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 16, 2019
1 parent 7615a3b commit 3332712
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 24 deletions.
2 changes: 1 addition & 1 deletion deploy/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions pkg/controller/operators/olm/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,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",
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/operators/olm/requirements.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
65 changes: 57 additions & 8 deletions pkg/controller/operators/olm/requirements_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -55,7 +55,7 @@ func TestRequirementAndPermissionStatus(t *testing.T) {
description: "AllPermissionsMet",
csv: csv("csv1",
namespace,
"0.0",
"0.0.0",
"",
installStrategy(
"csv1-dep",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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")},
Expand All @@ -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")},
Expand All @@ -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")},
Expand All @@ -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")},
Expand All @@ -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,
},
Expand Down
24 changes: 12 additions & 12 deletions test/e2e/csv_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 3332712

Please sign in to comment.