From 24cda35811aea756fe4f774a92b6951e40696fc6 Mon Sep 17 00:00:00 2001 From: msanjive-21 Date: Tue, 11 Jun 2024 11:42:12 -0700 Subject: [PATCH 1/2] Added 'disableHighAvailability' flag for resources --- services/compute/compute.go | 2 ++ services/compute/galleryimage/galleryimage.go | 5 +++++ services/storage/container/container.go | 6 ++++++ services/storage/storage.go | 4 ++++ services/storage/virtualharddisk/virtualharddisk.go | 5 +++++ 5 files changed, 22 insertions(+) diff --git a/services/compute/compute.go b/services/compute/compute.go index 7744ca872..b9604b522 100644 --- a/services/compute/compute.go +++ b/services/compute/compute.go @@ -850,6 +850,8 @@ type GalleryImageProperties struct { SourceType common.ImageSource `json:"sourceType,omitempty"` // CloudInitDataSource - READ-ONLY; The cloud init data source to be used with the image. [NoCloud, Azure]. Default Value – NoCloud. For marketplace images it will be Azure. CloudInitDataSource common.CloudInitDataSource `json:"cloudInitDataSource,omitempty"` + // Disable High Availability + DisableHighAvailability *bool `json:"disableHighAvailability,omitempty"` } // GalleryImage specifies information about the gallery Image Definition that you want to create or update. diff --git a/services/compute/galleryimage/galleryimage.go b/services/compute/galleryimage/galleryimage.go index 524d2272f..2d01f7bd0 100644 --- a/services/compute/galleryimage/galleryimage.go +++ b/services/compute/galleryimage/galleryimage.go @@ -30,6 +30,10 @@ func getWssdGalleryImage(c *compute.GalleryImage, locationName, imagePath string wssdgalleryimage.ContainerName = *c.GalleryImageProperties.ContainerName } + if c.DisableHighAvailability != nil { + wssdgalleryimage.DisableHighAvailability = *c.DisableHighAvailability + } + if c.GalleryImageProperties != nil { wssdgalleryimage.SourceType = c.SourceType wssdgalleryimage.CloudInitDataSource = c.GalleryImageProperties.CloudInitDataSource @@ -56,6 +60,7 @@ func getGalleryImage(c *wssdcloudcompute.GalleryImage, location string) *compute Statuses: status.GetStatuses(c.GetStatus()), ContainerName: &c.ContainerName, HyperVGeneration: c.HyperVGeneration, + DisableHighAvailability: &c.DisableHighAvailability, }, Tags: tags.ProtoToMap(c.Tags), } diff --git a/services/storage/container/container.go b/services/storage/container/container.go index d4d5dc20d..b3db5f7f5 100644 --- a/services/storage/container/container.go +++ b/services/storage/container/container.go @@ -40,6 +40,11 @@ func getWssdContainer(c *storage.Container, locationName string) (*wssdcloudstor } wssdcontainer.Isolated = c.Isolated } + + if c.DisableHighAvailability != nil { + wssdcontainer.DisableHighAvailability = *c.DisableHighAvailability + } + return wssdcontainer, nil } @@ -71,6 +76,7 @@ func getContainer(c *wssdcloudstorage.Container, location string) *storage.Conta AvailableSize: availSize, TotalSize: totalSize, }, + DisableHighAvailability: &c.DisableHighAvailability, }, Version: &c.Status.Version.Number, Tags: tags.ProtoToMap(c.Tags), diff --git a/services/storage/storage.go b/services/storage/storage.go index 01d788891..d962f0ffe 100644 --- a/services/storage/storage.go +++ b/services/storage/storage.go @@ -40,6 +40,8 @@ type VirtualHardDiskProperties struct { CloudInitDataSource common.CloudInitDataSource `json:"cloudInitDataSource,omitempty"` // Container name ContainerName *string `json:"containername,omitempty"` + // Disable High Availability + DisableHighAvailability *bool `json:"disableHighAvailability,omitempty"` } // VirtualHardDisk defines the structure of a VHD @@ -72,6 +74,8 @@ type ContainerProperties struct { // State - State Statuses map[string]*string `json:"statuses"` *ContainerInfo `json:"info"` + // Disable High Availability + DisableHighAvailability *bool `json:"disableHighAvailability,omitempty"` } // Container defines the structure of a VHD diff --git a/services/storage/virtualharddisk/virtualharddisk.go b/services/storage/virtualharddisk/virtualharddisk.go index 08d624022..c80034874 100644 --- a/services/storage/virtualharddisk/virtualharddisk.go +++ b/services/storage/virtualharddisk/virtualharddisk.go @@ -58,6 +58,10 @@ func getWssdVirtualHardDisk(c *storage.VirtualHardDisk, groupName, containerName wssdvhd.CloudInitDataSource = c.CloudInitDataSource } + + if c.DisableHighAvailability != nil { + wssdvhd.DisableHighAvailability = *c.DisableHighAvailability + } return wssdvhd, nil } @@ -82,6 +86,7 @@ func getVirtualHardDisk(c *wssdcloudstorage.VirtualHardDisk, group string) *stor HyperVGeneration: c.HyperVGeneration, DiskFileFormat: c.DiskFileFormat, ContainerName: &c.ContainerName, + DisableHighAvailability: &c.DisableHighAvailability, }, Tags: tags.ProtoToMap(c.Tags), } From baa323f8e6125c409ed61280c705237d46c99eeb Mon Sep 17 00:00:00 2001 From: msanjive-21 Date: Wed, 26 Jun 2024 09:11:34 -0700 Subject: [PATCH 2/2] Add HA/Non-HA support checks --- services/compute/galleryimage/galleryimage.go | 7 +++++++ services/storage/container/container.go | 3 +++ 2 files changed, 10 insertions(+) diff --git a/services/compute/galleryimage/galleryimage.go b/services/compute/galleryimage/galleryimage.go index 2d01f7bd0..75e747ddd 100644 --- a/services/compute/galleryimage/galleryimage.go +++ b/services/compute/galleryimage/galleryimage.go @@ -32,6 +32,13 @@ func getWssdGalleryImage(c *compute.GalleryImage, locationName, imagePath string if c.DisableHighAvailability != nil { wssdgalleryimage.DisableHighAvailability = *c.DisableHighAvailability + // If HA is disabled, then throw error + if wssdgalleryimage.DisableHighAvailability { + return nil, errors.Wrapf(errors.NotSupported, "GalleryImage currently does not support Non-HighAvailability mode") + } + } else { + // If no value specified, set value as false + wssdgalleryimage.DisableHighAvailability = false } if c.GalleryImageProperties != nil { diff --git a/services/storage/container/container.go b/services/storage/container/container.go index b3db5f7f5..5e8b5cd2d 100644 --- a/services/storage/container/container.go +++ b/services/storage/container/container.go @@ -43,6 +43,9 @@ func getWssdContainer(c *storage.Container, locationName string) (*wssdcloudstor if c.DisableHighAvailability != nil { wssdcontainer.DisableHighAvailability = *c.DisableHighAvailability + } else { + // If HighAvailability mode isn't specified, proceed with default behavior i.e., HA + wssdcontainer.DisableHighAvailability = false } return wssdcontainer, nil