Skip to content

Commit

Permalink
Merge pull request #370 from fmount/conditions
Browse files Browse the repository at this point in the history
Add ObservedGeneration to the sub Resources
  • Loading branch information
openshift-merge-bot[bot] authored Apr 22, 2024
2 parents 70b1026 + 57c43f6 commit 0607c4a
Show file tree
Hide file tree
Showing 21 changed files with 311 additions and 68 deletions.
8 changes: 8 additions & 0 deletions api/bases/telemetry.openstack.org_autoscalings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ spec:
items:
type: string
type: array
observedGeneration:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
prometheusHostname:
description: PrometheusHost - Hostname for prometheus used for autoscaling
type: string
Expand Down
8 changes: 8 additions & 0 deletions api/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ spec:
items:
type: string
type: array
observedGeneration:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
readyCount:
description: ReadyCount of ceilometer instances
format: int32
Expand Down
8 changes: 8 additions & 0 deletions api/bases/telemetry.openstack.org_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ spec:
type: string
description: Map of hashes to track e.g. job status
type: object
observedGeneration:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
type: object
type: object
served: true
Expand Down
8 changes: 8 additions & 0 deletions api/bases/telemetry.openstack.org_metricstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,14 @@ spec:
- type
type: object
type: array
observedGeneration:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
prometheusTLSPatched:
type: boolean
type: object
Expand Down
2 changes: 1 addition & 1 deletion api/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ spec:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the opentack-operator in the top-level CR (e.g. the
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/autoscaling_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ type AutoscalingStatus struct {

// API endpoint
APIEndpoints map[string]string `json:"apiEndpoint,omitempty"`

// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
// the openstack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/ceilometer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ type CeilometerStatus struct {

// Networks in addtion to the cluster network, the service is attached to
Networks []string `json:"networks,omitempty"`

// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
// the openstack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
6 changes: 6 additions & 0 deletions api/v1beta1/logging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ type LoggingStatus struct {

// Conditions
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`

// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
// the openstack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
5 changes: 5 additions & 0 deletions api/v1beta1/metricstorage_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ type MetricStorageSpec struct {
type MetricStorageStatus struct {
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`
PrometheusTLSPatched bool `json:"prometheusTLSPatched,omitempty" optional:"true"`
// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
// the openstack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/telemetry_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ type TelemetryStatus struct {
// ObservedGeneration - the most recent generation observed for this
// service. If the observed generation is less than the spec generation,
// then the controller has not processed the latest changes injected by
// the opentack-operator in the top-level CR (e.g. the ContainerImage)
// the openstack-operator in the top-level CR (e.g. the ContainerImage)
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/telemetry.openstack.org_autoscalings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,14 @@ spec:
items:
type: string
type: array
observedGeneration:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
prometheusHostname:
description: PrometheusHost - Hostname for prometheus used for autoscaling
type: string
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/telemetry.openstack.org_ceilometers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ spec:
items:
type: string
type: array
observedGeneration:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
readyCount:
description: ReadyCount of ceilometer instances
format: int32
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/telemetry.openstack.org_loggings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ spec:
type: string
description: Map of hashes to track e.g. job status
type: object
observedGeneration:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
type: object
type: object
served: true
Expand Down
8 changes: 8 additions & 0 deletions config/crd/bases/telemetry.openstack.org_metricstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,14 @@ spec:
- type
type: object
type: array
observedGeneration:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
prometheusTLSPatched:
type: boolean
type: object
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/telemetry.openstack.org_telemetries.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1766,7 +1766,7 @@ spec:
description: ObservedGeneration - the most recent generation observed
for this service. If the observed generation is less than the spec
generation, then the controller has not processed the latest changes
injected by the opentack-operator in the top-level CR (e.g. the
injected by the openstack-operator in the top-level CR (e.g. the
ContainerImage)
format: int64
type: integer
Expand Down
10 changes: 6 additions & 4 deletions controllers/aodh_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,13 @@ func (r *AutoscalingReconciler) reconcileNormalAodh(
return ctrl.Result{}, err
}

instance.Status.ReadyCount = sfset.GetStatefulSet().Status.ReadyReplicas
if instance.Status.ReadyCount > 0 {
instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition, condition.DeploymentReadyMessage)
if sfset.GetStatefulSet().Generation == sfset.GetStatefulSet().Status.ObservedGeneration {
instance.Status.ReadyCount = sfset.GetStatefulSet().Status.ReadyReplicas
if instance.Status.ReadyCount > 0 {
instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition, condition.DeploymentReadyMessage)
}
instance.Status.Networks = instance.Spec.Aodh.NetworkAttachmentDefinitions
}
instance.Status.Networks = instance.Spec.Aodh.NetworkAttachmentDefinitions

//
// create service/s
Expand Down
1 change: 1 addition & 0 deletions controllers/autoscaling_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func (r *AutoscalingReconciler) Reconcile(ctx context.Context, req ctrl.Request)
condition.UnknownCondition(condition.TLSInputReadyCondition, condition.InitReason, condition.InputReadyInitMessage),
)
instance.Status.Conditions.Init(&cl)
instance.Status.ObservedGeneration = instance.Generation

// If we're not deleting this and the service object doesn't have our finalizer, add it.
if instance.DeletionTimestamp.IsZero() && controllerutil.AddFinalizer(instance, helper.GetFinalizer()) || isNewInstance {
Expand Down
37 changes: 18 additions & 19 deletions controllers/ceilometer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,13 @@ func (r *CeilometerReconciler) Reconcile(ctx context.Context, req ctrl.Request)
condition.UnknownCondition(condition.InputReadyCondition, condition.InitReason, condition.InputReadyInitMessage),
condition.UnknownCondition(condition.ServiceConfigReadyCondition, condition.InitReason, condition.ServiceConfigReadyInitMessage),
condition.UnknownCondition(condition.DeploymentReadyCondition, condition.InitReason, condition.DeploymentReadyInitMessage),
// service account, role, rolebinding conditions
condition.UnknownCondition(condition.ServiceAccountReadyCondition, condition.InitReason, condition.ServiceAccountReadyInitMessage),
condition.UnknownCondition(condition.RoleReadyCondition, condition.InitReason, condition.RoleReadyInitMessage),
condition.UnknownCondition(condition.RoleBindingReadyCondition, condition.InitReason, condition.RoleBindingReadyInitMessage),
// right now we have no dedicated KeystoneServiceReadyInitMessage
condition.UnknownCondition(condition.KeystoneServiceReadyCondition, condition.InitReason, ""),
condition.UnknownCondition(condition.TLSInputReadyCondition, condition.InitReason, condition.InputReadyInitMessage),
)

instance.Status.Conditions.Init(&cl)
instance.Status.ObservedGeneration = instance.Generation

// If we're not deleting this and the service object doesn't have our finalizer, add it.
if instance.DeletionTimestamp.IsZero() && controllerutil.AddFinalizer(instance, helper.GetFinalizer()) || isNewInstance {
Expand Down Expand Up @@ -523,22 +520,24 @@ func (r *CeilometerReconciler) reconcileNormal(ctx context.Context, instance *te
return ctrl.Result{}, err
}

instance.Status.ReadyCount = sfset.GetStatefulSet().Status.ReadyReplicas
if instance.Status.ReadyCount > 0 {
instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition, condition.DeploymentReadyMessage)
}
instance.Status.Networks = instance.Spec.NetworkAttachmentDefinitions

_, _, err = ceilometer.Service(instance, helper, ceilometer.CeilometerPrometheusPort, serviceLabels)
if err != nil {
return ctrl.Result{}, err
}

if instance.Status.Conditions.AllSubConditionIsTrue() {
instance.Status.Conditions.MarkTrue(
condition.ReadyCondition, condition.ReadyMessage)
// Evaluate the last part of the reconciliation only if we see the last
// version of the CR
if sfset.GetStatefulSet().Generation == sfset.GetStatefulSet().Status.ObservedGeneration {
instance.Status.ReadyCount = sfset.GetStatefulSet().Status.ReadyReplicas
instance.Status.Networks = instance.Spec.NetworkAttachmentDefinitions
_, _, err = ceilometer.Service(instance, helper, ceilometer.CeilometerPrometheusPort, serviceLabels)
if err != nil {
return ctrl.Result{}, err
}
if instance.Status.ReadyCount > 0 {
instance.Status.Conditions.MarkTrue(condition.DeploymentReadyCondition, condition.DeploymentReadyMessage)
}
if instance.Status.Conditions.AllSubConditionIsTrue() {
instance.Status.Conditions.MarkTrue(
condition.ReadyCondition, condition.ReadyMessage)
}
Log.Info("Reconciled Service successfully")
}
Log.Info("Reconciled Service successfully")
return ctrl.Result{}, nil
}

Expand Down
1 change: 1 addition & 0 deletions controllers/logging_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ func (r *LoggingReconciler) Reconcile(ctx context.Context, req ctrl.Request) (re
)

instance.Status.Conditions.Init(&cl)
instance.Status.ObservedGeneration = instance.Generation

// If we're not deleting this and the service object doesn't have our finalizer, add it.
if instance.DeletionTimestamp.IsZero() && controllerutil.AddFinalizer(instance, helper.GetFinalizer()) || isNewInstance {
Expand Down
1 change: 1 addition & 0 deletions controllers/metricstorage_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func (r *MetricStorageReconciler) Reconcile(ctx context.Context, req ctrl.Reques
)

instance.Status.Conditions.Init(&cl)
instance.Status.ObservedGeneration = instance.Generation

// If we're not deleting this and the service object doesn't have our finalizer, add it.
if instance.DeletionTimestamp.IsZero() && controllerutil.AddFinalizer(instance, helper.GetFinalizer()) || isNewInstance {
Expand Down
Loading

0 comments on commit 0607c4a

Please sign in to comment.