From d9b1c4520e01508a66845668864cd22821fcd18c Mon Sep 17 00:00:00 2001 From: JT Olio Date: Fri, 5 Jun 2020 16:09:34 -0600 Subject: [PATCH] storagenode-updater: fix logic to use minimum version correctly See: https://review.dev.storj.io/c/storj/storj/+/2052 https://review.dev.storj.io/c/storj/private/+/2053 Change-Id: I30952c6e3893194ca876c12ecb7e53944e66aa2e --- cmd/storagenode-updater/cmd_test.go | 8 ++++++++ cmd/storagenode-updater/loop_windows.go | 10 +++++----- cmd/storagenode-updater/update.go | 10 +++++----- go.mod | 2 +- go.sum | 4 ++-- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/cmd/storagenode-updater/cmd_test.go b/cmd/storagenode-updater/cmd_test.go index 075aeefb1..be86c2958 100644 --- a/cmd/storagenode-updater/cmd_test.go +++ b/cmd/storagenode-updater/cmd_test.go @@ -221,6 +221,10 @@ func testVersionControlWithUpdates(ctx *testcontext.Context, t *testing.T, updat }, Binary: versioncontrol.ProcessesConfig{ Storagenode: versioncontrol.ProcessConfig{ + Minimum: versioncontrol.VersionConfig{ + Version: oldVersion, + URL: ts.URL + "/storagenode-old", + }, Suggested: versioncontrol.VersionConfig{ Version: newVersion, URL: ts.URL + "/storagenode", @@ -231,6 +235,10 @@ func testVersionControlWithUpdates(ctx *testcontext.Context, t *testing.T, updat }, }, StoragenodeUpdater: versioncontrol.ProcessConfig{ + Minimum: versioncontrol.VersionConfig{ + Version: oldVersion, + URL: ts.URL + "/storagenode-old", + }, Suggested: versioncontrol.VersionConfig{ Version: newVersion, URL: ts.URL + "/storagenode-updater", diff --git a/cmd/storagenode-updater/loop_windows.go b/cmd/storagenode-updater/loop_windows.go index 5e07a9a9e..a8907fdeb 100644 --- a/cmd/storagenode-updater/loop_windows.go +++ b/cmd/storagenode-updater/loop_windows.go @@ -50,12 +50,12 @@ func updateSelf(ctx context.Context, binaryLocation string, ver version.Process) currentVersion := version.Build.Version // should update - if currentVersion.Compare(suggestedVersion) >= 0 { - zap.L().Info("Version is up to date.", zap.String("Service", updaterServiceName)) - return nil + shouldUpdate, reason, err := version.ShouldUpdateVersion(currentVersion, nodeID, ver) + if err != nil { + return errs.Wrap(err) } - if !version.ShouldUpdate(ver.Rollout, nodeID) { - zap.L().Info("New version available but not rolled out to this nodeID yet", zap.String("Service", updaterServiceName)) + if !shouldUpdate { + zap.L().Info(reason, zap.String("Service", updaterServiceName)) return nil } diff --git a/cmd/storagenode-updater/update.go b/cmd/storagenode-updater/update.go index ef5235288..3654b60c5 100644 --- a/cmd/storagenode-updater/update.go +++ b/cmd/storagenode-updater/update.go @@ -30,12 +30,12 @@ func update(ctx context.Context, serviceName, binaryLocation string, ver version } // should update - if currentVersion.Compare(suggestedVersion) >= 0 { - zap.L().Info("Version is up to date.", zap.String("Service", serviceName)) - return nil + shouldUpdate, reason, err := version.ShouldUpdateVersion(currentVersion, nodeID, ver) + if err != nil { + return errs.Wrap(err) } - if !version.ShouldUpdate(ver.Rollout, nodeID) { - zap.L().Info("New version available but not rolled out to this nodeID yet", zap.String("Service", serviceName)) + if !shouldUpdate { + zap.L().Info(reason, zap.String("Service", serviceName)) return nil } diff --git a/go.mod b/go.mod index 022456e00..bd2e91548 100644 --- a/go.mod +++ b/go.mod @@ -42,6 +42,6 @@ require ( storj.io/common v0.0.0-20200601223809-7af8b7ee5d6c storj.io/drpc v0.0.12 storj.io/monkit-jaeger v0.0.0-20200518165323-80778fc3f91b - storj.io/private v0.0.0-20200527091855-082647005cf3 + storj.io/private v0.0.0-20200605221229-3236fe879ab3 storj.io/uplink v1.0.7 ) diff --git a/go.sum b/go.sum index 9231c4ba1..9d3dde1df 100644 --- a/go.sum +++ b/go.sum @@ -647,7 +647,7 @@ storj.io/drpc v0.0.12 h1:4ei1M4cnWlYxcQheX0Dg4+c12zCD+oJqfweVQVWarsA= storj.io/drpc v0.0.12/go.mod h1:82nfl+6YwRwF6UG31cEWWUqv/FaKvP5SGqUvoqTxCMA= storj.io/monkit-jaeger v0.0.0-20200518165323-80778fc3f91b h1:Bbg9JCtY6l3HrDxs3BXzT2UYnYCBLqNi6i84Y8QIPUs= storj.io/monkit-jaeger v0.0.0-20200518165323-80778fc3f91b/go.mod h1:gj4vuCeyCRjRmH8LIrgoyU9Dc9uR6H+/GcDUXmTbf80= -storj.io/private v0.0.0-20200527091855-082647005cf3 h1:niVMosczB5dcenexg5gIvbn5hfFeFweGIB5vykRHHPQ= -storj.io/private v0.0.0-20200527091855-082647005cf3/go.mod h1:iDgIudPntDcHt5vyOecd2KS7YEx3E5CD0/sxjtM7fG0= +storj.io/private v0.0.0-20200605221229-3236fe879ab3 h1:kUn1+iJmBwBTJopuNlN3daKAXLNe1u3F/cGDq0o3sak= +storj.io/private v0.0.0-20200605221229-3236fe879ab3/go.mod h1:iDgIudPntDcHt5vyOecd2KS7YEx3E5CD0/sxjtM7fG0= storj.io/uplink v1.0.7 h1:vI0csamiYsN2vTj17x4QUUQ8xyyFVQvNzxJjUsSEi7U= storj.io/uplink v1.0.7/go.mod h1:PiLAqaFPUgsOs4u0xfVtm1jkWSQwdQmXv7KQUJUL/MU=