@@ -976,19 +976,31 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
976
976
// not-satisfiable error
977
977
if _ , ok := err .(solver.NotSatisfiable ); ok {
978
978
logger .WithError (err ).Debug ("resolution failed" )
979
- updateErr := o .setSubsCond (subs , v1alpha1 .SubscriptionResolutionFailed , "ConstraintsNotSatisfiable" , err .Error (), true )
979
+ _ , updateErr := o .setSubsCond (subs , v1alpha1 .SubscriptionResolutionFailed , "ConstraintsNotSatisfiable" , err .Error (), true )
980
980
if updateErr != nil {
981
981
logger .WithError (updateErr ).Debug ("failed to update subs conditions" )
982
982
}
983
983
return nil
984
984
}
985
- updateErr := o .setSubsCond (subs , v1alpha1 .SubscriptionResolutionFailed , "ErrorPreventedResolution" , err .Error (), true )
985
+ _ , updateErr := o .setSubsCond (subs , v1alpha1 .SubscriptionResolutionFailed , "ErrorPreventedResolution" , err .Error (), true )
986
986
if updateErr != nil {
987
987
logger .WithError (updateErr ).Debug ("failed to update subs conditions" )
988
988
}
989
989
return err
990
990
} else {
991
- updateErr := o .setSubsCond (subs , v1alpha1 .SubscriptionResolutionFailed , "" , "" , false )
991
+ subs , updateErr := o .setSubsCond (updatedSubs , v1alpha1 .SubscriptionResolutionFailed , "" , "" , false )
992
+ if updateErr != nil {
993
+ logger .WithError (updateErr ).Debug ("failed to update subs conditions" )
994
+ }
995
+ updatedSubs = subs
996
+
997
+ // Also clear the condition from the subscriptions there were not included in the list of updatedSubs
998
+ allSubs , err := o .listSubscriptions (namespace )
999
+ if err != nil {
1000
+ logger .WithError (err ).Debug ("couldn't list subscriptions" )
1001
+ return err
1002
+ }
1003
+ _ , updateErr = o .setSubsCond (allSubs , v1alpha1 .SubscriptionResolutionFailed , "" , "" , false )
992
1004
if updateErr != nil {
993
1005
logger .WithError (updateErr ).Debug ("failed to update subs conditions" )
994
1006
}
@@ -1269,7 +1281,7 @@ func (o *Operator) createInstallPlan(namespace string, gen int, subs []*v1alpha1
1269
1281
return reference .GetReference (res )
1270
1282
}
1271
1283
1272
- func (o * Operator ) setSubsCond (subs []* v1alpha1.Subscription , condType v1alpha1.SubscriptionConditionType , reason , message string , setTrue bool ) error {
1284
+ func (o * Operator ) setSubsCond (subs []* v1alpha1.Subscription , condType v1alpha1.SubscriptionConditionType , reason , message string , setTrue bool ) ([] * v1alpha1. Subscription , error ) {
1273
1285
var (
1274
1286
errs []error
1275
1287
mu sync.Mutex
@@ -1284,26 +1296,31 @@ func (o *Operator) setSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.
1284
1296
cond .Reason = reason
1285
1297
cond .Message = message
1286
1298
if setTrue {
1299
+ if cond .Status == corev1 .ConditionTrue {
1300
+ continue
1301
+ }
1287
1302
cond .Status = corev1 .ConditionTrue
1288
1303
} else {
1304
+ if cond .Status == corev1 .ConditionFalse {
1305
+ continue
1306
+ }
1289
1307
cond .Status = corev1 .ConditionFalse
1290
1308
}
1291
1309
sub .Status .SetCondition (cond )
1292
1310
1293
1311
wg .Add (1 )
1294
- go func (s v1alpha1.Subscription ) {
1312
+ go func (sub v1alpha1.Subscription ) {
1295
1313
defer wg .Done ()
1296
1314
1297
1315
update := func () error {
1298
1316
// Update the status of the latest revision
1299
- latest , err := o .client .OperatorsV1alpha1 ().Subscriptions (s .GetNamespace ()).Get (context .TODO (), s .GetName (), getOpts )
1317
+ latest , err := o .client .OperatorsV1alpha1 ().Subscriptions (sub .GetNamespace ()).Get (context .TODO (), sub .GetName (), getOpts )
1300
1318
if err != nil {
1301
1319
return err
1302
1320
}
1303
-
1304
- latest .Status = s .Status
1305
- _ , err = o .client .OperatorsV1alpha1 ().Subscriptions (s .Namespace ).UpdateStatus (context .TODO (), latest , updateOpts )
1306
-
1321
+ sub = * latest
1322
+ latest .Status = sub .Status
1323
+ _ , err = o .client .OperatorsV1alpha1 ().Subscriptions (sub .Namespace ).UpdateStatus (context .TODO (), latest , updateOpts )
1307
1324
return err
1308
1325
}
1309
1326
if err := retry .RetryOnConflict (retry .DefaultRetry , update ); err != nil {
@@ -1315,7 +1332,7 @@ func (o *Operator) setSubsCond(subs []*v1alpha1.Subscription, condType v1alpha1.
1315
1332
}
1316
1333
wg .Wait ()
1317
1334
1318
- return utilerrors .NewAggregate (errs )
1335
+ return subs , utilerrors .NewAggregate (errs )
1319
1336
}
1320
1337
1321
1338
type UnpackedBundleReference struct {
0 commit comments