From 40aaf25d2d569e9eeb388959c19f312f2706b8fa Mon Sep 17 00:00:00 2001 From: Muthu Chidambaram Date: Thu, 29 Feb 2024 10:52:36 -0600 Subject: [PATCH] [BACKPORT 2.20.2][PLAT-12911] Fixing pause/resume for disks not mounted by UUID Summary: Original commit: 308af1fd6fcc8b23ce33f5476a8f9a572e5d4440 / D32735 Issue with pause/resume when universes disks were not mounted by UUID. We were trying to call self.cloud.get_device_names without the host_info, which for AWS was made required as part of https://phorge.dev.yugabyte.com/D31847. This diff overrides getting device names for AWS only to use host_info. Test Plan: patch diff on portal where failure occurred and retry pause/resume Reviewers: anijhawan, dshubin, yshchetinin, nbhatia Reviewed By: anijhawan Subscribers: aaruj, yugaware Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D32759 --- managed/devops/opscli/ybops/cloud/aws/cloud.py | 2 +- managed/devops/opscli/ybops/cloud/aws/method.py | 5 ++++- managed/devops/opscli/ybops/cloud/common/method.py | 10 ++++++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/managed/devops/opscli/ybops/cloud/aws/cloud.py b/managed/devops/opscli/ybops/cloud/aws/cloud.py index 89748c56b566e..b4536c23706fa 100644 --- a/managed/devops/opscli/ybops/cloud/aws/cloud.py +++ b/managed/devops/opscli/ybops/cloud/aws/cloud.py @@ -464,7 +464,7 @@ def get_host_info_specific_args(self, region, search_pattern, get_all=False, results.append(result) return results - def get_device_names(self, args, host_info): + def get_device_names(self, args, host_info=None): if has_ephemerals(args.instance_type, args.region): return [] else: diff --git a/managed/devops/opscli/ybops/cloud/aws/method.py b/managed/devops/opscli/ybops/cloud/aws/method.py index e31e01b16c466..071cab5abc7f9 100644 --- a/managed/devops/opscli/ybops/cloud/aws/method.py +++ b/managed/devops/opscli/ybops/cloud/aws/method.py @@ -136,7 +136,7 @@ def update_ansible_vars_with_args(self, args): self.extra_vars["mount_points"] = self.cloud.get_mount_points_csv(args) self.extra_vars.update({"aws_key_pair_name": args.key_pair_name}) - def get_device_names(self, args, host_info): + def get_device_names(self, args, host_info=None): return self.cloud.get_device_names(args, host_info) @@ -573,3 +573,6 @@ def add_extra_args(self): super(AwsUpdateMountedDisksMethod, self).add_extra_args() self.parser.add_argument("--volume_type", choices=["gp3", "gp2", "io1"], default="gp2", help="Volume type for volumes on EBS-backed instances.") + + def get_device_names(self, args, host_info=None): + return self.cloud.get_device_names(args, host_info) diff --git a/managed/devops/opscli/ybops/cloud/common/method.py b/managed/devops/opscli/ybops/cloud/common/method.py index 5fecafd82264f..3e2ae5a70e40e 100644 --- a/managed/devops/opscli/ybops/cloud/common/method.py +++ b/managed/devops/opscli/ybops/cloud/common/method.py @@ -848,7 +848,7 @@ def callback(self, args): host_port_user["user"], host_port_user["port"])) - def get_device_names(self, args, host_info): + def get_device_names(self, args, host_info=None): return self.cloud.get_device_names(args) def update_ansible_vars(self, args): @@ -1035,13 +1035,19 @@ def __init__(self, base_command): def update_ansible_vars_with_args(self, args): super(UpdateMountedDisksMethod, self).update_ansible_vars_with_args(args) - self.extra_vars["device_names"] = self.cloud.get_device_names(args) + + def get_device_names(args, host_info=None): + self.cloud.get_device_names(args) def callback(self, args): # Need to verify that all disks are mounted by UUUID host_info = self.cloud.get_host_info(args) + if not host_info: + raise YBOpsRuntimeError("Could not find host {} to provision!".format( + args.search_pattern)) ansible = self.cloud.setup_ansible(args) self.update_ansible_vars_with_args(args) + self.extra_vars["device_names"] = self.get_device_names(args, host_info) self.extra_vars.update(self.get_server_host_port(host_info, args.custom_ssh_port)) ansible.playbook_args["remote_role"] = "mount_ephemeral_drives" logging.debug(pprint(self.extra_vars))