Skip to content

Commit 890f2ee

Browse files
Merge pull request #491 from fmount/observed_generation
Add Status.ObservedGeneration to the top-level Glance CR
2 parents cc5c8f9 + cc47280 commit 890f2ee

File tree

5 files changed

+24
-0
lines changed

5 files changed

+24
-0
lines changed

api/bases/glance.openstack.org_glances.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,9 @@ spec:
10851085
additionalProperties:
10861086
type: string
10871087
type: object
1088+
observedGeneration:
1089+
format: int64
1090+
type: integer
10881091
serviceID:
10891092
type: string
10901093
type: object

api/v1beta1/glance_types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,12 @@ type GlanceStatus struct {
177177

178178
// GlanceAPIReadyCounts -
179179
GlanceAPIReadyCounts map[string]int32 `json:"glanceAPIReadyCounts,omitempty"`
180+
181+
// ObservedGeneration - the most recent generation observed for this
182+
// service. If the observed generation is less than the spec generation,
183+
// then the controller has not processed the latest changes injected by
184+
// the opentack-operator in the top-level CR (e.g. the ContainerImage)
185+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
180186
}
181187

182188
//+kubebuilder:object:root=true

config/crd/bases/glance.openstack.org_glances.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,9 @@ spec:
10851085
additionalProperties:
10861086
type: string
10871087
type: object
1088+
observedGeneration:
1089+
format: int64
1090+
type: integer
10881091
serviceID:
10891092
type: string
10901093
type: object

controllers/glance_controller.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,10 @@ func (r *GlanceReconciler) reconcileInit(
485485
}
486486
instance.Status.Conditions.MarkTrue(condition.DBSyncReadyCondition, condition.DBSyncReadyMessage)
487487
// run Glance db sync - end
488+
489+
// when job passed, mark NetworkAttachmentsReadyCondition ready, because we
490+
// pass NADs as serviceAnnotation to glance-dbsync job
491+
instance.Status.Conditions.MarkTrue(condition.NetworkAttachmentsReadyCondition, condition.NetworkAttachmentsReadyMessage)
488492
r.Log.Info(fmt.Sprintf("Reconciled Service '%s' init successfully", instance.Name))
489493
return ctrl.Result{}, nil
490494
}
@@ -703,6 +707,7 @@ func (r *GlanceReconciler) reconcileNormal(ctx context.Context, instance *glance
703707

704708
// We reached the end of the Reconcile, update the Ready condition based on
705709
// the sub conditions
710+
instance.Status.ObservedGeneration = instance.Generation
706711
if instance.Status.Conditions.AllSubConditionIsTrue() {
707712
instance.Status.Conditions.MarkTrue(
708713
condition.ReadyCondition, condition.ReadyMessage)

controllers/glanceapi_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,13 @@ func (r *GlanceAPIReconciler) reconcileNormal(ctx context.Context, instance *gla
593593
// added or removed from an already existing API
594594
if hashChanged {
595595
if err = r.glanceAPIRefresh(ctx, helper, instance); err != nil {
596+
instance.Status.Conditions.MarkFalse(
597+
condition.DeploymentReadyCondition,
598+
condition.ErrorReason,
599+
condition.SeverityWarning,
600+
condition.DeploymentReadyErrorMessage,
601+
err.Error(),
602+
)
596603
return ctrl.Result{}, err
597604
}
598605
}

0 commit comments

Comments
 (0)