Skip to content

Commit 9c78a27

Browse files
committed
Fix nodeset status changes with BmhRef hash changes
Attempt 2: The current logic is still flawed and it would never reach NodeSetReady after deleting BMHs and running deployment. Jira: https://issues.redhat.com/browse/OSPRH-14952 Signed-off-by: rabi <[email protected]>
1 parent 06e9880 commit 9c78a27

10 files changed

+40
-5
lines changed

apis/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ spec:
9191
additionalProperties:
9292
type: string
9393
type: object
94+
bmhRefHashes:
95+
additionalProperties:
96+
type: string
97+
type: object
9498
conditions:
9599
items:
96100
properties:

apis/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ spec:
903903
type: string
904904
type: object
905905
type: object
906+
bmhRefHash:
907+
type: string
906908
conditions:
907909
items:
908910
properties:

apis/dataplane/v1beta1/openstackdataplanedeployment_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ type OpenStackDataPlaneDeploymentStatus struct {
9090
// NodeSetHashes
9191
NodeSetHashes map[string]string `json:"nodeSetHashes,omitempty" optional:"true"`
9292

93+
// BmhRefHashes
94+
BmhRefHashes map[string]string `json:"bmhRefHashes,omitempty" optional:"true"`
95+
9396
// ContainerImages
9497
ContainerImages map[string]string `json:"containerImages,omitempty"`
9598

@@ -185,4 +188,7 @@ func (instance *OpenStackDataPlaneDeployment) InitHashesAndImages() {
185188
if instance.Status.ContainerImages == nil {
186189
instance.Status.ContainerImages = make(map[string]string)
187190
}
191+
if instance.Status.BmhRefHashes == nil {
192+
instance.Status.BmhRefHashes = make(map[string]string)
193+
}
188194
}

apis/dataplane/v1beta1/openstackdataplanenodeset_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ type OpenStackDataPlaneNodeSetStatus struct {
155155
// DeployedVersion
156156
DeployedVersion string `json:"deployedVersion,omitempty"`
157157

158+
// bmhRefHash - Current hash of the BMHs
159+
BmhRefHash string `json:"bmhRefHash,omitempty"`
160+
158161
//DeployedBmhHash - Hash of BMHs deployed
159162
DeployedBmhHash string `json:"deployedBmhHash,omitempty"`
160163
}

apis/dataplane/v1beta1/zz_generated.deepcopy.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bindata/crds/crds.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17922,6 +17922,10 @@ spec:
1792217922
additionalProperties:
1792317923
type: string
1792417924
type: object
17925+
bmhRefHashes:
17926+
additionalProperties:
17927+
type: string
17928+
type: object
1792517929
conditions:
1792617930
items:
1792717931
properties:
@@ -18902,6 +18906,8 @@ spec:
1890218906
type: string
1890318907
type: object
1890418908
type: object
18909+
bmhRefHash:
18910+
type: string
1890518911
conditions:
1890618912
items:
1890718913
properties:

config/crd/bases/dataplane.openstack.org_openstackdataplanedeployments.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ spec:
9191
additionalProperties:
9292
type: string
9393
type: object
94+
bmhRefHashes:
95+
additionalProperties:
96+
type: string
97+
type: object
9498
conditions:
9599
items:
96100
properties:

config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -903,6 +903,8 @@ spec:
903903
type: string
904904
type: object
905905
type: object
906+
bmhRefHash:
907+
type: string
906908
conditions:
907909
items:
908910
properties:

controllers/dataplane/openstackdataplanedeployment_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
320320
dataplanev1.NodeSetDeploymentReadyCondition,
321321
condition.DeploymentReadyMessage)
322322
instance.Status.NodeSetHashes[nodeSet.Name] = nodeSet.Status.ConfigHash
323+
instance.Status.BmhRefHashes[nodeSet.Name] = nodeSet.Status.BmhRefHash
323324
}
324325
}
325326

controllers/dataplane/openstackdataplanenodeset_controller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,11 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
379379
if err != nil || !provResult.IsProvisioned {
380380
return ctrl.Result{}, err
381381
}
382+
instance.Status.BmhRefHash = provResult.BmhRefHash
382383
}
383384

384385
isDeploymentReady, isDeploymentRunning, isDeploymentFailed, failedDeployment, err := checkDeployment(
385-
ctx, helper, instance, provResult.BmhRefHash)
386+
ctx, helper, instance)
386387
if !isDeploymentFailed && err != nil {
387388
instance.Status.Conditions.MarkFalse(
388389
condition.DeploymentReadyCondition,
@@ -426,7 +427,7 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
426427
Log.Info("Set NodeSet DeploymentReadyCondition true")
427428
instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition,
428429
condition.DeploymentReadyMessage)
429-
instance.Status.DeployedBmhHash = provResult.BmhRefHash
430+
instance.Status.DeployedBmhHash = instance.Status.BmhRefHash
430431
} else if isDeploymentRunning {
431432
Log.Info("Deployment still running...", "instance", instance)
432433
Log.Info("Set NodeSet DeploymentReadyCondition false")
@@ -462,7 +463,6 @@ func (r *OpenStackDataPlaneNodeSetReconciler) Reconcile(ctx context.Context, req
462463

463464
func checkDeployment(ctx context.Context, helper *helper.Helper,
464465
instance *dataplanev1.OpenStackDataPlaneNodeSet,
465-
bmhRefHash string,
466466
) (bool, bool, bool, string, error) {
467467
// Get all completed deployments
468468
var failedDeployment string
@@ -520,8 +520,8 @@ func checkDeployment(ctx context.Context, helper *helper.Helper,
520520
// If the nodeset configHash does not match with what's in the deployment or
521521
// deployedBmhHash is different from current bmhRefHash.
522522
if (deployment.Status.NodeSetHashes[instance.Name] != instance.Status.ConfigHash) ||
523-
(!instance.Spec.PreProvisioned && instance.Status.DeployedBmhHash != "" &&
524-
instance.Status.DeployedBmhHash != bmhRefHash) {
523+
(!instance.Spec.PreProvisioned &&
524+
deployment.Status.BmhRefHashes[instance.Name] != instance.Status.BmhRefHash) {
525525
continue
526526
}
527527
isDeploymentReady = true

0 commit comments

Comments
 (0)