forked from determined-ai/determined
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: pull version check out (determined-ai#759)
- Loading branch information
Showing
6 changed files
with
116 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
master/internal/rm/dispatcherrm/dispatcher_version_checker.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package dispatcherrm | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
semvar "github.com/Masterminds/semver/v3" | ||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
const versionCheckPeriod = 60 | ||
|
||
var launcherMinimumVersion = semvar.MustParse("3.2.4") | ||
|
||
// periodicallyCheckLauncherVersion checks the launcher version every 60s, logging warnings while | ||
// it is out of date and exiting if it finds it is ok. | ||
func periodicallyCheckLauncherVersion( | ||
ctx context.Context, | ||
log *logrus.Entry, | ||
cl *launcherAPIClient, | ||
) { | ||
for range time.NewTicker(versionCheckPeriod).C { | ||
v, err := cl.getVersion(ctx) | ||
if err != nil { | ||
log.WithError(err).Error("could not get launcher API version") | ||
continue | ||
} | ||
|
||
if checkLauncherVersion(v) { | ||
return | ||
} | ||
|
||
log.Errorf("Launcher version %s does not meet the required minimum. "+ | ||
"Upgrade to hpe-hpc-launcher version %s", | ||
v, launcherMinimumVersion) | ||
} | ||
} | ||
|
||
func checkLauncherVersion(v *semvar.Version) bool { | ||
return v.Equal(launcherMinimumVersion) || v.GreaterThan(launcherMinimumVersion) | ||
} |
20 changes: 20 additions & 0 deletions
20
master/internal/rm/dispatcherrm/dispatcher_version_checker_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package dispatcherrm | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/Masterminds/semver/v3" | ||
"gotest.tools/assert" | ||
) | ||
|
||
func TestCheckLauncherVersion(t *testing.T) { | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("4.1.0")), true) | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("4.1.3-SNAPSHOT")), true) | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("3.2.4")), true) | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("3.2.3")), false) | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("3.2.0")), false) | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("3.1.3")), false) | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("3.1.0")), false) | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("2.3.3")), false) | ||
assert.Equal(t, checkLauncherVersion(semver.MustParse("3.0.3")), false) | ||
} |