Skip to content

Commit 35f113f

Browse files
committed
clarify maxOpenShiftVersion upgrade error message
Signed-off-by: Ankita Thomas <[email protected]>
1 parent 4a784fc commit 35f113f

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Diff for: pkg/controller/operators/openshift/helpers.go

+8-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ func (s skew) String() string {
110110
return fmt.Sprintf("%s/%s has invalid %s properties: %s", s.namespace, s.name, MaxOpenShiftVersionProperty, s.err)
111111
}
112112

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

116116
type transientError struct {
@@ -161,7 +161,8 @@ func incompatibleOperators(ctx context.Context, cli client.Client) (skews, error
161161
if max == nil || max.GTE(*next) {
162162
continue
163163
}
164-
s.maxOpenShiftVersion = max.String()
164+
165+
s.maxOpenShiftVersion = semver.Version{Major: max.Major, Minor: max.Minor}.String()
165166

166167
incompatible = append(incompatible, s)
167168
}
@@ -234,7 +235,11 @@ func maxOpenShiftVersion(csv *operatorsv1alpha1.ClusterServiceVersion) (*semver.
234235
return nil, fmt.Errorf(`Failed to parse "%s" as semver: %w`, value, err)
235236
}
236237

237-
return &version, nil
238+
truncatedVersion := semver.Version{Major: version.Major, Minor: version.Minor}
239+
if !version.EQ(truncatedVersion) {
240+
return nil, fmt.Errorf("property %s must specify only <major>.<minor> version, got invalid value %s", MaxOpenShiftVersionProperty, version)
241+
}
242+
return &truncatedVersion, nil
238243
}
239244

240245
func notCopiedSelector() (labels.Selector, error) {

Diff for: pkg/controller/operators/openshift/helpers_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -304,12 +304,12 @@ func TestIncompatibleOperators(t *testing.T) {
304304
{
305305
name: "beech",
306306
namespace: "default",
307-
maxOpenShiftVersion: "1.0.0+build",
307+
maxOpenShiftVersion: "1.0.0",
308308
},
309309
{
310-
name: "chestnut",
311-
namespace: "default",
312-
maxOpenShiftVersion: "1.1.0-pre",
310+
name: "chestnut",
311+
namespace: "default",
312+
err: fmt.Errorf("property olm.maxOpenShiftVersion must specify only <major>.<minor> version, got invalid value 1.1.0-pre"),
313313
},
314314
{
315315
name: "drupe",

0 commit comments

Comments
 (0)