Skip to content

Commit

Permalink
Add NodeSetMinorUpdateReadyCondition to NodeSet
Browse files Browse the repository at this point in the history
The NodeSetMinorUpdateReadyCondition is set if the NodeSet has been
updated with the latest version. To satisfy the check, a NodeSet must
have a completed deployment that:

- deployed a service with EDPMServiceType = 'update'
- used the latest version

Jira: https://issues.redhat.com/browse/OSPRH-8176
Signed-off-by: James Slagle <[email protected]>
  • Loading branch information
slagle committed Jul 1, 2024
1 parent 8b2b3bf commit c19f8a1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
7 changes: 7 additions & 0 deletions apis/dataplane/v1beta1/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,11 @@ const (

// NodeSetServiceDeploymentErrorMessage error
NodeSetServiceDeploymentErrorMessage = "Deployment error occurred in %s service"

// NodeSetMinorUpdateReadyCondition Status=True condition indicates if the
// NodeSet minor update is finished and successful.
NodeSetMinorUpdateReadyCondition condition.Type = "NodeSetMinorUpdateReady"

// NodeSetMinorUpdateReadyMessage ready
NodeSetMinorUpdateReadyMessage = "Minor update ready for NodeSet"
)
38 changes: 36 additions & 2 deletions controllers/dataplane/openstackdataplanenodeset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
}
}

isDeploymentReady, isDeploymentRunning, isDeploymentFailed, failedDeployment, err := checkDeployment(helper, instance)
isDeploymentReady, isDeploymentRunning, isDeploymentFailed, failedDeployment, err := checkDeployment(helper, instance, version)
if !isDeploymentFailed && err != nil {
instance.Status.Conditions.MarkFalse(
condition.DeploymentReadyCondition,
Expand Down Expand Up @@ -464,6 +464,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req

func checkDeployment(helper *helper.Helper,
instance *dataplanev1.OpenStackDataPlaneNodeSet,
version *openstackv1.OpenStackVersion,
) (bool, bool, bool, string, error) {
// Get all completed deployments
var failedDeployment string
Expand Down Expand Up @@ -530,8 +531,41 @@ func checkDeployment(helper *helper.Helper,
}
instance.Status.DeployedConfigHash = deployment.Status.NodeSetHashes[instance.Name]
instance.Status.DeployedVersion = deployment.Status.DeployedVersion
}

// Get list of services by name, either from ServicesOverride or
// the NodeSet.
var services []string
if len(deployment.Spec.ServicesOverride) != 0 {
services = deployment.Spec.ServicesOverride
} else {
services = instance.Spec.Services
}

// For each service, check if EDPMServiceType is "update", and the
// deployment deployed the latest version.
for _, serviceName := range services {
service := &dataplanev1.OpenStackDataPlaneService{}
name := types.NamespacedName{
Namespace: instance.Namespace,
Name: serviceName,
}
err := helper.GetClient().Get(context.Background(), name, service)
if err != nil {
helper.GetLogger().Error(err, "Unable to retrieve OpenStackDataPlaneService %v")
return false, false, false, failedDeployment, err
}

if service.Spec.EDPMServiceType != "update" {
continue
}

if deployment.Status.DeployedVersion == version.Spec.TargetVersion {
instance.Status.Conditions.MarkTrue(
dataplanev1.NodeSetMinorUpdateReadyCondition,
dataplanev1.NodeSetMinorUpdateReadyMessage)
}
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/openstack/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func DataplaneNodesetsDeployed(version *corev1beta1.OpenStackVersion, dataplaneN
if !nodeset.IsReady() {
return false
}
if nodeset.Status.DeployedVersion != version.Spec.TargetVersion {
if !nodeset.Status.Conditions.IsTrue(dataplanev1.NodeSetMinorUpdateReadyCondition) {
return false
}

Expand Down

0 comments on commit c19f8a1

Please sign in to comment.