Skip to content

Commit

Permalink
set version to start for s390/ppc until we have actual samples
Browse files Browse the repository at this point in the history
  • Loading branch information
gabemontero committed Dec 5, 2019
1 parent c8d02cb commit 4a582ed
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/operatorstatus/operatorstatus.go
Expand Up @@ -87,7 +87,7 @@ func (o *ClusterOperatorHandler) UpdateOperatorStatus(cfg *v1.Config, deletionIn
// will ignore errors in delete path, but we at least log them above
return nil
}
if len(cfg.Spec.Architectures) > 0 && cfg.Spec.Architectures[0] != v1.AMDArchitecture && cfg.Spec.Architectures[0] != v1.X86Architecture {
if util.IsNonX86Arch(cfg) {
o.setOperatorStatusWithoutInterrogatingConfig(configv1.ConditionFalse, cfg, nonX86)
// will ignore errors in non-x86 path, but we at least log them above
return nil
Expand Down
6 changes: 5 additions & 1 deletion pkg/stub/handler.go
Expand Up @@ -588,6 +588,10 @@ func (h *Handler) Handle(event util.Event) error {
// 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)
//TODO remove this setting of version once we start getting samples for z or ppc
if util.IsNonX86Arch(cfg) {
cfg.Status.Version = h.version
}
err := h.cvowrapper.UpdateOperatorStatus(cfg, false)
if err != nil {
logrus.Errorf("error updating cluster operator status: %v", err)
Expand Down Expand Up @@ -625,7 +629,7 @@ func (h *Handler) Handle(event util.Event) error {
}

//TODO adjust this check as we start getting samples for z or ppc
if len(cfg.Spec.Architectures) > 0 && cfg.Spec.Architectures[0] != v1.AMDArchitecture && cfg.Spec.Architectures[0] != v1.X86Architecture {
if util.IsNonX86Arch(cfg) {
logrus.Printf("samples are not installed on non-x86 architectures")
return nil
}
Expand Down
31 changes: 27 additions & 4 deletions pkg/stub/handler_test.go
Expand Up @@ -3,6 +3,7 @@ package stub
import (
"fmt"
"os"
"runtime"
"strings"
"time"

Expand Down Expand Up @@ -83,9 +84,17 @@ func TestWithDist(t *testing.T) {
func TestWithArchDist(t *testing.T) {
h, cfg, event := setup()
processCred(&h, cfg, t)
cfg.Spec.Architectures = []string{
v1.X86Architecture,
if len(cfg.Spec.Architectures) == 0 {
t.Errorf("arch not set on bootstrap")
}
testValue := runtime.GOARCH
if testValue == v1.AMDArchitecture {
testValue = v1.X86Architecture
}
if cfg.Spec.Architectures[0] != testValue {
t.Errorf("arch set to %s instead of %s", cfg.Spec.Architectures[0], runtime.GOARCH)
}

mimic(&h, x86OCPContentRootDir)
err := h.Handle(event)
statuses := []corev1.ConditionStatus{corev1.ConditionFalse, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse}
Expand All @@ -98,6 +107,7 @@ func TestWithArchDist(t *testing.T) {
conditions,
statuses, t)


}

func TestWithArch(t *testing.T) {
Expand All @@ -108,7 +118,7 @@ func TestWithArch(t *testing.T) {
v1.PPCArchitecture,
}
err := h.Handle(event)
validate(true, err, "", cfg, conditions, []corev1.ConditionStatus{corev1.ConditionFalse, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse}, t)
validateArchOverride(true, err, "", cfg, conditions, []corev1.ConditionStatus{corev1.ConditionFalse, corev1.ConditionTrue, corev1.ConditionTrue, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse, corev1.ConditionFalse}, t, v1.PPCArchitecture)
}

func TestWithBadArch(t *testing.T) {
Expand Down Expand Up @@ -1280,7 +1290,7 @@ func mimic(h *Handler, topdir string) {

}

func validate(succeed bool, err error, errstr string, cfg *v1.Config, statuses []v1.ConfigConditionType, conditions []corev1.ConditionStatus, t *testing.T) {
func validateArchOverride(succeed bool, err error, errstr string, cfg *v1.Config, statuses []v1.ConfigConditionType, conditions []corev1.ConditionStatus, t *testing.T, arch string) {
if succeed && err != nil {
t.Fatal(err)
}
Expand All @@ -1307,9 +1317,22 @@ func validate(succeed bool, err error, errstr string, cfg *v1.Config, statuses [
t.Fatalf("unexpected for succeed %v have status condition %#v expected condition %#v and status %#v", succeed, cfg.Status.Conditions[i], c, conditions[i])
}
}
testValue := arch
if testValue == v1.AMDArchitecture {
testValue = v1.X86Architecture
}
if cfg.Spec.Architectures[0] != testValue {
t.Fatalf("arch set to %s instead of %s", cfg.Spec.Architectures[0], runtime.GOARCH)
}
}

}

func validate(succeed bool, err error, errstr string, cfg *v1.Config, statuses []v1.ConfigConditionType, conditions []corev1.ConditionStatus, t *testing.T) {
validateArchOverride(succeed, err, errstr, cfg, statuses, conditions, t, runtime.GOARCH)
}


func NewTestHandler() Handler {
h := Handler{}

Expand Down
8 changes: 8 additions & 0 deletions pkg/util/util.go
Expand Up @@ -325,6 +325,14 @@ func ClusterNeedsCreds(s *samplev1.Config, ) bool {
return ConditionFalse(s, samplev1.ImportCredentialsExist)
}

// IsNonX86Arch let's us know if this is something other than x86_64/amd like s390x or ppc
func IsNonX86Arch(cfg *samplev1.Config) bool {
if len(cfg.Spec.Architectures) > 0 && cfg.Spec.Architectures[0] != samplev1.AMDArchitecture && cfg.Spec.Architectures[0] != samplev1.X86Architecture {
return true
}
return false
}

type Event struct {
Object runtime.Object
Deleted bool
Expand Down

0 comments on commit 4a582ed

Please sign in to comment.