Skip to content

Commit

Permalink
[BACKPORT 2024.2.1][PLAT-16404] Handle Azure images with no plan info…
Browse files Browse the repository at this point in the history
…rmation

Summary:
We always try to compute the plan information for an image regardless of whether use_plan is specified or not, which sometimes comes into issues when the image tags don't have certain fields we expect containing plan information specified. With recent YBM incident with Azure images, plan information may have been removed from packer process for some images, so code needs to be more robust to handle those situations.
Original commit: 1e297c2 / D41202

Test Plan: Test with /subscriptions/dc8d5676-65d2-4322-849b-d23b84e54d26/resourceGroups/yugabyte-ami-rg/providers/Microsoft.Compute/galleries/yugabyte_amis_gallery/images/yugabyte-db-ami-almalinux-8-gen2-x86-64/versions/1.0.2528

Reviewers: asharma, cwang

Reviewed By: cwang

Subscribers: yugaware, daniel

Differential Revision: https://phorge.dev.yugabyte.com/D41353
  • Loading branch information
mchiddy committed Jan 23, 2025
1 parent 6761872 commit 1554cd6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions managed/devops/opscli/ybops/cloud/azure/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,9 @@ def create_or_update_vm(self, vm_name, zone, num_vols, private_key_file, volume_
# Otherwise, we try to extract this info from the purchase plan
# or identifier of the image definition.
if (image_tags is not None
and image_tags['PlanPublisher'] is not None
and image_tags['PlanProduct'] is not None
and image_tags['PlanInfo'] is not None):
and image_tags.get('PlanPublisher', None) is not None
and image_tags.get('PlanProduct', None) is not None
and image_tags.get('PlanInfo', None) is not None):
plan = {
"publisher": image_tags['PlanPublisher'],
"product": image_tags['PlanProduct'],
Expand All @@ -916,9 +916,9 @@ def create_or_update_vm(self, vm_name, zone, num_vols, private_key_file, volume_
image_identifier = gallery_image.as_dict().get('identifier')
logging.info("Gallery Image identifier = " + str(image_identifier))
if (image_identifier is not None
and image_identifier["publisher"] is not None
and image_identifier["offer"] is not None
and image_identifier["sku"] is not None):
and image_identifier.get("publisher", None) is not None
and image_identifier.get("offer", None) is not None
and image_identifier.get("sku", None) is not None):
plan = {
"publisher": image_identifier["publisher"],
"product": image_identifier["offer"],
Expand Down

0 comments on commit 1554cd6

Please sign in to comment.