diff --git a/cmd/upgrade/roles/cmd.go b/cmd/upgrade/roles/cmd.go index 53919a392a..5d2be014e4 100644 --- a/cmd/upgrade/roles/cmd.go +++ b/cmd/upgrade/roles/cmd.go @@ -299,6 +299,7 @@ func run(cmd *cobra.Command, argv []string) { LogError(roles.RosaUpgradeAccRolesModeAuto, ocmClient, policyVersion, err, reporter) if args.isInvokedFromClusterUpgrade { reporter.Errorf("%s", err) + printClusterUpgradeInfo(mode, reporter) os.Exit(1) } reporter.Errorf("Error upgrading the account role policies: %s", err) @@ -417,6 +418,9 @@ func run(cmd *cobra.Command, argv []string) { ) if err != nil { r.Reporter.Errorf("%s", err) + if args.isInvokedFromClusterUpgrade { + printClusterUpgradeInfo(mode, reporter) + } os.Exit(1) } } @@ -443,6 +447,9 @@ func run(cmd *cobra.Command, argv []string) { ) if err != nil { r.Reporter.Errorf("%s", err) + if args.isInvokedFromClusterUpgrade { + printClusterUpgradeInfo(mode, r.Reporter) + } os.Exit(1) } createdMissingRoles++ @@ -1173,3 +1180,16 @@ func checkPolicyAndClusterVersionCompatibility(policyVersion, clusterVersion str } return nil } + +func printClusterUpgradeInfo(mode string, reporter *rprtr.Object) { + if args.isInvokedFromClusterUpgrade && reporter.IsTerminal() { + rolesStr := fmt.Sprintf("rosa upgrade roles -c %s --cluster-version=%s --mode=%s", + args.clusterID, args.clusterUpgradeVersion, mode) + upgradeClusterStr := fmt.Sprintf("rosa upgrade cluster -c %s", args.clusterID) + reporter.Infof("Account/Operator Role policies are not valid with upgrade version %s. "+ + "Run the following command(s) to upgrade the roles:\n"+ + "\t%s\n\n"+ + ", then run the upgrade command again:\n"+ + "\t%s\n", args.clusterUpgradeVersion, rolesStr, upgradeClusterStr) + } +}