Appropriate error message on unsuccessful update. (#6203)

master
Aarushi Arya 6 years ago committed by kannappanr
parent a7c9058375
commit 8e6d756e3a
  1. 24
      cmd/update-main.go

@ -456,32 +456,32 @@ func getUpdateInfo(timeout time.Duration, mode string) (updateMsg string, sha256
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 {
successMsg = greenColorSprintf("Minio update to version RELEASE.%s canceled.",
updateStatusMsg = greenColorSprintf("Minio update to version RELEASE.%s canceled.",
latestReleaseTime.Format(minioReleaseTagTimeLayout))
return successMsg, nil
return updateStatusMsg, nil
}
var sha256Sum []byte
sha256Sum, err = hex.DecodeString(sha256Hex)
if err != nil {
return successMsg, err
return updateStatusMsg, err
}
resp, err := http.Get(getDownloadURL(releaseTimeToReleaseTag(latestReleaseTime)))
if err != nil {
return successMsg, err
return updateStatusMsg, err
}
defer resp.Body.Close()
// FIXME: add support for gpg verification as well.
if err = update.RollbackError(update.Apply(resp.Body,
if err = update.Apply(resp.Body,
update.Options{
Hash: crypto.SHA256,
Checksum: sha256Sum,
},
)); err != nil {
return successMsg, err
); err != nil {
return updateStatusMsg, err
}
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 redColorSprintf = color.New(color.FgRed, color.Bold).SprintfFunc()
func mainUpdate(ctx *cli.Context) {
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
// user to update the binaries.
if strings.Contains(updateMsg, minioReleaseURL) && !globalInplaceUpdateDisabled {
var successMsg string
successMsg, err = doUpdate(sha256Hex, latestReleaseTime, shouldUpdate(quiet, sha256Hex, latestReleaseTime))
var updateStatusMsg string
updateStatusMsg, err = doUpdate(sha256Hex, latestReleaseTime, shouldUpdate(quiet, sha256Hex, latestReleaseTime))
if err != nil {
logger.Info(redColorSprintf("Unable to update ‘minio’."))
logger.Info(err.Error())
os.Exit(-1)
}
logger.Info(successMsg)
logger.Info(updateStatusMsg)
os.Exit(1)
}
}

Loading…
Cancel
Save