cmd/storagenode-updater: update to correct version
Currently if the nodes is below the minimum version it will immediately update to the suggested version, regardless if its eligible from the seed or not. This change corrects the behaviour to update to the minimum version only and then properly respect/wait for the rollout to include it. Updates based on logic here: https://review.dev.storj.io/c/storj/private/+/6187 Change-Id: Ic6c91c48ae9b8a116378b2573fbfca7e7bd5cc32
This commit is contained in:
parent
f94d8a200c
commit
4d023f773f
@ -14,11 +14,6 @@ import (
|
||||
)
|
||||
|
||||
func update(ctx context.Context, serviceName, binaryLocation string, ver version.Process) error {
|
||||
suggestedVersion, err := ver.Suggested.SemVer()
|
||||
if err != nil {
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
currentVersion, err := binaryVersion(binaryLocation)
|
||||
if err != nil {
|
||||
return errs.Wrap(err)
|
||||
@ -30,18 +25,18 @@ func update(ctx context.Context, serviceName, binaryLocation string, ver version
|
||||
)
|
||||
|
||||
// should update
|
||||
shouldUpdate, reason, err := version.ShouldUpdateVersion(currentVersion, nodeID, ver)
|
||||
newVersion, reason, err := version.ShouldUpdateVersion(currentVersion, nodeID, ver)
|
||||
if err != nil {
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
if !shouldUpdate {
|
||||
if newVersion.IsZero() {
|
||||
zap.L().Info(reason, zap.String("Service", serviceName))
|
||||
return nil
|
||||
}
|
||||
|
||||
newVersionPath := prependExtension(binaryLocation, ver.Suggested.Version)
|
||||
newVersionPath := prependExtension(binaryLocation, newVersion.Version)
|
||||
|
||||
if err = downloadBinary(ctx, parseDownloadURL(ver.Suggested.URL), newVersionPath); err != nil {
|
||||
if err = downloadBinary(ctx, parseDownloadURL(newVersion.URL), newVersionPath); err != nil {
|
||||
return errs.Wrap(err)
|
||||
}
|
||||
|
||||
@ -50,9 +45,14 @@ func update(ctx context.Context, serviceName, binaryLocation string, ver version
|
||||
return errs.Combine(errs.Wrap(err), os.Remove(newVersionPath))
|
||||
}
|
||||
|
||||
if suggestedVersion.Compare(downloadedVersion) != 0 {
|
||||
newSemVer, err := newVersion.SemVer()
|
||||
if err != nil {
|
||||
return errs.Combine(err, os.Remove(newVersionPath))
|
||||
}
|
||||
|
||||
if newSemVer.Compare(downloadedVersion) != 0 {
|
||||
err := errs.New("invalid version downloaded: wants %s got %s",
|
||||
suggestedVersion.String(),
|
||||
newVersion.Version,
|
||||
downloadedVersion.String(),
|
||||
)
|
||||
return errs.Combine(err, os.Remove(newVersionPath))
|
||||
|
2
go.mod
2
go.mod
@ -50,7 +50,7 @@ require (
|
||||
storj.io/common v0.0.0-20211021003554-f155346ccc11
|
||||
storj.io/drpc v0.0.26
|
||||
storj.io/monkit-jaeger v0.0.0-20210426161729-debb1cbcbbd7
|
||||
storj.io/private v0.0.0-20211028215455-880524381bb1
|
||||
storj.io/private v0.0.0-20211029202355-a7eae71c382a
|
||||
storj.io/uplink v1.7.1-0.20211012154306-65bb87992c7c
|
||||
)
|
||||
|
||||
|
4
go.sum
4
go.sum
@ -889,7 +889,7 @@ storj.io/drpc v0.0.26/go.mod h1:ofQUDPQbbIymRDKE0tms48k8bLP5Y+dsI9CbXGv3gko=
|
||||
storj.io/monkit-jaeger v0.0.0-20210225162224-66fb37637bf6/go.mod h1:gj4vuCeyCRjRmH8LIrgoyU9Dc9uR6H+/GcDUXmTbf80=
|
||||
storj.io/monkit-jaeger v0.0.0-20210426161729-debb1cbcbbd7 h1:zi0w9zoBfvuqysSAqxJT1Ton2YB5IhyMM3/3CISjlrQ=
|
||||
storj.io/monkit-jaeger v0.0.0-20210426161729-debb1cbcbbd7/go.mod h1:gj4vuCeyCRjRmH8LIrgoyU9Dc9uR6H+/GcDUXmTbf80=
|
||||
storj.io/private v0.0.0-20211028215455-880524381bb1 h1:DljhIJuoZ6xOsHBCSLeNFpeoP8enY1rJMVfga+wnbh8=
|
||||
storj.io/private v0.0.0-20211028215455-880524381bb1/go.mod h1:BoSaGSvsC8C6Gy0FyjrHfsElJA623hLsNIyexs6vGno=
|
||||
storj.io/private v0.0.0-20211029202355-a7eae71c382a h1:cWPChMGma5Cw5rdGuKrlc+XFxjisRVAXfa5Ny9/nxzw=
|
||||
storj.io/private v0.0.0-20211029202355-a7eae71c382a/go.mod h1:BoSaGSvsC8C6Gy0FyjrHfsElJA623hLsNIyexs6vGno=
|
||||
storj.io/uplink v1.7.1-0.20211012154306-65bb87992c7c h1:yhjQBOnEO1F6zTRkye2oSPgjQTa6Cf9h/rx/ssPFNGE=
|
||||
storj.io/uplink v1.7.1-0.20211012154306-65bb87992c7c/go.mod h1:FrGJM81ojBOv0qk2pZENtma+9ecQHNdfNnd3KAAwDwI=
|
||||
|
@ -12,7 +12,7 @@ require (
|
||||
go.uber.org/zap v1.17.0
|
||||
storj.io/common v0.0.0-20211021003554-f155346ccc11
|
||||
storj.io/gateway-mt v1.14.4-0.20211015103214-01eddbc864fb
|
||||
storj.io/private v0.0.0-20211028215455-880524381bb1
|
||||
storj.io/private v0.0.0-20211029202355-a7eae71c382a
|
||||
storj.io/storj v0.12.1-0.20210916114455-b2d724962c24
|
||||
)
|
||||
|
||||
|
@ -1414,8 +1414,8 @@ storj.io/monkit-jaeger v0.0.0-20210225162224-66fb37637bf6/go.mod h1:gj4vuCeyCRjR
|
||||
storj.io/monkit-jaeger v0.0.0-20210426161729-debb1cbcbbd7 h1:zi0w9zoBfvuqysSAqxJT1Ton2YB5IhyMM3/3CISjlrQ=
|
||||
storj.io/monkit-jaeger v0.0.0-20210426161729-debb1cbcbbd7/go.mod h1:gj4vuCeyCRjRmH8LIrgoyU9Dc9uR6H+/GcDUXmTbf80=
|
||||
storj.io/private v0.0.0-20210810102517-434aeab3f17d/go.mod h1:wvudoWSyOyB2daZNaMykjjqsSUad/ttFlUwgelg9+qg=
|
||||
storj.io/private v0.0.0-20211028215455-880524381bb1 h1:DljhIJuoZ6xOsHBCSLeNFpeoP8enY1rJMVfga+wnbh8=
|
||||
storj.io/private v0.0.0-20211028215455-880524381bb1/go.mod h1:BoSaGSvsC8C6Gy0FyjrHfsElJA623hLsNIyexs6vGno=
|
||||
storj.io/private v0.0.0-20211029202355-a7eae71c382a h1:cWPChMGma5Cw5rdGuKrlc+XFxjisRVAXfa5Ny9/nxzw=
|
||||
storj.io/private v0.0.0-20211029202355-a7eae71c382a/go.mod h1:BoSaGSvsC8C6Gy0FyjrHfsElJA623hLsNIyexs6vGno=
|
||||
storj.io/uplink v1.6.0/go.mod h1:zqj/LFDxa6RMaSRSHOmukg3mMgesOry0iHSjNldDMGo=
|
||||
storj.io/uplink v1.7.0/go.mod h1:zqj/LFDxa6RMaSRSHOmukg3mMgesOry0iHSjNldDMGo=
|
||||
storj.io/uplink v1.7.1-0.20211012154306-65bb87992c7c h1:yhjQBOnEO1F6zTRkye2oSPgjQTa6Cf9h/rx/ssPFNGE=
|
||||
|
Loading…
Reference in New Issue
Block a user