Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#1029 from rabi/override
Browse files Browse the repository at this point in the history
Handle global services with servicesOverride in DedupeServices
  • Loading branch information
openshift-merge-bot[bot] authored Aug 27, 2024
2 parents 1d364c6 + 21e460d commit 35796ae
Show file tree
Hide file tree
Showing 5 changed files with 468 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
// deploy those services for each OpenStackDataPlaneNodeSet. Otherwise,
// deploy with the OpenStackDataPlaneNodeSet's Services.
var deployResult *ctrl.Result
if len(instance.Spec.ServicesOverride) != 0 {
deployResult, err = deployer.Deploy(nodesetServiceMap[deployment.AllNodeSets])
} else {
deployResult, err = deployer.Deploy(nodesetServiceMap[nodeSet.Name])
}
deployResult, err = deployer.Deploy(nodesetServiceMap[nodeSet.Name])

nsConditions := instance.Status.NodeSetConditions[nodeSet.Name]
nsConditions.Set(nsConditions.Mirror(dataplanev1.NodeSetDeploymentReadyCondition))
Expand Down
4 changes: 0 additions & 4 deletions pkg/dataplane/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,4 @@ const (

//HostnameLabel label for marking secrets to be watched for changes
HostnameLabel = "hostname"

//AllNodeSets Key used in nodeset service map for all nodesets when
//using serviceOverride.
AllNodeSets = "AllNodeSets"
)
23 changes: 11 additions & 12 deletions pkg/dataplane/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,22 +161,21 @@ func DedupeServices(ctx context.Context, helper *helper.Helper,
var globalServices []string
var services []string
var err error
if len(serviceOverride) != 0 {
services, globalServices, err = dedupe(ctx, helper, serviceOverride, globalServices)

for _, nodeset := range nodesets {
var nodeSetServices []string
if len(serviceOverride) != 0 {
nodeSetServices = serviceOverride
} else {
nodeSetServices = nodeset.Spec.Services
}
services, globalServices, err = dedupe(ctx, helper, nodeSetServices, globalServices)
if err != nil {
return nil, err
}
nodeSetServiceMap[AllNodeSets] = services
} else {
for _, nodeset := range nodesets {
services, globalServices, err = dedupe(ctx, helper, nodeset.Spec.Services, globalServices)
if err != nil {
return nil, err
}
nodeSetServiceMap[nodeset.Name] = services
}
nodeSetServiceMap[nodeset.Name] = services
}
helper.GetLogger().Info(fmt.Sprintf("Current Global Services %s", globalServices))
helper.GetLogger().Info(fmt.Sprintf("Current Global Services %v", globalServices))
return nodeSetServiceMap, nil
}

Expand Down
28 changes: 28 additions & 0 deletions tests/functional/dataplane/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,34 @@ func DuplicateServiceDeploymentSpec() map[string]interface{} {
}
}

// Build OpenStackDataPlnaeDeploymentSpec with global service
func GlobalServiceDeploymentSpec() map[string]interface{} {
return map[string]interface{}{
"nodeSets": []string{
"alpha-nodeset",
"beta-nodeset",
},
"servicesOverride": []string{
"foo-service",
"global-service",
"foo-update-service",
},
}
}

// Build OpenStackDataPlnaeDeploymentSpec with single global service
func SingleGlobalServiceDeploymentSpec() map[string]interface{} {
return map[string]interface{}{
"nodeSets": []string{
"alpha-nodeset",
"beta-nodeset",
},
"servicesOverride": []string{
"global-service",
},
}
}

func DefaultNetConfigSpec() map[string]interface{} {
return map[string]interface{}{
"networks": []map[string]interface{}{{
Expand Down
Loading

0 comments on commit 35796ae

Please sign in to comment.