@@ -1278,6 +1278,7 @@ func (a *Operator) operatorGroupForCSV(csv *v1alpha1.ClusterServiceVersion, logg
1278
1278
}
1279
1279
1280
1280
// transitionCSVState moves the CSV status state machine along based on the current value and the current cluster state.
1281
+ // SyncError should be returned when an additional reconcile of the CSV might fix the issue.
1281
1282
func (a * Operator ) transitionCSVState (in v1alpha1.ClusterServiceVersion ) (out * v1alpha1.ClusterServiceVersion , syncError error ) {
1282
1283
logger := a .logger .WithFields (logrus.Fields {
1283
1284
"id" : queueinformer .NewLoopID (),
@@ -1297,8 +1298,8 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1297
1298
1298
1299
operatorSurface , err := resolver .NewOperatorFromV1Alpha1CSV (out )
1299
1300
if err != nil {
1300
- // TODO: Add failure status to CSV
1301
- syncError = err
1301
+ // If the resolver is unable to retrieve the operator info from the CSV the CSV requires changes, a syncError should not be returned.
1302
+ logger . WithError ( err ). Warn ( "Unable to retrieve operator information from CSV" )
1302
1303
return
1303
1304
}
1304
1305
@@ -1327,9 +1328,8 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1327
1328
1328
1329
modeSet , err := v1alpha1 .NewInstallModeSet (out .Spec .InstallModes )
1329
1330
if err != nil {
1330
- syncError = err
1331
1331
logger .WithError (err ).Warn ("csv has invalid installmodes" )
1332
- out .SetPhaseWithEventIfChanged (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidInstallModes , syncError .Error (), now , a .recorder )
1332
+ out .SetPhaseWithEventIfChanged (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidInstallModes , err .Error (), now , a .recorder )
1333
1333
return
1334
1334
}
1335
1335
@@ -1454,15 +1454,18 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1454
1454
// Create a map to track unique names
1455
1455
webhookNames := map [string ]struct {}{}
1456
1456
// Check if Webhooks have valid rules and unique names
1457
+ // TODO: Move this to validating library
1457
1458
for _ , desc := range out .Spec .WebhookDefinitions {
1458
1459
_ , present := webhookNames [desc .GenerateName ]
1459
1460
if present {
1461
+ logger .WithError (fmt .Errorf ("Repeated WebhookDescription name %s" , desc .GenerateName )).Warn ("CSV is invalid" )
1460
1462
out .SetPhaseWithEventIfChanged (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidWebhookDescription , "CSV contains repeated WebhookDescription name" , now , a .recorder )
1461
1463
return
1462
1464
}
1463
1465
webhookNames [desc .GenerateName ] = struct {}{}
1464
- if syncError = install .ValidWebhookRules (desc .Rules ); syncError != nil {
1465
- out .SetPhaseWithEventIfChanged (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidWebhookDescription , syncError .Error (), now , a .recorder )
1466
+ if err = install .ValidWebhookRules (desc .Rules ); err != nil {
1467
+ logger .WithError (err ).Warnf ("WebhookDescription %s includes invalid rules" , desc .GenerateName )
1468
+ out .SetPhaseWithEventIfChanged (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidWebhookDescription , err .Error (), now , a .recorder )
1466
1469
return
1467
1470
}
1468
1471
}
@@ -1486,6 +1489,7 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1486
1489
// Check if we're not ready to install part of the replacement chain yet
1487
1490
if prev := a .isReplacing (out ); prev != nil {
1488
1491
if prev .Status .Phase != v1alpha1 .CSVPhaseReplacing {
1492
+ logger .WithError (fmt .Errorf ("CSV being replaced is in phase %s instead of %s" , prev .Status .Phase , v1alpha1 .CSVPhaseReplacing )).Debug ("Unable to replace previous CSV" )
1489
1493
return
1490
1494
}
1491
1495
}
@@ -1532,6 +1536,7 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1532
1536
1533
1537
strategy , err := a .updateDeploymentSpecsWithApiServiceData (out , strategy )
1534
1538
if err != nil {
1539
+ logger .WithError (err ).Debug ("Unable to calculate expected deployment" )
1535
1540
out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsReinstall , "calculated deployment install is bad" , now , a .recorder )
1536
1541
return
1537
1542
}
@@ -1559,13 +1564,15 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1559
1564
1560
1565
// Check if any generated resources are missing
1561
1566
if err := a .checkAPIServiceResources (out , certs .PEMSHA256 ); err != nil {
1567
+ logger .WithError (err ).Debug ("API Resources are unavailable" )
1562
1568
out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonAPIServiceResourceIssue , err .Error (), now , a .recorder )
1563
1569
return
1564
1570
}
1565
1571
1566
1572
// Check if it's time to refresh owned APIService certs
1567
1573
if install .ShouldRotateCerts (out ) {
1568
- out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsCertRotation , "owned APIServices need cert refresh" , now , a .recorder )
1574
+ logger .Debug ("CSV owns resources that require a cert refresh" )
1575
+ out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsCertRotation , "CSV owns resources that require a cert refresh" , now , a .recorder )
1569
1576
return
1570
1577
}
1571
1578
@@ -1576,6 +1583,7 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1576
1583
out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidStrategy , fmt .Sprintf ("install strategy invalid: %s" , err .Error ()), now , a .recorder )
1577
1584
return
1578
1585
} else if ! met {
1586
+ logger .Debug ("CSV Requirements are no longer met" )
1579
1587
out .SetRequirementStatus (statuses )
1580
1588
out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonRequirementsNotMet , fmt .Sprintf ("requirements no longer met" ), now , a .recorder )
1581
1589
return
@@ -1584,6 +1592,7 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1584
1592
// Check install status
1585
1593
strategy , err = a .updateDeploymentSpecsWithApiServiceData (out , strategy )
1586
1594
if err != nil {
1595
+ logger .WithError (err ).Debug ("Unable to calculate expected deployment" )
1587
1596
out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsReinstall , "calculated deployment install is bad" , now , a .recorder )
1588
1597
return
1589
1598
}
@@ -1639,6 +1648,7 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1639
1648
out .SetPhaseWithEvent (v1alpha1 .CSVPhaseFailed , v1alpha1 .CSVReasonInvalidStrategy , fmt .Sprintf ("install strategy invalid: %s" , err .Error ()), now , a .recorder )
1640
1649
return
1641
1650
} else if ! met {
1651
+ logger .Debug ("CSV Requirements are not met" )
1642
1652
out .SetRequirementStatus (statuses )
1643
1653
out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonRequirementsNotMet , fmt .Sprintf ("requirements not met" ), now , a .recorder )
1644
1654
return
@@ -1647,6 +1657,7 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1647
1657
// Check if any generated resources are missing and that OLM can action on them
1648
1658
if err := a .checkAPIServiceResources (out , certs .PEMSHA256 ); err != nil {
1649
1659
if a .apiServiceResourceErrorActionable (err ) {
1660
+ logger .WithError (err ).Debug ("API Resources are unavailable" )
1650
1661
// Check if API services are adoptable. If not, keep CSV as Failed state
1651
1662
out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonAPIServiceResourcesNeedReinstall , err .Error (), now , a .recorder )
1652
1663
}
@@ -1655,13 +1666,15 @@ func (a *Operator) transitionCSVState(in v1alpha1.ClusterServiceVersion) (out *v
1655
1666
1656
1667
// Check if it's time to refresh owned APIService certs
1657
1668
if install .ShouldRotateCerts (out ) {
1669
+ logger .Debug ("CSV owns resources that require a cert refresh" )
1658
1670
out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsCertRotation , "owned APIServices need cert refresh" , now , a .recorder )
1659
1671
return
1660
1672
}
1661
1673
1662
1674
// Check install status
1663
1675
strategy , err = a .updateDeploymentSpecsWithApiServiceData (out , strategy )
1664
1676
if err != nil {
1677
+ logger .WithError (err ).Debug ("Unable to calculate expected deployment" )
1665
1678
out .SetPhaseWithEvent (v1alpha1 .CSVPhasePending , v1alpha1 .CSVReasonNeedsReinstall , "calculated deployment install is bad" , now , a .recorder )
1666
1679
return
1667
1680
}
0 commit comments