mirror of https://github.com/minio/minio.git
Appropriate error message on unsuccessful update. (#6203)
This commit is contained in:
parent
a7c9058375
commit
8e6d756e3a
|
@ -456,32 +456,32 @@ func getUpdateInfo(timeout time.Duration, mode string) (updateMsg string, sha256
|
||||||
return prepareUpdateMessage(downloadURL, older), sha256Hex, currentReleaseTime, latestReleaseTime, nil
|
return prepareUpdateMessage(downloadURL, older), sha256Hex, currentReleaseTime, latestReleaseTime, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func doUpdate(sha256Hex string, latestReleaseTime time.Time, ok bool) (successMsg string, err error) {
|
func doUpdate(sha256Hex string, latestReleaseTime time.Time, ok bool) (updateStatusMsg string, err error) {
|
||||||
if !ok {
|
if !ok {
|
||||||
successMsg = greenColorSprintf("Minio update to version RELEASE.%s canceled.",
|
updateStatusMsg = greenColorSprintf("Minio update to version RELEASE.%s canceled.",
|
||||||
latestReleaseTime.Format(minioReleaseTagTimeLayout))
|
latestReleaseTime.Format(minioReleaseTagTimeLayout))
|
||||||
return successMsg, nil
|
return updateStatusMsg, nil
|
||||||
}
|
}
|
||||||
var sha256Sum []byte
|
var sha256Sum []byte
|
||||||
sha256Sum, err = hex.DecodeString(sha256Hex)
|
sha256Sum, err = hex.DecodeString(sha256Hex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return successMsg, err
|
return updateStatusMsg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, err := http.Get(getDownloadURL(releaseTimeToReleaseTag(latestReleaseTime)))
|
resp, err := http.Get(getDownloadURL(releaseTimeToReleaseTag(latestReleaseTime)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return successMsg, err
|
return updateStatusMsg, err
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
// FIXME: add support for gpg verification as well.
|
// FIXME: add support for gpg verification as well.
|
||||||
if err = update.RollbackError(update.Apply(resp.Body,
|
if err = update.Apply(resp.Body,
|
||||||
update.Options{
|
update.Options{
|
||||||
Hash: crypto.SHA256,
|
Hash: crypto.SHA256,
|
||||||
Checksum: sha256Sum,
|
Checksum: sha256Sum,
|
||||||
},
|
},
|
||||||
)); err != nil {
|
); err != nil {
|
||||||
return successMsg, err
|
return updateStatusMsg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return greenColorSprintf("Minio updated to version RELEASE.%s successfully.",
|
return greenColorSprintf("Minio updated to version RELEASE.%s successfully.",
|
||||||
|
@ -497,6 +497,7 @@ func shouldUpdate(quiet bool, sha256Hex string, latestReleaseTime time.Time) (ok
|
||||||
}
|
}
|
||||||
|
|
||||||
var greenColorSprintf = color.New(color.FgGreen, color.Bold).SprintfFunc()
|
var greenColorSprintf = color.New(color.FgGreen, color.Bold).SprintfFunc()
|
||||||
|
var redColorSprintf = color.New(color.FgRed, color.Bold).SprintfFunc()
|
||||||
|
|
||||||
func mainUpdate(ctx *cli.Context) {
|
func mainUpdate(ctx *cli.Context) {
|
||||||
if len(ctx.Args()) != 0 {
|
if len(ctx.Args()) != 0 {
|
||||||
|
@ -527,13 +528,14 @@ func mainUpdate(ctx *cli.Context) {
|
||||||
// if the in-place update is disabled then we shouldn't ask the
|
// if the in-place update is disabled then we shouldn't ask the
|
||||||
// user to update the binaries.
|
// user to update the binaries.
|
||||||
if strings.Contains(updateMsg, minioReleaseURL) && !globalInplaceUpdateDisabled {
|
if strings.Contains(updateMsg, minioReleaseURL) && !globalInplaceUpdateDisabled {
|
||||||
var successMsg string
|
var updateStatusMsg string
|
||||||
successMsg, err = doUpdate(sha256Hex, latestReleaseTime, shouldUpdate(quiet, sha256Hex, latestReleaseTime))
|
updateStatusMsg, err = doUpdate(sha256Hex, latestReleaseTime, shouldUpdate(quiet, sha256Hex, latestReleaseTime))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Info(redColorSprintf("Unable to update ‘minio’."))
|
||||||
logger.Info(err.Error())
|
logger.Info(err.Error())
|
||||||
os.Exit(-1)
|
os.Exit(-1)
|
||||||
}
|
}
|
||||||
logger.Info(successMsg)
|
logger.Info(updateStatusMsg)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue