Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PWX-32825: Adjusting version triggers for px-3.0.1 #1207

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions drivers/storage/portworx/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var (
pxVer2_8, _ = version.NewVersion("2.8")
pxVer2_9_1, _ = version.NewVersion("2.9.1")
pxVer2_13_8, _ = version.NewVersion("2.13.8")
pxVer3_0_1, _ = version.NewVersion("3.0.1")
pxVer3_0, _ = version.NewVersion("3.0")
)

type volumeInfo struct {
Expand Down Expand Up @@ -302,9 +302,9 @@ func (p *portworx) GetStoragePodSpec(
}

if _, has := t.cluster.Annotations[pxutil.AnnotationIsPrivileged]; has {
if pxutil.GetPortworxVersion(cluster).LessThan(pxVer3_0_1) {
err = fmt.Errorf("failed to create pod spec: need portworx %s or higher to use annotation '%s'",
pxVer3_0_1, pxutil.AnnotationIsPrivileged)
if pxutil.GetPortworxVersion(cluster).LessThanOrEqual(pxVer3_0) {
err = fmt.Errorf("failed to create pod spec: need portworx higher than %s to use annotation '%s'",
pxVer3_0, pxutil.AnnotationIsPrivileged)
return v1.PodSpec{}, err
}
}
Expand Down Expand Up @@ -1040,7 +1040,7 @@ func (t *template) getArguments() []string {
args = append(args, "--log", t.cluster.Annotations[pxutil.AnnotationLogFile])
}
// for non-privileged and PKS, add shared mounts via parameters
if t.pxVersion.GreaterThanOrEqual(pxVer3_0_1) &&
if t.pxVersion.GreaterThan(pxVer3_0) &&
(!pxutil.IsPrivileged(t.cluster) || pxutil.IsPKS(t.cluster)) {
args = append(args,
"-v", "/var/lib/osd/pxns:/var/lib/osd/pxns:shared",
Expand Down Expand Up @@ -1158,7 +1158,7 @@ func (t *template) getEnvList() []v1.EnvVar {

if t.isPKS {
ev := "if [ ! -x /bin/systemctl ]; then apt-get update; apt-get install -y systemd; fi"
if t.pxVersion.GreaterThanOrEqual(pxVer3_0_1) {
if t.pxVersion.GreaterThan(pxVer3_0) {
ev = "rm -fr /var/lib/osd/driver"
}
envMap["PRE-EXEC"] = &v1.EnvVar{
Expand Down Expand Up @@ -1858,7 +1858,7 @@ func getDefaultVolumeInfoList(pxVersion *version.Version) []volumeInfo {
func getCommonVolumeList(pxVersion *version.Version) []volumeInfo {
list := make([]volumeInfo, 0)

if pxVersion.GreaterThanOrEqual(pxVer3_0_1) {
if pxVersion.GreaterThan(pxVer3_0) {
list = append(list, volumeInfo{
name: "varlibosd",
hostPath: "/var/lib/osd",
Expand Down
11 changes: 10 additions & 1 deletion drivers/storage/portworx/deployment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2778,7 +2778,7 @@ func TestOpenshiftRuncPodSpec(t *testing.T) {

actual, err = driver.GetStoragePodSpec(cluster, nodeName)
require.Error(t, err)
assert.Contains(t, err.Error(), "need portworx 3.0.1 or higher to use annotation '"+
assert.Contains(t, err.Error(), "need portworx higher than 3.0.0 to use annotation '"+
pxutil.AnnotationIsPrivileged+"'")

cluster.Spec.Image = "portworx/oci-monitor:3.0.1"
Expand Down Expand Up @@ -2808,6 +2808,15 @@ func TestOpenshiftRuncPodSpec(t *testing.T) {
for _, v := range actual.Containers[0].VolumeMounts {
assert.Nil(t, v.MountPropagation, "Wrong propagation on %v", v)
}

// PWX-32825 tweak the 3.0.1 version slightly -- should still evaluate the same
cluster.Spec.Image = "portworx/oci-monitor:3.0.1-ubuntu1604"
expected_3_0_1.Containers[0].Image = "docker.io/" + cluster.Spec.Image

actual, err = driver.GetStoragePodSpec(cluster, nodeName)
require.NoError(t, err)

assertPodSpecEqual(t, expected_3_0_1, &actual)
}

func TestPodSpecForK3s(t *testing.T) {
Expand Down
Loading