Re-add --force parameter for kube-rootca update strategy

To accommodate the upgraded subcloud from previous releases where the
kube-rootca_sync_status can be in-sync even without matching
certificates between subcloud and system controller, the kube-rootca
audit was changed to alarm based. Since the user might want to update
the cert for it to match between the two systems even with
kube-rootca_sync_status being in-sync, this commit adds the --force
parameter back to kube-rootca update strategy.

Test plan:
  - PASS: Perform a kube-rootca update strategy without --force in an
          out-of-sync subcloud and verify it completes successfully.
  - PASS: Perform a kube-rootca update strategy without --force in an
          in-sync subcloud and verify an exception is raised.
  - PASS: Perform a kube-rootca update strategy with --force in an
          in-sync subcloud and verify it completes successfully.

Depends-on: https://review.opendev.org/c/starlingx/distcloud/+/937874

Closes-bug: 2092069

Change-Id: I4dabe9811eaef8f82608576b0e70af109c57bc51
Signed-off-by: Victor Romano <victor.gluzromano@windriver.com>
This commit is contained in:
Victor Romano 2024-12-18 10:41:41 -03:00
parent 71a817fa80
commit 59d2f380f7

View File

@ -38,6 +38,12 @@ class CreateKubeRootcaUpdateStrategy(
parser.add_argument(
"--cert-file", required=False, help="Path to a certificate to upload."
)
parser.add_argument(
"--force",
required=False,
action="store_true",
help="Allow update even with in-sync endpoint status.",
)
return parser
@ -51,6 +57,8 @@ class CreateKubeRootcaUpdateStrategy(
if parsed_args.cert_file:
# Need an absolute path for the cert-file
kwargs_dict["cert-file"] = os.path.abspath(parsed_args.cert_file)
if parsed_args.force:
kwargs_dict["force"] = "true"
class ShowKubeRootcaUpdateStrategy(