Skip to content

Commit

Permalink
Properly set certain conditions to True when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
abays authored and dmendiza committed Nov 20, 2023
1 parent 0b11bbe commit 50f8ad7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 5 deletions.
25 changes: 21 additions & 4 deletions controllers/barbican_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ func (r *BarbicanReconciler) Reconcile(ctx context.Context, req ctrl.Request) (r
condition.UnknownCondition(barbicanv1beta1.BarbicanAPIReadyCondition, condition.InitReason, barbicanv1beta1.BarbicanAPIReadyInitMessage),
condition.UnknownCondition(barbicanv1beta1.BarbicanWorkerReadyCondition, condition.InitReason, barbicanv1beta1.BarbicanWorkerReadyInitMessage),
condition.UnknownCondition(barbicanv1beta1.BarbicanKeystoneListenerReadyCondition, condition.InitReason, barbicanv1beta1.BarbicanKeystoneListenerReadyInitMessage),
condition.UnknownCondition(condition.DeploymentReadyCondition, condition.InitReason, condition.DeploymentReadyInitMessage),
condition.UnknownCondition(condition.NetworkAttachmentsReadyCondition, condition.InitReason, condition.NetworkAttachmentsReadyInitMessage),
// service account, role, rolebinding conditions
condition.UnknownCondition(condition.ServiceAccountReadyCondition, condition.InitReason, condition.ServiceAccountReadyInitMessage),
Expand Down Expand Up @@ -318,7 +317,7 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb
// TODO(dmendiza): Handle service upgrade

// create or update Barbican API deployment
_, op, err = r.apiDeploymentCreateOrUpdate(ctx, instance, helper)
barbicanAPI, op, err := r.apiDeploymentCreateOrUpdate(ctx, instance, helper)
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
barbicanv1beta1.BarbicanAPIReadyCondition,
Expand All @@ -332,8 +331,14 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
}

// Mirror BarbicanAPI's condition status
c := barbicanAPI.Status.Conditions.Mirror(barbicanv1beta1.BarbicanAPIReadyCondition)
if c != nil {
instance.Status.Conditions.Set(c)
}

// create or update Barbican Worker deployment
_, op, err = r.workerDeploymentCreateOrUpdate(ctx, instance, helper)
barbicanWorker, op, err := r.workerDeploymentCreateOrUpdate(ctx, instance, helper)
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
barbicanv1beta1.BarbicanWorkerReadyCondition,
Expand All @@ -347,8 +352,14 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
}

// Mirror BarbicanWorker's condition status
c = barbicanWorker.Status.Conditions.Mirror(barbicanv1beta1.BarbicanWorkerReadyCondition)
if c != nil {
instance.Status.Conditions.Set(c)
}

// create or update Barbican KeystoneListener deployment
_, op, err = r.keystoneListenerDeploymentCreateOrUpdate(ctx, instance, helper)
barbicanKeystoneListener, op, err := r.keystoneListenerDeploymentCreateOrUpdate(ctx, instance, helper)
if err != nil {
instance.Status.Conditions.Set(condition.FalseCondition(
barbicanv1beta1.BarbicanKeystoneListenerReadyCondition,
Expand All @@ -362,6 +373,12 @@ func (r *BarbicanReconciler) reconcileNormal(ctx context.Context, instance *barb
Log.Info(fmt.Sprintf("Deployment %s successfully reconciled - operation: %s", instance.Name, string(op)))
}

// Mirror BarbicanKeystoneListener's condition status
c = barbicanKeystoneListener.Status.Conditions.Mirror(barbicanv1beta1.BarbicanKeystoneListenerReadyCondition)
if c != nil {
instance.Status.Conditions.Set(c)
}

// TODO(dmendiza): Handle API endpoints

// TODO(dmendiza): Understand what Glance is doing with the API conditions and maybe do it here too
Expand Down
3 changes: 2 additions & 1 deletion controllers/barbicanapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ func (r *BarbicanAPIReconciler) Reconcile(ctx context.Context, req ctrl.Request)
condition.UnknownCondition(condition.ServiceConfigReadyCondition, condition.InitReason, condition.ServiceConfigReadyInitMessage),
condition.UnknownCondition(condition.DeploymentReadyCondition, condition.InitReason, condition.DeploymentReadyInitMessage),
// right now we have no dedicated KeystoneServiceReadyInitMessage and KeystoneEndpointReadyInitMessage
condition.UnknownCondition(condition.KeystoneServiceReadyCondition, condition.InitReason, ""),
condition.UnknownCondition(condition.KeystoneEndpointReadyCondition, condition.InitReason, ""),
condition.UnknownCondition(condition.NetworkAttachmentsReadyCondition, condition.InitReason, condition.NetworkAttachmentsReadyInitMessage),
)
Expand Down Expand Up @@ -271,6 +270,8 @@ func (r *BarbicanAPIReconciler) generateServiceConfigs(
return err
}

instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)

templateParameters := map[string]interface{}{
"DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s",
instance.Spec.DatabaseUser,
Expand Down
2 changes: 2 additions & 0 deletions controllers/barbicankeystonelistener_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ func (r *BarbicanKeystoneListenerReconciler) generateServiceConfigs(
return err
}

instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)

templateParameters := map[string]interface{}{
"DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s",
instance.Spec.DatabaseUser,
Expand Down
2 changes: 2 additions & 0 deletions controllers/barbicanworker_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ func (r *BarbicanWorkerReconciler) generateServiceConfigs(
return err
}

instance.Status.Conditions.MarkTrue(condition.InputReadyCondition, condition.InputReadyMessage)

templateParameters := map[string]interface{}{
"DatabaseConnection": fmt.Sprintf("mysql+pymysql://%s:%s@%s/%s",
instance.Spec.DatabaseUser,
Expand Down

0 comments on commit 50f8ad7

Please sign in to comment.