Skip to content

Commit 5ab896d

Browse files
committed
fix(olm): Provide correct format of kube version in CSV
The format of kube version in CSV should be Major.Minor.Patch. For example, 1.1.1 is correct. Signed-off-by: Vu Dinh <[email protected]>
1 parent 0182a24 commit 5ab896d

File tree

6 files changed

+87
-24
lines changed

6 files changed

+87
-24
lines changed

deploy/chart/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ rbacApiVersion: rbac.authorization.k8s.io
22
namespace: operator-lifecycle-manager
33
catalog_namespace: operator-lifecycle-manager
44
operator_namespace: operators
5-
minKubeVersion: 1.11
5+
minKubeVersion: 1.11.0
66
imagestream: false
77
debug: false
88
olm:

pkg/controller/operators/olm/operator_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1849,6 +1849,7 @@ func TestTransitionCSV(t *testing.T) {
18491849
csvs: []runtime.Object{
18501850
withConditionReason(csvWithAnnotations(csv("csv1",
18511851
namespace,
1852+
"0.0.0",
18521853
"",
18531854
installStrategy("a1", nil, nil),
18541855
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1")},
@@ -1878,6 +1879,7 @@ func TestTransitionCSV(t *testing.T) {
18781879
csvs: []runtime.Object{
18791880
withConditionReason(csvWithAnnotations(csv("csv1",
18801881
namespace,
1882+
"0.0.0",
18811883
"",
18821884
installStrategy("a1", nil, nil),
18831885
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1")},
@@ -1944,6 +1946,7 @@ func TestTransitionCSV(t *testing.T) {
19441946
csvs: []runtime.Object{
19451947
withConditionReason(csvWithAnnotations(csv("csv1",
19461948
namespace,
1949+
"0.0.0",
19471950
"",
19481951
installStrategy("a1", nil, nil),
19491952
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1")},
@@ -1975,6 +1978,7 @@ func TestTransitionCSV(t *testing.T) {
19751978
csvs: []runtime.Object{
19761979
withConditionReason(csvWithAnnotations(csv("csv1",
19771980
namespace,
1981+
"0.0.0",
19781982
"",
19791983
installStrategy("a1", nil, nil),
19801984
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1")},
@@ -2477,6 +2481,14 @@ func TestSyncOperatorGroups(t *testing.T) {
24772481
operatorCSVFinal.Status.LastUpdateTime = timeNow()
24782482
operatorCSVFinal.Status.LastTransitionTime = timeNow()
24792483
operatorCSVFinal.Status.RequirementStatus = []v1alpha1.RequirementStatus{
2484+
{
2485+
Group: "operators.coreos.com",
2486+
Version: "v1alpha1",
2487+
Kind: "ClusterServiceVersion",
2488+
Name: "csv1",
2489+
Status: v1alpha1.RequirementStatusReasonPresent,
2490+
Message: "CSV minKubeVersion (0.0.0) less than server version (v0.0.0-master+$Format:%h$)",
2491+
},
24802492
{
24812493
Group: "apiextensions.k8s.io",
24822494
Version: "v1beta1",

pkg/controller/operators/olm/requirements.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (a *Operator) minKubeVersionStatus(name string, minKubeVersion string) (met
4141
return
4242
}
4343

44-
serverVersion, err := semver.NewVersion(strings.TrimPrefix(serverVersionInfo.String(), "v"))
44+
serverVersion, err := semver.NewVersion(strings.Split(strings.TrimPrefix(serverVersionInfo.String(), "v"), "-")[0])
4545
if err != nil {
4646
status.Status = v1alpha1.RequirementStatusReasonPresentNotSatisfied
4747
status.Message = "Server version parsing error"
@@ -59,9 +59,9 @@ func (a *Operator) minKubeVersionStatus(name string, minKubeVersion string) (met
5959
return
6060
}
6161

62-
if csvVersionInfo.Compare(*serverVersion) < 0 {
62+
if csvVersionInfo.Compare(*serverVersion) > 0 {
6363
status.Status = v1alpha1.RequirementStatusReasonPresentNotSatisfied
64-
status.Message = "CSV version requirement not met"
64+
status.Message = fmt.Sprintf("CSV version requirement not met: minKubeVersion (%s) > server version (%s)", minKubeVersion, serverVersion.String())
6565
met = false
6666
statuses = append(statuses, status)
6767
return

pkg/controller/operators/olm/requirements_test.go

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
3838
description: "BadInstallStrategy",
3939
csv: csv("csv1",
4040
namespace,
41-
"0.0",
41+
"0.0.0",
4242
"",
4343
v1alpha1.NamedInstallStrategy{"deployment", json.RawMessage{}},
4444
nil,
@@ -55,7 +55,7 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
5555
description: "AllPermissionsMet",
5656
csv: csv("csv1",
5757
namespace,
58-
"0.0",
58+
"0.0.0",
5959
"",
6060
installStrategy(
6161
"csv1-dep",
@@ -179,14 +179,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
179179
},
180180
},
181181
},
182+
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
183+
Group: "operators.coreos.com",
184+
Version: "v1alpha1",
185+
Kind: "ClusterServiceVersion",
186+
Name: "csv1",
187+
Status: v1alpha1.RequirementStatusReasonPresent,
188+
},
182189
},
183190
expectedError: nil,
184191
},
185192
{
186193
description: "OnePermissionNotMet",
187194
csv: csv("csv1",
188195
namespace,
189-
"0.0",
196+
"0.0.0",
190197
"",
191198
installStrategy(
192199
"csv1-dep",
@@ -310,14 +317,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
310317
},
311318
},
312319
},
320+
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
321+
Group: "operators.coreos.com",
322+
Version: "v1alpha1",
323+
Kind: "ClusterServiceVersion",
324+
Name: "csv1",
325+
Status: v1alpha1.RequirementStatusReasonPresent,
326+
},
313327
},
314328
expectedError: nil,
315329
},
316330
{
317331
description: "AllRequirementsMet",
318332
csv: csv("csv1",
319333
namespace,
320-
"0.0",
334+
"0.0.0",
321335
"",
322336
installStrategy(
323337
"csv1-dep",
@@ -428,14 +442,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
428442
Name: "c2group",
429443
Status: v1alpha1.RequirementStatusReasonPresent,
430444
},
445+
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
446+
Group: "operators.coreos.com",
447+
Version: "v1alpha1",
448+
Kind: "ClusterServiceVersion",
449+
Name: "csv1",
450+
Status: v1alpha1.RequirementStatusReasonPresent,
451+
},
431452
},
432453
expectedError: nil,
433454
},
434455
{
435456
description: "RequirementNotMet/NonServedCRDVersion",
436457
csv: csv("csv1",
437458
namespace,
438-
"0.0",
459+
"0.0.0",
439460
"",
440461
installStrategy("csv1-dep", nil, nil),
441462
[]*v1beta1.CustomResourceDefinition{crd("c1", "v2")},
@@ -455,14 +476,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
455476
Name: "c1group",
456477
Status: v1alpha1.RequirementStatusReasonNotPresent,
457478
},
479+
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
480+
Group: "operators.coreos.com",
481+
Version: "v1alpha1",
482+
Kind: "ClusterServiceVersion",
483+
Name: "csv1",
484+
Status: v1alpha1.RequirementStatusReasonPresent,
485+
},
458486
},
459487
expectedError: nil,
460488
},
461489
{
462490
description: "RequirementNotMet/NotEstablishedCRDVersion",
463491
csv: csv("csv1",
464492
namespace,
465-
"0.0",
493+
"0.0.0",
466494
"",
467495
installStrategy("csv1-dep", nil, nil),
468496
[]*v1beta1.CustomResourceDefinition{crd("c1", "version-not-found")},
@@ -482,14 +510,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
482510
Name: "c1group",
483511
Status: v1alpha1.RequirementStatusReasonNotAvailable,
484512
},
513+
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
514+
Group: "operators.coreos.com",
515+
Version: "v1alpha1",
516+
Kind: "ClusterServiceVersion",
517+
Name: "csv1",
518+
Status: v1alpha1.RequirementStatusReasonPresent,
519+
},
485520
},
486521
expectedError: nil,
487522
},
488523
{
489524
description: "RequirementNotMet/NamesConflictedCRD",
490525
csv: csv("csv1",
491526
namespace,
492-
"0.0",
527+
"0.0.0",
493528
"",
494529
installStrategy("csv1-dep", nil, nil),
495530
[]*v1beta1.CustomResourceDefinition{crd("c1", "v2")},
@@ -515,14 +550,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
515550
Name: "c1group",
516551
Status: v1alpha1.RequirementStatusReasonNotAvailable,
517552
},
553+
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
554+
Group: "operators.coreos.com",
555+
Version: "v1alpha1",
556+
Kind: "ClusterServiceVersion",
557+
Name: "csv1",
558+
Status: v1alpha1.RequirementStatusReasonPresent,
559+
},
518560
},
519561
expectedError: nil,
520562
},
521563
{
522564
description: "RequirementNotMet/CRDResourceInactive",
523565
csv: csv("csv1",
524566
namespace,
525-
"0.0",
567+
"0.0.0",
526568
"",
527569
installStrategy("csv1-dep", nil, nil),
528570
[]*v1beta1.CustomResourceDefinition{crd("c1", "v2")},
@@ -548,6 +590,13 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
548590
Name: "c1group",
549591
Status: v1alpha1.RequirementStatusReasonNotAvailable,
550592
},
593+
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
594+
Group: "operators.coreos.com",
595+
Version: "v1alpha1",
596+
Kind: "ClusterServiceVersion",
597+
Name: "csv1",
598+
Status: v1alpha1.RequirementStatusReasonPresent,
599+
},
551600
},
552601
expectedError: nil,
553602
},

test/e2e/csv_e2e_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func TestCreateCSVWithUnmetRequirementsMinKubeVersion(t *testing.T) {
271271
Name: genName("csv"),
272272
},
273273
Spec: v1alpha1.ClusterServiceVersionSpec{
274-
MinKubeVersion: "999.999",
274+
MinKubeVersion: "999.999.999",
275275
InstallModes: []v1alpha1.InstallMode{
276276
{
277277
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -334,7 +334,7 @@ func TestCreateCSVWithUnmetRequirementsCRD(t *testing.T) {
334334
Name: genName("csv"),
335335
},
336336
Spec: v1alpha1.ClusterServiceVersionSpec{
337-
MinKubeVersion: "0.0",
337+
MinKubeVersion: "0.0.0",
338338
InstallModes: []v1alpha1.InstallMode{
339339
{
340340
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -507,7 +507,7 @@ func TestCreateCSVWithUnmetRequirementsAPIService(t *testing.T) {
507507
Name: genName("csv"),
508508
},
509509
Spec: v1alpha1.ClusterServiceVersionSpec{
510-
MinKubeVersion: "0.0",
510+
MinKubeVersion: "0.0.0",
511511
InstallModes: []v1alpha1.InstallMode{
512512
{
513513
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -596,7 +596,7 @@ func TestCreateCSVWithUnmetPermissionsAPIService(t *testing.T) {
596596
Name: genName("csv"),
597597
},
598598
Spec: v1alpha1.ClusterServiceVersionSpec{
599-
MinKubeVersion: "0.0",
599+
MinKubeVersion: "0.0.0",
600600
InstallModes: []v1alpha1.InstallMode{
601601
{
602602
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -659,7 +659,7 @@ func TestCreateCSVWithUnmetRequirementsNativeAPI(t *testing.T) {
659659
Name: genName("csv"),
660660
},
661661
Spec: v1alpha1.ClusterServiceVersionSpec{
662-
MinKubeVersion: "0.0",
662+
MinKubeVersion: "0.0.0",
663663
InstallModes: []v1alpha1.InstallMode{
664664
{
665665
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -750,7 +750,7 @@ func TestCreateCSVRequirementsMetCRD(t *testing.T) {
750750
Name: genName("csv"),
751751
},
752752
Spec: v1alpha1.ClusterServiceVersionSpec{
753-
MinKubeVersion: "0.0",
753+
MinKubeVersion: "0.0.0",
754754
InstallModes: []v1alpha1.InstallMode{
755755
{
756756
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1006,7 +1006,7 @@ func TestCreateCSVRequirementsMetAPIService(t *testing.T) {
10061006
Name: genName("csv"),
10071007
},
10081008
Spec: v1alpha1.ClusterServiceVersionSpec{
1009-
MinKubeVersion: "0.0",
1009+
MinKubeVersion: "0.0.0",
10101010
InstallModes: []v1alpha1.InstallMode{
10111011
{
10121012
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1162,7 +1162,7 @@ func TestCreateCSVWithOwnedAPIService(t *testing.T) {
11621162

11631163
csv := v1alpha1.ClusterServiceVersion{
11641164
Spec: v1alpha1.ClusterServiceVersionSpec{
1165-
MinKubeVersion: "0.0",
1165+
MinKubeVersion: "0.0.0",
11661166
InstallModes: []v1alpha1.InstallMode{
11671167
{
11681168
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1337,7 +1337,7 @@ func TestUpdateCSVSameDeploymentName(t *testing.T) {
13371337
Name: genName("csv"),
13381338
},
13391339
Spec: v1alpha1.ClusterServiceVersionSpec{
1340-
MinKubeVersion: "0.0",
1340+
MinKubeVersion: "0.0.0",
13411341
InstallModes: []v1alpha1.InstallMode{
13421342
{
13431343
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1520,7 +1520,7 @@ func TestUpdateCSVDifferentDeploymentName(t *testing.T) {
15201520
Name: genName("csv"),
15211521
},
15221522
Spec: v1alpha1.ClusterServiceVersionSpec{
1523-
MinKubeVersion: "0.0",
1523+
MinKubeVersion: "0.0.0",
15241524
InstallModes: []v1alpha1.InstallMode{
15251525
{
15261526
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1708,7 +1708,7 @@ func TestUpdateCSVMultipleIntermediates(t *testing.T) {
17081708
Name: genName("csv"),
17091709
},
17101710
Spec: v1alpha1.ClusterServiceVersionSpec{
1711-
MinKubeVersion: "0.0",
1711+
MinKubeVersion: "0.0.0",
17121712
InstallModes: []v1alpha1.InstallMode{
17131713
{
17141714
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1902,7 +1902,7 @@ func TestUpdateCSVMultipleVersionCRD(t *testing.T) {
19021902
Name: genName("csv"),
19031903
},
19041904
Spec: v1alpha1.ClusterServiceVersionSpec{
1905-
MinKubeVersion: "0.0",
1905+
MinKubeVersion: "0.0.0",
19061906
InstallModes: []v1alpha1.InstallMode{
19071907
{
19081908
Type: v1alpha1.InstallModeTypeOwnNamespace,

test/e2e/subscription_e2e_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ var (
7575
Spec: v1alpha1.ClusterServiceVersionSpec{
7676
Replaces: "",
7777
Version: *semver.New("0.1.0"),
78+
MinKubeVersion: "0.0.0",
7879
InstallModes: []v1alpha1.InstallMode{
7980
{
8081
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -104,6 +105,7 @@ var (
104105
Spec: v1alpha1.ClusterServiceVersionSpec{
105106
Replaces: outdated,
106107
Version: *semver.New("0.2.0"),
108+
MinKubeVersion: "0.0.0",
107109
InstallModes: []v1alpha1.InstallMode{
108110
{
109111
Type: v1alpha1.InstallModeTypeOwnNamespace,

0 commit comments

Comments
 (0)