Skip to content

Commit fcbbaec

Browse files
committed
[PWX-28585] Avoid parsing git sha to valid operator versions in automation
1 parent 7a3d5f2 commit fcbbaec

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

pkg/util/test/util.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2875,14 +2875,17 @@ func GetPxOperatorVersion() (*version.Version, error) {
28752875
if err != nil {
28762876
return nil, err
28772877
}
2878-
2878+
// tag is not a valid version, e.g. commit sha in PR automation builds "1a6a788" can be parsed to "1.0.0-a6a788"
2879+
if !strings.Contains(imageTag, ".") {
2880+
logrus.Errorf("Operator tag %s is not a valid version tag, assuming its latest and setting it to %s", imageTag, PxOperatorMasterVersion)
2881+
imageTag = PxOperatorMasterVersion
2882+
}
28792883
// We may run the automation on operator installed using private images,
28802884
// so assume we are testing the latest operator version if failed to parse the tag
28812885
opVersion, err := version.NewVersion(imageTag)
28822886
if err != nil {
2883-
masterVersionTag := PxOperatorMasterVersion
28842887
logrus.WithError(err).Warnf("Failed to parse portworx-operator tag to version, assuming its latest and setting it to %s", PxOperatorMasterVersion)
2885-
opVersion, _ = version.NewVersion(masterVersionTag)
2888+
opVersion, _ = version.NewVersion(PxOperatorMasterVersion)
28862889
}
28872890

28882891
logrus.Infof("Testing portworx-operator version [%s]", opVersion.String())

test/integration_test/utils/px_operator.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,18 @@ var (
3232

3333
// GetPXOperatorVersion returns the portworx operator version found
3434
func GetPXOperatorVersion() (*version.Version, error) {
35-
pxImageTag, err := getPXOperatorImageTag()
35+
imageTag, err := getPXOperatorImageTag()
3636
if err != nil {
3737
return nil, err
3838
}
39-
39+
// tag is not a valid version, e.g. commit sha in PR automation builds "1a6a788" can be parsed to "1.0.0-a6a788"
40+
if !strings.Contains(imageTag, ".") {
41+
logrus.Errorf("Operator tag %s is not a valid version tag, assuming its latest and setting it to %s", imageTag, pxOperatorMasterVersion)
42+
imageTag = pxOperatorMasterVersion
43+
}
4044
// We may run the automation on operator installed using private images,
4145
// so assume we are testing the latest operator version if failed to parse the tag
42-
opVersion, err := version.NewVersion(pxImageTag)
46+
opVersion, err := version.NewVersion(imageTag)
4347
if err != nil {
4448
logrus.WithError(err).Warnf("Failed to parse portworx-operator tag to version, assuming its latest and setting it to %s", pxOperatorMasterVersion)
4549
opVersion, _ = version.NewVersion(pxOperatorMasterVersion)

0 commit comments

Comments
 (0)