@@ -26,7 +26,7 @@ var _ = Describe("Operator Condition", func() {
26
26
By ("This test proves that an operator can upgrade successfully when" +
27
27
"Upgrade condition type is set in OperatorCondition CR. Plus, an operator" +
28
28
"chooses not to use OperatorCondition, the upgrade process will proceed as" +
29
- " asexpected . The overrides specification in OperatorCondition can be used to" +
29
+ " as expected . The overrides specification in OperatorCondition can be used to" +
30
30
" override the status condition. The overrides spec will remain in place until" +
31
31
"they are unset." )
32
32
c := newKubeClient ()
@@ -99,14 +99,17 @@ var _ = Describe("Operator Condition", func() {
99
99
Message : "test" ,
100
100
LastTransitionTime : metav1 .Now (),
101
101
}
102
+
103
+ var currentGen int64
102
104
Eventually (func () error {
103
105
cond , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).Get (context .TODO (), csvA .GetName (), metav1.GetOptions {})
104
106
if err != nil {
105
107
return err
106
108
}
107
-
108
- meta .SetStatusCondition (& cond .Status .Conditions , upgradeableFalseCondition )
109
- _ , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).UpdateStatus (context .TODO (), cond , metav1.UpdateOptions {})
109
+ currentGen = cond .ObjectMeta .GetGeneration ()
110
+ upgradeableFalseCondition .ObservedGeneration = currentGen
111
+ meta .SetStatusCondition (& cond .Spec .Conditions , upgradeableFalseCondition )
112
+ _ , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).Update (context .TODO (), cond , metav1.UpdateOptions {})
110
113
return err
111
114
112
115
}, pollInterval , pollDuration ).Should (Succeed ())
@@ -142,11 +145,13 @@ var _ = Describe("Operator Condition", func() {
142
145
}
143
146
Eventually (func () error {
144
147
cond , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).Get (context .TODO (), csvA .GetName (), metav1.GetOptions {})
145
- if err != nil {
148
+ if err != nil || currentGen == cond . ObjectMeta . GetGeneration () {
146
149
return err
147
150
}
148
- meta .SetStatusCondition (& cond .Status .Conditions , upgradeableTrueCondition )
149
- _ , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).UpdateStatus (context .TODO (), cond , metav1.UpdateOptions {})
151
+ currentGen = cond .ObjectMeta .GetGeneration ()
152
+ upgradeableTrueCondition .ObservedGeneration = cond .ObjectMeta .GetGeneration ()
153
+ meta .SetStatusCondition (& cond .Spec .Conditions , upgradeableTrueCondition )
154
+ _ , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).Update (context .TODO (), cond , metav1.UpdateOptions {})
150
155
return err
151
156
}, pollInterval , pollDuration ).Should (Succeed ())
152
157
@@ -157,11 +162,13 @@ var _ = Describe("Operator Condition", func() {
157
162
// Get the OperatorCondition for csvB and report that it is not upgradeable
158
163
Eventually (func () error {
159
164
cond , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).Get (context .TODO (), csvB .GetName (), metav1.GetOptions {})
160
- if err != nil {
165
+ if err != nil || currentGen == cond . ObjectMeta . GetGeneration () {
161
166
return err
162
167
}
163
- meta .SetStatusCondition (& cond .Status .Conditions , upgradeableFalseCondition )
164
- _ , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).UpdateStatus (context .TODO (), cond , metav1.UpdateOptions {})
168
+ currentGen = cond .ObjectMeta .GetGeneration ()
169
+ upgradeableFalseCondition .ObservedGeneration = currentGen
170
+ meta .SetStatusCondition (& cond .Spec .Conditions , upgradeableFalseCondition )
171
+ _ , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).Update (context .TODO (), cond , metav1.UpdateOptions {})
165
172
return err
166
173
}, pollInterval , pollDuration ).Should (Succeed ())
167
174
@@ -189,7 +196,7 @@ var _ = Describe("Operator Condition", func() {
189
196
// Get the OperatorCondition for csvB and override the upgradeable false condition
190
197
Eventually (func () error {
191
198
cond , err = crc .OperatorsV1 ().OperatorConditions (testNamespace ).Get (context .TODO (), csvB .GetName (), metav1.GetOptions {})
192
- if err != nil {
199
+ if err != nil || currentGen == cond . ObjectMeta . GetGeneration () {
193
200
return err
194
201
}
195
202
// Set Condition overrides to True
0 commit comments