Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions pkg/stub/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
28 changes: 20 additions & 8 deletions pkg/stub/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions pkg/stub/imagestreams.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down