Skip to content

Commit 2532f09

Browse files
Merge pull request #389 from kstrenkova/fix-condition-status
Fix status reporting
2 parents dcf5983 + 8a271a1 commit 2532f09

14 files changed

Lines changed: 131 additions & 19 deletions

api/bases/test.openstack.org_ansibletests.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,14 @@ spec:
17061706
type: array
17071707
description: NetworkAttachments status of the deployment pods
17081708
type: object
1709+
observedGeneration:
1710+
description: |-
1711+
ObservedGeneration - the most recent generation observed for this
1712+
service. If the observed generation is less than the spec generation,
1713+
then the controller has not processed the latest changes injected by
1714+
the opentack-operator in the top-level CR (e.g. the ContainerImage)
1715+
format: int64
1716+
type: integer
17091717
type: object
17101718
type: object
17111719
served: true

api/bases/test.openstack.org_horizontests.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,14 @@ spec:
15051505
type: array
15061506
description: NetworkAttachments status of the deployment pods
15071507
type: object
1508+
observedGeneration:
1509+
description: |-
1510+
ObservedGeneration - the most recent generation observed for this
1511+
service. If the observed generation is less than the spec generation,
1512+
then the controller has not processed the latest changes injected by
1513+
the opentack-operator in the top-level CR (e.g. the ContainerImage)
1514+
format: int64
1515+
type: integer
15081516
type: object
15091517
type: object
15101518
served: true

api/bases/test.openstack.org_tempests.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,14 @@ spec:
23482348
type: array
23492349
description: NetworkAttachments status of the deployment pods
23502350
type: object
2351+
observedGeneration:
2352+
description: |-
2353+
ObservedGeneration - the most recent generation observed for this
2354+
service. If the observed generation is less than the spec generation,
2355+
then the controller has not processed the latest changes injected by
2356+
the opentack-operator in the top-level CR (e.g. the ContainerImage)
2357+
format: int64
2358+
type: integer
23512359
type: object
23522360
type: object
23532361
served: true

api/bases/test.openstack.org_tobikoes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,14 @@ spec:
17151715
type: array
17161716
description: NetworkAttachments status of the deployment pods
17171717
type: object
1718+
observedGeneration:
1719+
description: |-
1720+
ObservedGeneration - the most recent generation observed for this
1721+
service. If the observed generation is less than the spec generation,
1722+
then the controller has not processed the latest changes injected by
1723+
the opentack-operator in the top-level CR (e.g. the ContainerImage)
1724+
format: int64
1725+
type: integer
17181726
type: object
17191727
type: object
17201728
served: true

api/v1beta1/common.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ type CommonTestStatus struct {
133133
// Conditions
134134
Conditions condition.Conditions `json:"conditions,omitempty" optional:"true"`
135135

136+
// ObservedGeneration - the most recent generation observed for this
137+
// service. If the observed generation is less than the spec generation,
138+
// then the controller has not processed the latest changes injected by
139+
// the opentack-operator in the top-level CR (e.g. the ContainerImage)
140+
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
141+
136142
// NetworkAttachments status of the deployment pods
137143
NetworkAttachments map[string][]string `json:"networkAttachments,omitempty"`
138144
}

config/crd/bases/test.openstack.org_ansibletests.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1706,6 +1706,14 @@ spec:
17061706
type: array
17071707
description: NetworkAttachments status of the deployment pods
17081708
type: object
1709+
observedGeneration:
1710+
description: |-
1711+
ObservedGeneration - the most recent generation observed for this
1712+
service. If the observed generation is less than the spec generation,
1713+
then the controller has not processed the latest changes injected by
1714+
the opentack-operator in the top-level CR (e.g. the ContainerImage)
1715+
format: int64
1716+
type: integer
17091717
type: object
17101718
type: object
17111719
served: true

