@@ -46,6 +46,7 @@ import (
46
46
"github.com/operator-framework/api/pkg/operators/v1alpha1"
47
47
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
48
48
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/informers/externalversions"
49
+ v1listers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/listers/operators/v1"
49
50
operatorsv1alpha1listers "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/listers/operators/v1alpha1"
50
51
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle"
51
52
olmerrors "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/errors"
@@ -934,7 +935,42 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
934
935
return err
935
936
}
936
937
937
- failForwardEnabled , err := resolver .IsFailForwardEnabled (o .lister .OperatorsV1 ().OperatorGroupLister ().OperatorGroups (namespace ))
938
+ ogLister := o .lister .OperatorsV1 ().OperatorGroupLister ().OperatorGroups (namespace )
939
+ failForwardEnabled , err := resolver .IsFailForwardEnabled (ogLister )
940
+ if err != nil {
941
+ return err
942
+ }
943
+
944
+ // TODO: Move into a separate func (probably into the github.com/operator-framework/operator-lifecycle-manager/pkg/controller/bundle package)
945
+ // operatorGroupBundleUnpackTimeout returns bundle timeout from annotation if specified.
946
+ // This is to overrides the --bundle-unpack-timeout flag value on per-OperatorGroup basis.
947
+ // If the timeout cannot be parsed it's set to < 0 and subsequently ignored.
948
+ operatorGroupBundleUnpackTimeout := func (logger * logrus.Logger , ogLister v1listers.OperatorGroupNamespaceLister ) (time.Duration , error ) {
949
+ ignoreTimeout := - 1 * time .Minute
950
+
951
+ ogs , err := ogLister .List (labels .Everything ())
952
+ if err != nil || len (ogs ) == 0 {
953
+ return ignoreTimeout , nil
954
+ }
955
+ if len (ogs ) != 1 {
956
+ return ignoreTimeout , fmt .Errorf ("found %d operatorGroups, expected 1" , len (ogs ))
957
+ }
958
+
959
+ timeoutStr , ok := ogs [0 ].GetAnnotations ()[bundle .BundleUnpackTimeoutAnnotationKey ]
960
+ if ! ok {
961
+ return ignoreTimeout , nil
962
+ }
963
+
964
+ d , err := time .ParseDuration (timeoutStr )
965
+ if err != nil {
966
+ logger .Errorf ("failed to parse unpack timeout annotation(%s: %s): %v" , bundle .BundleUnpackTimeoutAnnotationKey , timeoutStr , err )
967
+ return ignoreTimeout , nil
968
+ }
969
+
970
+ return d , nil
971
+ }
972
+
973
+ unpackTimeout , err := operatorGroupBundleUnpackTimeout (o .logger , ogLister )
938
974
if err != nil {
939
975
return err
940
976
}
@@ -1034,7 +1070,7 @@ func (o *Operator) syncResolvingNamespace(obj interface{}) error {
1034
1070
logger .Debug ("unpacking bundles" )
1035
1071
1036
1072
var unpacked bool
1037
- unpacked , steps , bundleLookups , err = o .unpackBundles (namespace , bundleLookups )
1073
+ unpacked , steps , bundleLookups , err = o .unpackBundles (namespace , bundleLookups , unpackTimeout )
1038
1074
if err != nil {
1039
1075
return fmt .Errorf ("bundle unpacking failed with an error: %v" , err )
1040
1076
}
@@ -1456,28 +1492,14 @@ type UnpackedBundleReference struct {
1456
1492
Properties string `json:"properties"`
1457
1493
}
1458
1494
1459
- func (o * Operator ) unpackBundles (namespace string , bundleLookups []v1alpha1.BundleLookup ) (bool , []* v1alpha1.Step , []v1alpha1.BundleLookup , error ) {
1495
+ func (o * Operator ) unpackBundles (namespace string , bundleLookups []v1alpha1.BundleLookup , unpackTimeout time. Duration ) (bool , []* v1alpha1.Step , []v1alpha1.BundleLookup , error ) {
1460
1496
unpacked := true
1461
1497
1462
1498
outBundleLookups := make ([]v1alpha1.BundleLookup , len (bundleLookups ))
1463
1499
for i := range bundleLookups {
1464
1500
bundleLookups [i ].DeepCopyInto (& outBundleLookups [i ])
1465
1501
}
1466
1502
1467
- // The bundle timeout annotation if specified overrides the --bundle-unpack-timeout flag value
1468
- // If the timeout cannot be parsed it's set to < 0 and subsequently ignored
1469
- unpackTimeout := - 1 * time .Minute
1470
- // TODO: Update. This is internal stuff for testing. Maybe move to a sub?
1471
- // timeoutStr, ok := plan.GetAnnotations()[bundle.BundleUnpackTimeoutAnnotationKey]
1472
- // if ok {
1473
- // d, err := time.ParseDuration(timeoutStr)
1474
- // if err != nil {
1475
- // o.logger.Errorf("failed to parse unpack timeout annotation(%s: %s): %v", bundle.BundleUnpackTimeoutAnnotationKey, timeoutStr, err)
1476
- // } else {
1477
- // unpackTimeout = d
1478
- // }
1479
- // }
1480
-
1481
1503
installPlanSteps := []* v1alpha1.Step {}
1482
1504
var errs []error
1483
1505
for i := 0 ; i < len (outBundleLookups ); i ++ {
0 commit comments