diff --git a/pkg/stub/config.go b/pkg/stub/config.go index 50ad6eaaf..e91695c07 100644 --- a/pkg/stub/config.go +++ b/pkg/stub/config.go @@ -17,6 +17,20 @@ func (h *Handler) ClearStatusConfigForRemoved(cfg *v1.Config) { cfg.Status.Architectures = []string{} } +func (h *Handler) IsValidArch(cfg *v1.Config) (bool, string) { + for _, arch := range cfg.Spec.Architectures { + switch arch { + case v1.X86Architecture: + case v1.AMDArchitecture: + case v1.PPCArchitecture: + case v1.S390Architecture: + default: + return false, arch + } + } + return true, "" +} + func (h *Handler) StoreCurrentValidConfig(cfg *v1.Config) { cfg.Status.SamplesRegistry = cfg.Spec.SamplesRegistry cfg.Status.Architectures = cfg.Spec.Architectures @@ -28,16 +42,9 @@ func (h *Handler) SpecValidation(cfg *v1.Config) error { // the first thing this should do is check that all the config values // are "valid" (the architecture name is known, the distribution name is known, etc) // if that fails, we should immediately error out and set ConfigValid to false. - for _, arch := range cfg.Spec.Architectures { - switch arch { - case v1.X86Architecture: - case v1.AMDArchitecture: - case v1.PPCArchitecture: - case v1.S390Architecture: - default: - err := fmt.Errorf("architecture %s unsupported; only support %s", arch, strings.Join([]string{v1.X86Architecture, v1.AMDArchitecture, v1.PPCArchitecture, v1.S390Architecture}, ",")) - return h.processError(cfg, v1.ConfigurationValid, corev1.ConditionFalse, err, "%v") - } + if valid, badArch := h.IsValidArch(cfg); !valid { + err := fmt.Errorf("architecture %s unsupported; only support %s", badArch, strings.Join([]string{v1.X86Architecture, v1.AMDArchitecture, v1.PPCArchitecture, v1.S390Architecture}, ",")) + return h.processError(cfg, v1.ConfigurationValid, corev1.ConditionFalse, err, "%v") } // only if the values being requested are valid, should we then proceed to check diff --git a/pkg/stub/handler.go b/pkg/stub/handler.go index e894088b1..5c2b97bc2 100644 --- a/pkg/stub/handler.go +++ b/pkg/stub/handler.go @@ -122,12 +122,12 @@ type Handler struct { templateclientwrapper TemplateClientWrapper secretclientwrapper SecretClientWrapper - crdlister configv1lister.ConfigLister - streamlister imagev1lister.ImageStreamNamespaceLister - tplstore templatev1lister.TemplateNamespaceLister + crdlister configv1lister.ConfigLister + streamlister imagev1lister.ImageStreamNamespaceLister + tplstore templatev1lister.TemplateNamespaceLister opshiftsecretlister corev1lister.SecretNamespaceLister - cfgsecretlister corev1lister.SecretNamespaceLister - opersecretlister corev1lister.SecretNamespaceLister + cfgsecretlister corev1lister.SecretNamespaceLister + opersecretlister corev1lister.SecretNamespaceLister Fileimagegetter ImageStreamFromFileGetter Filetemplategetter TemplateFromFileGetter @@ -697,6 +697,16 @@ func (h *Handler) Handle(event util.Event) error { } } + validArch, _ := h.IsValidArch(cfg) + if validArch && util.IsNonX86Arch(cfg) && cfg.Spec.ManagementState == operatorsv1api.Managed { + // we did not bootstrap as removed in 4.2 for s390/ppc; we just reported complete + // clean that up to facilitate our mode of operation for those platforms + cfg.Spec.ManagementState = operatorsv1api.Removed + dbg := fmt.Sprintf("switch management state to removed for %s", cfg.Spec.Architectures[0]) + logrus.Printf("CRDUPDATE %s", dbg) + return h.crdwrapper.Update(cfg) + } + // Every time we see a change to the Config object, update the ClusterOperator status // based on the current conditions of the Config. cfg = h.refetchCfgMinimizeConflicts(cfg) @@ -772,9 +782,11 @@ func (h *Handler) Handle(event util.Event) error { // migration inevitably means we need to refresh the file cache as samples are added and // deleted between releases, so force file map building - h.buildFileMaps(cfg, true) - // passing in false means if the samples is present, we leave it alone - _, err = h.createSamples(cfg, false, registryChanged, unskippedStreams, unskippedTemplates) + if !util.IsNonX86Arch(cfg) { + h.buildFileMaps(cfg, true) + // passing in false means if the samples is present, we leave it alone + _, err = h.createSamples(cfg, false, registryChanged, unskippedStreams, unskippedTemplates) + } return err } // if config changed requiring an upsert, but a prior config action is still in progress, diff --git a/pkg/stub/imagestreams.go b/pkg/stub/imagestreams.go index 26d58b974..c7236bf09 100644 --- a/pkg/stub/imagestreams.go +++ b/pkg/stub/imagestreams.go @@ -27,6 +27,13 @@ func (h *Handler) processImageStreamWatchEvent(is *imagev1.ImageStream, deleted } else { logrus.Debugf("Imagestream %s watch event do upsert %v; no errors in prep %v, possibly update operator conditions %v", is.Name, doUpsert, err == nil, cfg != nil) } + if cfg != nil { + if util.IsNonX86Arch(cfg) { + logrus.Printf("ignoring watch event for imagestream %s ignored because we are on %s", + is.Name, cfg.Spec.Architectures[0]) + return nil + } + } if !doUpsert { if err != nil { return err