Skip to content

[release-4.8] Bug 1994038: clarify maxOpenShiftVersion upgrade error message #173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package openshift

import (
"fmt"

semver "github.com/blang/semver/v4"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -213,6 +212,7 @@ var _ = Describe("ClusterOperator controller", func() {
}).Should(Succeed())
}()

parsedVersion := semver.MustParse(clusterVersion)
Eventually(func() ([]configv1.ClusterOperatorStatusCondition, error) {
err := k8sClient.Get(ctx, clusterOperatorName, co)
return co.Status.Conditions, err
Expand All @@ -224,7 +224,7 @@ var _ = Describe("ClusterOperator controller", func() {
{
namespace: ns.GetName(),
name: incompatible.GetName(),
maxOpenShiftVersion: clusterVersion,
maxOpenShiftVersion: fmt.Sprintf("%d.%d", parsedVersion.Major, parsedVersion.Minor),
},
}.String(),
LastTransitionTime: fixedNow(),
Expand Down Expand Up @@ -270,7 +270,7 @@ var _ = Describe("ClusterOperator controller", func() {
{
namespace: ns.GetName(),
name: incompatible.GetName(),
maxOpenShiftVersion: short + ".0",
maxOpenShiftVersion: short,
},
}.String(),
LastTransitionTime: fixedNow(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (s skew) String() string {
return fmt.Sprintf("%s/%s has invalid %s properties: %s", s.namespace, s.name, MaxOpenShiftVersionProperty, s.err)
}

return fmt.Sprintf("%s/%s is incompatible with OpenShift versions greater than %s", s.namespace, s.name, s.maxOpenShiftVersion)
return fmt.Sprintf("%s/%s is incompatible with OpenShift minor versions greater than %s", s.namespace, s.name, s.maxOpenShiftVersion)
}

type transientError struct {
Expand Down Expand Up @@ -165,7 +165,8 @@ func incompatibleOperators(ctx context.Context, cli client.Client) (skews, error
if max == nil || max.GTE(next) {
continue
}
s.maxOpenShiftVersion = max.String()

s.maxOpenShiftVersion = fmt.Sprintf("%d.%d", max.Major, max.Minor)

incompatible = append(incompatible, s)
}
Expand Down Expand Up @@ -252,7 +253,11 @@ func maxOpenShiftVersion(csv *operatorsv1alpha1.ClusterServiceVersion) (*semver.
return nil, fmt.Errorf(`Failed to parse "%s" as semver: %w`, value, err)
}

return &version, nil
truncatedVersion := semver.Version{Major: version.Major, Minor: version.Minor}
if !version.EQ(truncatedVersion) {
return nil, fmt.Errorf("property %s must specify only <major>.<minor> version, got invalid value %s", MaxOpenShiftVersionProperty, version)
}
return &truncatedVersion, nil
}

func notCopiedSelector() (labels.Selector, error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,6 @@ func TestIncompatibleOperators(t *testing.T) {
{
name: "chestnut",
namespace: "default",
maxOpenShiftVersion: "1.2.0-pre+build",
},
{
name: "drupe",
namespace: "default",
maxOpenShiftVersion: "2.0.0",
},
},
Expand Down Expand Up @@ -308,27 +303,27 @@ func TestIncompatibleOperators(t *testing.T) {
{
name: "almond",
namespace: "default",
maxOpenShiftVersion: "1.0.0",
maxOpenShiftVersion: "1.0",
},
{
name: "beech",
namespace: "default",
maxOpenShiftVersion: "1.0.0+build",
maxOpenShiftVersion: "1.0",
},
{
name: "chestnut",
namespace: "default",
maxOpenShiftVersion: "1.1.0-pre",
name: "chestnut",
namespace: "default",
err: fmt.Errorf("property olm.maxOpenShiftVersion must specify only <major>.<minor> version, got invalid value 1.1.0-pre"),
},
{
name: "drupe",
namespace: "default",
maxOpenShiftVersion: "1.1.0-pre+build",
name: "drupe",
namespace: "default",
err: fmt.Errorf("property olm.maxOpenShiftVersion must specify only <major>.<minor> version, got invalid value 1.1.0-pre+build"),
},
{
name: "european-hazelnut",
namespace: "default",
maxOpenShiftVersion: "0.1.0",
maxOpenShiftVersion: "0.1",
},
},
},
Expand Down Expand Up @@ -368,12 +363,12 @@ func TestIncompatibleOperators(t *testing.T) {
{
name: "beech",
namespace: "default",
maxOpenShiftVersion: "1.0.0",
maxOpenShiftVersion: "1.0",
},
{
name: "chestnut",
namespace: "default",
maxOpenShiftVersion: "1.0.0",
maxOpenShiftVersion: "1.0",
},
},
},
Expand Down Expand Up @@ -413,7 +408,7 @@ func TestIncompatibleOperators(t *testing.T) {
{
name: "beech",
namespace: "default",
maxOpenShiftVersion: "1.0.0",
maxOpenShiftVersion: "1.0",
},
{
name: "chestnut",
Expand Down Expand Up @@ -468,11 +463,6 @@ func TestIncompatibleOperators(t *testing.T) {
},
},
in: skews{
{
name: "almond",
namespace: "default",
maxOpenShiftVersion: "1.1.2",
},
{
name: "beech",
namespace: "default",
Expand Down Expand Up @@ -502,21 +492,10 @@ func TestIncompatibleOperators(t *testing.T) {
namespace: "default",
maxOpenShiftVersion: "1.1.0",
},
{
name: "beech",
namespace: "default",
maxOpenShiftVersion: "1.1.0-pre",
},
},
expect: expect{
err: false,
incompatible: skews{
{
name: "beech",
namespace: "default",
maxOpenShiftVersion: "1.1.0-pre",
},
},
err: false,
incompatible: nil,
},
},
} {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.