Skip to content

Commit

Permalink
PWX-22131,PWX-34256_pt4 (px-rel-23.10.2): Version parsing fix (#1383) (
Browse files Browse the repository at this point in the history
…#1385)

Signed-off-by: Zoran Rajic <zox@portworx.com>
  • Loading branch information
zoxpx authored Dec 22, 2023
1 parent 7ed33e3 commit 98618a4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/storage/portworx/manifest/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,12 @@ func (m *manifest) GetVersions(
var provider versionProvider
ver := pxutil.GetImageTag(cluster.Spec.Image)
currPxVer, err := version.NewSemver(ver)
if err == nil {
if currPxVer.LessThan(pxVer2_5_7) {
provider = newDeprecatedManifest(ver)
}
if currPxVer == nil || err != nil {
// note, dev-bulids like `c2bb2a0_14e4543` won't parse correctly, so adding this as a failback
currPxVer = pxutil.GetPortworxVersion(cluster)
}
if currPxVer != nil && currPxVer.LessThan(pxVer2_5_7) {
provider = newDeprecatedManifest(ver)
}

if provider == nil {
Expand Down
40 changes: 40 additions & 0 deletions drivers/storage/portworx/manifest/manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,46 @@ func TestManifestWithKnownNonSemvarPortworxVersion(t *testing.T) {
require.Equal(t, expected, rel)
}

func TestManifestWithDevelopmentPortworxVersion(t *testing.T) {
k8sVersion, _ := version.NewSemver("1.28.4")
expected := &Version{
PortworxVersion: "c2bb2a0_14e4543",
Components: Release{
Stork: "image/stork:22.33.44",
Autopilot: "image/autopi:55.666.777",
},
}
httpGet = func(url string) (*http.Response, error) {
body, _ := yaml.Marshal(expected)
return &http.Response{
Body: io.NopCloser(bytes.NewReader(body)),
}, nil
}

expected_ociMon := "px/image:" + expected.PortworxVersion
cluster := &corev1.StorageCluster{
Spec: corev1.StorageClusterSpec{
Image: expected_ociMon,
CommonConfig: corev1.CommonConfig{
Env: []v1.EnvVar{
{
Name: envKeyReleaseManifestURL,
Value: "https://edge-install.portworx.com/3.1.0/version",
},
},
},
},
}

m := Instance()
m.Init(testutil.FakeK8sClient(), nil, k8sVersion)
rel := m.GetVersions(cluster, true)
assert.Equal(t, rel.PortworxVersion, expected.PortworxVersion)
assert.Equal(t, rel.Components.Stork, expected.Components.Stork)
assert.Equal(t, rel.Components.Autopilot, expected.Components.Autopilot)
assert.Equal(t, rel.Components.NodeWiper, expected_ociMon)
}

func TestManifestWithUnknownNonSemvarPortworxVersion(t *testing.T) {
httpGet = func(url string) (*http.Response, error) {
// Return empty response without any versions
Expand Down

0 comments on commit 98618a4

Please sign in to comment.