Skip to content

Commit

Permalink
Revert "Remove the deployed attribute from deployment"
Browse files Browse the repository at this point in the history
This reverts commit 5a55c47.

Without the status.Deployed boolean flag on OpenStackDataPlaneDeployment
there is no mechanism in place to prevert the full reconcile of a
Deployment. While the immutable annotation prevents user edits to the
spec, other changes could still trigger Deployment reconciles.

In the case of testing minor updates, it was discovered that when the
ansible runner image as specified by the
RELATED_IMAGE_ANSIBLEEE_IMAGE_URL_DEFAULT env var in the
openstack-operator csv is changed, it will re-execute the ansible for
all existing Deployments. This breaks the minor update workflow as
things are done out of order, and breaks the expectation that it is the
user who starts ansible executions as opposed to automatically.

Jira: OSPRH-8923
Signed-off-by: James Slagle <[email protected]>
  • Loading branch information
slagle committed Jul 24, 2024
1 parent 803a50a commit 4f117a0
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ spec:
additionalProperties:
type: string
type: object
deployed:
type: boolean
deployedVersion:
type: string
nodeSetConditions:
Expand Down
6 changes: 6 additions & 0 deletions apis/dataplane/v1beta1/openstackdataplanedeployment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ type OpenStackDataPlaneDeploymentStatus struct {

// DeployedVersion
DeployedVersion string `json:"deployedVersion,omitempty"`

// +operator-sdk:csv:customresourcedefinitions:type=status,xDescriptors={"urn:alm:descriptor:com.tectonic.ui:booleanSwitch"}
// Deployed
Deployed bool `json:"deployed,omitempty" optional:"true"`
}

//+kubebuilder:object:root=true
Expand Down Expand Up @@ -147,6 +151,8 @@ func (instance *OpenStackDataPlaneDeployment) InitConditions() {

}
}

instance.Status.Deployed = false
}

// InitHashesAndImages - Initialize ConfigHashes and Images
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ spec:
additionalProperties:
type: string
type: object
deployed:
type: boolean
deployedVersion:
type: string
nodeSetConditions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
Log,
)

// If the deploy is already done, return immediately.
if instance.Status.Deployed {
Log.Info("Already deployed", "instance.Status.Deployed", instance.Status.Deployed)
return ctrl.Result{}, nil
}

// initialize status if Conditions is nil, but do not reset if it already
// exists
isNewInstance := instance.Status.Conditions == nil
Expand Down Expand Up @@ -274,6 +280,8 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
for _, nodeSet := range nodeSets.Items {

Log.Info(fmt.Sprintf("Deploying NodeSet: %s", nodeSet.Name))
Log.Info("Set Status.Deployed to false", "instance", instance)
instance.Status.Deployed = false
Log.Info("Set DeploymentReadyCondition false")
instance.Status.Conditions.MarkFalse(
condition.DeploymentReadyCondition, condition.RequestedReason,
Expand Down Expand Up @@ -366,6 +374,7 @@ func (r *OpenStackDataPlaneDeploymentReconciler) Reconcile(ctx context.Context,
Log.Info("Set DeploymentReadyCondition true")
instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition, condition.DeploymentReadyMessage)
Log.Info("Set Status.Deployed to true", "instance", instance)
instance.Status.Deployed = true
if version != nil {
instance.Status.DeployedVersion = version.Spec.TargetVersion
}
Expand Down
5 changes: 5 additions & 0 deletions docs/assemblies/dataplane_resources.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ OpenStackDataPlaneDeploymentStatus defines the observed state of OpenStackDataPl
| DeployedVersion
| string
| false
| deployed
| Deployed
| bool
| false
|===
<<custom-resources,Back to Custom Resources>>
Expand Down

0 comments on commit 4f117a0

Please sign in to comment.