From afa0f12a1d0855dae2b528e7986cb3300ed5e4c1 Mon Sep 17 00:00:00 2001 From: Dhriti Shikhar Date: Mon, 30 Aug 2021 17:55:36 +0530 Subject: [PATCH] Adds ParsingError field --- pkg/controller/operators/catalog/operator.go | 3 ++- .../pkg/operators/v1alpha1/catalogsource_types.go | 13 +++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pkg/controller/operators/catalog/operator.go b/pkg/controller/operators/catalog/operator.go index 5dc068ba35d..da8806dafb5 100644 --- a/pkg/controller/operators/catalog/operator.go +++ b/pkg/controller/operators/catalog/operator.go @@ -724,7 +724,8 @@ func (o *Operator) syncRegistryServer(logger *logrus.Entry, in *v1alpha1.Catalog // requeue the catalog sync based on the polling interval, for accurate syncs of catalogs with polling enabled if out.Spec.UpdateStrategy != nil { if out.Spec.UpdateStrategy.RegistryPoll != nil { - if out.Spec.UpdateStrategy.RegistryPoll.Interval.Duration == queueinformer.DefaultResyncPeriod { + if out.Spec.UpdateStrategy.RegistryPoll.Interval.Duration == queueinformer.DefaultResyncPeriod && out.Spec.UpdateStrategy.RegistryPoll.ParsingError != nil { + out.SetError(v1alpha1.CatalogSourceIntervalInvalidError, out.Spec.UpdateStrategy.RegistryPoll.ParsingError) if _, err := o.client.OperatorsV1alpha1().CatalogSources(out.GetNamespace()).Update(context.TODO(), out, metav1.UpdateOptions{}); err != nil { logger.Errorf("error while setting catalogsource interval - %v", err) return diff --git a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha1/catalogsource_types.go b/vendor/github.com/operator-framework/api/pkg/operators/v1alpha1/catalogsource_types.go index 8ea4a4f4315..f18838b8538 100644 --- a/vendor/github.com/operator-framework/api/pkg/operators/v1alpha1/catalogsource_types.go +++ b/vendor/github.com/operator-framework/api/pkg/operators/v1alpha1/catalogsource_types.go @@ -11,8 +11,9 @@ import ( ) const ( - CatalogSourceCRDAPIVersion = GroupName + "/" + GroupVersion - CatalogSourceKind = "CatalogSource" + CatalogSourceCRDAPIVersion = GroupName + "/" + GroupVersion + CatalogSourceKind = "CatalogSource" + DefaultRegistryPollDuration = "15m" ) // SourceType indicates the type of backing store for a CatalogSource @@ -37,6 +38,8 @@ const ( CatalogSourceConfigMapError ConditionReason = "ConfigMapError" // CatalogSourceRegistryServerError denotes when there is an issue querying the specified registry server. CatalogSourceRegistryServerError ConditionReason = "RegistryServerError" + // CatalogSourceIntervalInvalidError denotes when the registry interval is invalid. + CatalogSourceIntervalInvalidError ConditionReason = "IntervalInvalidError" ) type CatalogSourceSpec struct { @@ -97,7 +100,8 @@ type RegistryPoll struct { // Interval is used to determine the time interval between checks of the latest catalog source version. // The catalog operator polls to see if a new version of the catalog source is available. // If available, the latest image is pulled and gRPC traffic is directed to the latest catalog source. - Interval *metav1.Duration `json:"interval,omitempty"` + Interval *metav1.Duration `json:"interval,omitempty"` + ParsingError error } type RegistryServiceStatus struct { @@ -243,7 +247,8 @@ func (u *UpdateStrategy) UnmarshalJSON(data []byte) (err error) { registryPoll := &RegistryPoll{} duration, err := time.ParseDuration(updateStrategyMap["registryPoll"]["interval"]) if err != nil { - defaultTime, err := time.ParseDuration("15m") + registryPoll.ParsingError = fmt.Errorf("error parsing spec.updateStrategy.registryPoll.interval. Setting the default value of %v. Error:%v", DefaultRegistryPollDuration, err) + defaultTime, err := time.ParseDuration(DefaultRegistryPollDuration) if err != nil { return err }