config/crd/bases/test.openstack.org_horizontests.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,14 @@ spec:
15051505
type: array
15061506
description: NetworkAttachments status of the deployment pods
15071507
type: object
1508+
observedGeneration:
1509+
description: |-
1510+
ObservedGeneration - the most recent generation observed for this
1511+
service. If the observed generation is less than the spec generation,
1512+
then the controller has not processed the latest changes injected by
1513+
the opentack-operator in the top-level CR (e.g. the ContainerImage)
1514+
format: int64
1515+
type: integer
15081516
type: object
15091517
type: object
15101518
served: true

config/crd/bases/test.openstack.org_tempests.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,6 +2348,14 @@ spec:
23482348
type: array
23492349
description: NetworkAttachments status of the deployment pods
23502350
type: object
2351+
observedGeneration:
2352+
description: |-
2353+
ObservedGeneration - the most recent generation observed for this
2354+
service. If the observed generation is less than the spec generation,
2355+
then the controller has not processed the latest changes injected by
2356+
the opentack-operator in the top-level CR (e.g. the ContainerImage)
2357+
format: int64
2358+
type: integer
23512359
type: object
23522360
type: object
23532361
served: true

config/crd/bases/test.openstack.org_tobikoes.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,6 +1715,14 @@ spec:
17151715
type: array
17161716
description: NetworkAttachments status of the deployment pods
17171717
type: object
1718+
observedGeneration:
1719+
description: |-
1720+
ObservedGeneration - the most recent generation observed for this
1721+
service. If the observed generation is less than the spec generation,
1722+
then the controller has not processed the latest changes injected by
1723+
the opentack-operator in the top-level CR (e.g. the ContainerImage)
1724+
format: int64
1725+
type: integer
17181726
type: object
17191727
type: object
17201728
served: true

internal/controller/ansibletest_controller.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,10 @@ func (r *AnsibleTestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
9494
// Always patch the instance status when exiting this function so we
9595
// can persist any changes.
9696
defer func() {
97-
// update the overall status condition if service is ready
98-
if instance.Status.Conditions.AllSubConditionIsTrue() {
99-
instance.Status.Conditions.MarkTrue(condition.ReadyCondition, condition.ReadyMessage)
97+
// Don't update the status, if reconciler Panics
98+
if r := recover(); r != nil {
99+
Log.Info(fmt.Sprintf("panic during reconcile %v\n", r))
100+
panic(r)
100101
}
101102
condition.RestoreLastTransitionTimes(&instance.Status.Conditions, savedConditions)
102103
if instance.Status.Conditions.IsUnknown(condition.ReadyCondition) {
@@ -122,8 +123,8 @@ func (r *AnsibleTestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
122123
// Register overall status immediately to have an early feedback
123124
// e.g. in the cli
124125
return ctrl.Result{}, nil
125-
126126
}
127+
instance.Status.ObservedGeneration = instance.Generation
127128

128129
workflowLength := len(instance.Spec.Workflow)
129130
nextAction, nextWorkflowStep, err := r.NextAction(ctx, instance, workflowLength)
@@ -151,6 +152,10 @@ func (r *AnsibleTestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
151152
condition.DeploymentReadyCondition,
152153
condition.DeploymentReadyMessage)
153154

155+
if instance.Status.Conditions.AllSubConditionIsTrue() {
156+
instance.Status.Conditions.MarkTrue(condition.ReadyCondition, condition.ReadyMessage)
157+
}
158+
154159
Log.Info(InfoTestingCompleted)
155160
return ctrl.Result{}, nil
156161

@@ -250,6 +255,11 @@ func (r *AnsibleTestReconciler) Reconcile(ctx context.Context, req ctrl.Request)
250255
return ctrlResult, nil
251256
}
252257
// Create a new pod - end
258+
259+
if instance.Status.Conditions.AllSubConditionIsTrue() {
260+
instance.Status.Conditions.MarkTrue(condition.ReadyCondition, condition.ReadyMessage)
261+
}
262+
253263
Log.Info("Reconciled Service successfully")
254264
return ctrl.Result{}, nil
255265
}

0 commit comments

Comments
 (0)