Skip to content

Commit

Permalink
fix logs
Browse files Browse the repository at this point in the history
Signed-off-by: Keran Yang <[email protected]>
  • Loading branch information
KeranYang committed Sep 17, 2024
1 parent 9267602 commit 58e9170
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 10 deletions.
6 changes: 3 additions & 3 deletions pkg/sdkclient/serverinfo/serverinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func checkNumaflowCompatibility(numaflowVersion string, minNumaflowVersion strin
numaflowConstraint := fmt.Sprintf(">= %s", minNumaflowVersion)
if err = checkConstraint(numaflowVersionSemVer, numaflowConstraint); err != nil {
return fmt.Errorf("numaflow version %s must be upgraded to at least %s, in order to work with current SDK version: %w",
numaflowVersionSemVer.String(), minNumaflowVersion, err)
numaflowVersionSemVer.String(), getRealMinimumVersion(minNumaflowVersion), err)
}
return nil
}
Expand All @@ -193,7 +193,7 @@ func checkSDKCompatibility(sdkVersion string, sdkLanguage Language, minSupported

if !c.Check(sdkVersionPEP440) {
return fmt.Errorf("SDK version %s must be upgraded to at least %s, in order to work with current numaflow version: %w",
sdkVersionPEP440.String(), sdkRequiredVersion, err)
sdkVersionPEP440.String(), getRealMinimumVersion(sdkRequiredVersion), err)
}
} else {
sdkVersionSemVer, err := semver.NewVersion(sdkVersion)
Expand All @@ -203,7 +203,7 @@ func checkSDKCompatibility(sdkVersion string, sdkLanguage Language, minSupported

if err := checkConstraint(sdkVersionSemVer, sdkConstraint); err != nil {
return fmt.Errorf("SDK version %s must be upgraded to at least %s, in order to work with current numaflow version: %w",
sdkVersionSemVer.String(), sdkRequiredVersion, err)
sdkVersionSemVer.String(), getRealMinimumVersion(sdkRequiredVersion), err)
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions pkg/sdkclient/serverinfo/serverinfo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func Test_CheckNumaflowCompatibility(t *testing.T) {
numaflowVersion: "v1.1.6",
minNumaflowVersion: "1.1.7-z",
shouldErr: true,
errMessage: "numaflow version 1.1.6 must be upgraded to at least 1.1.7-z, in order to work with current SDK version",
errMessage: "numaflow version 1.1.6 must be upgraded to at least 1.1.7, in order to work with current SDK version",
},
{
name: "Test with compatible numaflow version - min is a stable version 1.1.6",
Expand All @@ -114,7 +114,7 @@ func Test_CheckNumaflowCompatibility(t *testing.T) {
numaflowVersion: "v1.1.7-rc1",
minNumaflowVersion: "1.1.7-z",
shouldErr: true,
errMessage: "numaflow version 1.1.7-rc1 must be upgraded to at least 1.1.7-z, in order to work with current SDK version",
errMessage: "numaflow version 1.1.7-rc1 must be upgraded to at least 1.1.7, in order to work with current SDK version",
},
{
name: "Test with compatible numaflow version - min is a stable version 1.1.6, numaflow version is a pre-release version",
Expand Down Expand Up @@ -190,7 +190,7 @@ func Test_CheckSDKCompatibility(t *testing.T) {
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.5.3a1 must be upgraded to at least 0.6.0rc100, in order to work with current numaflow version",
errMessage: "SDK version 0.5.3a1 must be upgraded to at least 0.6.0, in order to work with current numaflow version",
},
{
name: "python pre-release version is compatible with minimum supported version",
Expand All @@ -212,7 +212,7 @@ func Test_CheckSDKCompatibility(t *testing.T) {
sdkLanguage: Python,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.5.3 must be upgraded to at least 0.6.0rc100, in order to work with current numaflow version",
errMessage: "SDK version 0.5.3 must be upgraded to at least 0.6.0, in order to work with current numaflow version",
},
{
name: "python release version is compatible with minimum supported version",
Expand Down Expand Up @@ -247,23 +247,23 @@ func Test_CheckSDKCompatibility(t *testing.T) {
sdkLanguage: Rust,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.0.3 must be upgraded to at least 0.1.0-z, in order to work with current numaflow version",
errMessage: "SDK version 0.0.3 must be upgraded to at least 0.1.0, in order to work with current numaflow version",
},
{
name: "java rc release version is lower than minimum supported version",
sdkVersion: "v0.6.0-rc1",
sdkLanguage: Java,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.6.0-rc1 must be upgraded to at least 0.6.0-z, in order to work with current numaflow version",
errMessage: "SDK version 0.6.0-rc1 must be upgraded to at least 0.6.0, in order to work with current numaflow version",
},
{
name: "golang pre-release version is lower than minimum supported version",
sdkVersion: "v0.6.0-0.20240913163521-4910018031a7",
sdkLanguage: Go,
minimumSupportedSDKVersions: testMinimumSupportedSDKVersions,
shouldErr: true,
errMessage: "SDK version 0.6.0-0.20240913163521-4910018031a7 must be upgraded to at least 0.6.0-z, in order to work with current numaflow version",
errMessage: "SDK version 0.6.0-0.20240913163521-4910018031a7 must be upgraded to at least 0.6.0, in order to work with current numaflow version",
},
}
for _, tt := range tests {
Expand Down
21 changes: 21 additions & 0 deletions pkg/sdkclient/serverinfo/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ limitations under the License.

package serverinfo

import "strings"

type Language string

const (
Expand Down Expand Up @@ -72,6 +74,25 @@ var minimumSupportedSDKVersions = sdkConstraints{
Rust: "0.1.0-z",
}

// getRealMinimumVersion returns the real minimum supported version for the given version.
// it's used to help log the correct minimum supported version in the error message.
// it translates the version we used in the sdkConstraints map to the real minimum supported version.
// e.g., if the given version is "0.8.0rc100", the real minimum supported version is "0.8.0".
// if the given version is "0.8.0-z", the real minimum supported version is "0.8.0".
// if the given version is "0.8.0-rc1", the real minimum supported version is "0.8.0-rc1".
func getRealMinimumVersion(ver string) string {
if ver == "" {
return ""
}
if strings.HasSuffix(ver, "-z") {
return ver[:len(ver)-2]
}
if strings.HasSuffix(ver, "rc100") {
return ver[:len(ver)-5]
}
return ver
}

type Protocol string

const (
Expand Down

0 comments on commit 58e9170

Please sign in to comment.