Skip to content

Commit

Permalink
fix(olm): Provide correct format of kube version in CSV
Browse files Browse the repository at this point in the history
The format of kube version in CSV should be Major.Minor.Patch. For
example, 1.1.1 is correct.

Signed-off-by: Vu Dinh <vdinh@redhat.com>
  • Loading branch information
dinhxuanvu committed Jan 17, 2019
1 parent 319c991 commit 57ad90f
Showing 6 changed files with 87 additions and 24 deletions.
2 changes: 1 addition & 1 deletion deploy/chart/values.yaml
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ rbacApiVersion: rbac.authorization.k8s.io
namespace: operator-lifecycle-manager
catalog_namespace: operator-lifecycle-manager
operator_namespace: operators
minKubeVersion: 1.11
minKubeVersion: 1.11.0
imagestream: false
debug: false
olm:
12 changes: 12 additions & 0 deletions pkg/controller/operators/olm/operator_test.go
Original file line number Diff line number Diff line change
@@ -1849,6 +1849,7 @@ func TestTransitionCSV(t *testing.T) {
csvs: []runtime.Object{
withConditionReason(csvWithAnnotations(csv("csv1",
namespace,
"0.0.0",
"",
installStrategy("a1", nil, nil),
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1")},
@@ -1878,6 +1879,7 @@ func TestTransitionCSV(t *testing.T) {
csvs: []runtime.Object{
withConditionReason(csvWithAnnotations(csv("csv1",
namespace,
"0.0.0",
"",
installStrategy("a1", nil, nil),
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1")},
@@ -1944,6 +1946,7 @@ func TestTransitionCSV(t *testing.T) {
csvs: []runtime.Object{
withConditionReason(csvWithAnnotations(csv("csv1",
namespace,
"0.0.0",
"",
installStrategy("a1", nil, nil),
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1")},
@@ -1975,6 +1978,7 @@ func TestTransitionCSV(t *testing.T) {
csvs: []runtime.Object{
withConditionReason(csvWithAnnotations(csv("csv1",
namespace,
"0.0.0",
"",
installStrategy("a1", nil, nil),
[]*v1beta1.CustomResourceDefinition{crd("c1", "v1")},
@@ -2477,6 +2481,14 @@ func TestSyncOperatorGroups(t *testing.T) {
operatorCSVFinal.Status.LastUpdateTime = timeNow()
operatorCSVFinal.Status.LastTransitionTime = timeNow()
operatorCSVFinal.Status.RequirementStatus = []v1alpha1.RequirementStatus{
{
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv1",
Status: v1alpha1.RequirementStatusReasonPresent,
Message: "CSV minKubeVersion (0.0.0) less than server version (v0.0.0-master+$Format:%h$)",
},
{
Group: "apiextensions.k8s.io",
Version: "v1beta1",
6 changes: 3 additions & 3 deletions pkg/controller/operators/olm/requirements.go
Original file line number Diff line number Diff line change
@@ -41,7 +41,7 @@ func (a *Operator) minKubeVersionStatus(name string, minKubeVersion string) (met
return
}

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

if csvVersionInfo.Compare(*serverVersion) < 0 {
if csvVersionInfo.Compare(*serverVersion) > 0 {
status.Status = v1alpha1.RequirementStatusReasonPresentNotSatisfied
status.Message = "CSV version requirement not met"
status.Message = fmt.Sprintf("CSV version requirement not met: minKubeVersion (%s) > server version (%s)", minKubeVersion, serverVersion.String())
met = false
statuses = append(statuses, status)
return
65 changes: 57 additions & 8 deletions pkg/controller/operators/olm/requirements_test.go
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
description: "BadInstallStrategy",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
v1alpha1.NamedInstallStrategy{"deployment", json.RawMessage{}},
nil,
@@ -55,7 +55,7 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
description: "AllPermissionsMet",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
installStrategy(
"csv1-dep",
@@ -179,14 +179,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
},
},
},
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv1",
Status: v1alpha1.RequirementStatusReasonPresent,
},
},
expectedError: nil,
},
{
description: "OnePermissionNotMet",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
installStrategy(
"csv1-dep",
@@ -310,14 +317,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
},
},
},
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv1",
Status: v1alpha1.RequirementStatusReasonPresent,
},
},
expectedError: nil,
},
{
description: "AllRequirementsMet",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
installStrategy(
"csv1-dep",
@@ -428,14 +442,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
Name: "c2group",
Status: v1alpha1.RequirementStatusReasonPresent,
},
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv1",
Status: v1alpha1.RequirementStatusReasonPresent,
},
},
expectedError: nil,
},
{
description: "RequirementNotMet/NonServedCRDVersion",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
installStrategy("csv1-dep", nil, nil),
[]*v1beta1.CustomResourceDefinition{crd("c1", "v2")},
@@ -455,14 +476,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
Name: "c1group",
Status: v1alpha1.RequirementStatusReasonNotPresent,
},
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv1",
Status: v1alpha1.RequirementStatusReasonPresent,
},
},
expectedError: nil,
},
{
description: "RequirementNotMet/NotEstablishedCRDVersion",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
installStrategy("csv1-dep", nil, nil),
[]*v1beta1.CustomResourceDefinition{crd("c1", "version-not-found")},
@@ -482,14 +510,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
Name: "c1group",
Status: v1alpha1.RequirementStatusReasonNotAvailable,
},
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv1",
Status: v1alpha1.RequirementStatusReasonPresent,
},
},
expectedError: nil,
},
{
description: "RequirementNotMet/NamesConflictedCRD",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
installStrategy("csv1-dep", nil, nil),
[]*v1beta1.CustomResourceDefinition{crd("c1", "v2")},
@@ -515,14 +550,21 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
Name: "c1group",
Status: v1alpha1.RequirementStatusReasonNotAvailable,
},
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv1",
Status: v1alpha1.RequirementStatusReasonPresent,
},
},
expectedError: nil,
},
{
description: "RequirementNotMet/CRDResourceInactive",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
installStrategy("csv1-dep", nil, nil),
[]*v1beta1.CustomResourceDefinition{crd("c1", "v2")},
@@ -548,6 +590,13 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
Name: "c1group",
Status: v1alpha1.RequirementStatusReasonNotAvailable,
},
{"operators.coreos.com", "v1alpha1", "ClusterServiceVersion", "csv1"}: {
Group: "operators.coreos.com",
Version: "v1alpha1",
Kind: "ClusterServiceVersion",
Name: "csv1",
Status: v1alpha1.RequirementStatusReasonPresent,
},
},
expectedError: nil,
},
24 changes: 12 additions & 12 deletions test/e2e/csv_e2e_test.go
Original file line number Diff line number Diff line change
@@ -271,7 +271,7 @@ func TestCreateCSVWithUnmetRequirementsMinKubeVersion(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "999.999",
MinKubeVersion: "999.999.999",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -334,7 +334,7 @@ func TestCreateCSVWithUnmetRequirementsCRD(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -507,7 +507,7 @@ func TestCreateCSVWithUnmetRequirementsAPIService(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -596,7 +596,7 @@ func TestCreateCSVWithUnmetPermissionsAPIService(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -659,7 +659,7 @@ func TestCreateCSVWithUnmetRequirementsNativeAPI(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -750,7 +750,7 @@ func TestCreateCSVRequirementsMetCRD(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1006,7 +1006,7 @@ func TestCreateCSVRequirementsMetAPIService(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1162,7 +1162,7 @@ func TestCreateCSVWithOwnedAPIService(t *testing.T) {

csv := v1alpha1.ClusterServiceVersion{
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1337,7 +1337,7 @@ func TestUpdateCSVSameDeploymentName(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1520,7 +1520,7 @@ func TestUpdateCSVDifferentDeploymentName(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1708,7 +1708,7 @@ func TestUpdateCSVMultipleIntermediates(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -1902,7 +1902,7 @@ func TestUpdateCSVMultipleVersionCRD(t *testing.T) {
Name: genName("csv"),
},
Spec: v1alpha1.ClusterServiceVersionSpec{
MinKubeVersion: "0.0",
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
2 changes: 2 additions & 0 deletions test/e2e/subscription_e2e_test.go
Original file line number Diff line number Diff line change
@@ -75,6 +75,7 @@ var (
Spec: v1alpha1.ClusterServiceVersionSpec{
Replaces: "",
Version: *semver.New("0.1.0"),
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,
@@ -104,6 +105,7 @@ var (
Spec: v1alpha1.ClusterServiceVersionSpec{
Replaces: outdated,
Version: *semver.New("0.2.0"),
MinKubeVersion: "0.0.0",
InstallModes: []v1alpha1.InstallMode{
{
Type: v1alpha1.InstallModeTypeOwnNamespace,

0 comments on commit 57ad90f

Please sign in to comment.