From 7e19044d982c42ab670d1b9124fd417019eadda4 Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Sun, 24 Jan 2021 08:05:15 +0100 Subject: [PATCH] ilm: Import aborts when lifecycle config does not have a rule (#3576) Currently, there is a success message misleading the user, while what is really happened is that minio-go SetLifecycle removes any existing lifecycle configuration in the bucket. --- cmd/ilm-import.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/ilm-import.go b/cmd/ilm-import.go index 401f621d..587524bd 100644 --- a/cmd/ilm-import.go +++ b/cmd/ilm-import.go @@ -104,6 +104,12 @@ func mainILMImport(cliCtx *cli.Context) error { ilmCfg, err := readILMConfig() fatalIf(err.Trace(args...), "Unable to read ILM configuration") + if len(ilmCfg.Rules) == 0 { + // Abort here, otherwise client.SetLifecycle will remove the lifecycle configuration + // since no rules are provided and we will show a success message. + fatalIf(errDummy(), "The provided ILM configuration does not contain any rule, aborting.") + } + fatalIf(client.SetLifecycle(ctx, ilmCfg).Trace(urlStr), "Unable to set new lifecycle rules") printMsg(ilmImportMessage{