-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data disk image reference for vsmp #165
Conversation
Tested with: gardener/gardener-extension-provider-azure#891 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial, set of review comments.
@@ -206,6 +206,8 @@ type AzureDataDisk struct { | |||
StorageAccountType string `json:"storageAccountType,omitempty"` | |||
// DiskSizeGB is the size of an empty disk in gigabytes. | |||
DiskSizeGB int32 `json:"diskSizeGB,omitempty"` | |||
// ImageRef optionally specifies an image source | |||
ImageRef *AzureImageReference `json:"imageRef,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please validate the ImageRef if specified? For Data Disks the validation of image ref is currently missing. Modify the existing validateDataDisks
function in validation.go
for this
pkg/azure/provider/helpers/driver.go
Outdated
@@ -534,12 +540,12 @@ func checkAndAcceptAgreementIfNotAccepted(ctx context.Context, factory access.Fa | |||
} | |||
|
|||
// CreateVM gathers the VM creation parameters and invokes a call to create or update the VM. | |||
func CreateVM(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, providerSpec api.AzureProviderSpec, imageRef armcompute.ImageReference, plan *armcompute.Plan, secret *corev1.Secret, nicID string, vmName string) (*armcompute.VirtualMachine, error) { | |||
func CreateVM(ctx context.Context, factory access.Factory, connectConfig access.ConnectConfig, providerSpec api.AzureProviderSpec, vmImageRef armcompute.ImageReference, plan *armcompute.Plan, secret *corev1.Secret, nicID string, vmName string, imageRefDisks map[DataDiskLun]DiskID) (*armcompute.VirtualMachine, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rename imageRefDisks
to imageRefDiskIDs
everywhere?
pkg/azure/provider/helpers/driver.go
Outdated
vmImagesAccess, err := factory.GetVirtualMachineImagesAccess(connectConfig) | ||
if err != nil { | ||
return status.WrapError(codes.Internal, fmt.Sprintf("Failed to create image access, Err: %v", err), err) | ||
} | ||
image, err := accesshelpers.GetVMImage(ctx, vmImagesAccess, location, imageRef) | ||
if err != nil { | ||
return status.WrapError(codes.Internal, fmt.Sprintf("Failed to get image, Err: %v", err), err) | ||
} | ||
disk.Properties.CreationData.ImageReference = &armcompute.ImageDiskReference{ | ||
ID: image.ID, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part is already there in getVirtualMachineImage
. Why not reuse it? Also, we are using VM images as a disk image. Is that fine?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, I really should make use of getVirtualMachineImage
here.
In regards to your second question:
What do you mean with fine?
I think that is what this feature request is about.
If I understood it correctly they provide us basically two vm images and then boot from one into the other.
pkg/azure/provider/helpers/driver.go
Outdated
Tags: utils.CreateResourceTags(providerSpec.Tags), | ||
Zones: getZonesFromProviderSpec(providerSpec), | ||
} | ||
err = setDiskImageReference(ctx, ¶ms, specDataDisk, providerSpec.Location, factory, connectConfig) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since setDiskImageReference
is the only function that can return an error while constructing Disk creation params, it should be called first before you start to create the struct itself.
pkg/azure/provider/helpers/driver.go
Outdated
return | ||
} | ||
|
||
func setDiskImageReference(ctx context.Context, disk *armcompute.Disk, specDataDisk api.AzureDataDisk, location string, factory access.Factory, connectConfig access.ConnectConfig) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally this should only return an image ID which the caller should use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced the func setDiskImageReference
with createDiskCreationData
.
It now does not tamper on the disk reference anymore.
@hebelsan You need rebase this pull request with latest master branch. Please check. |
I tested the DeleteMachine by locally manipulating the createMachine function so it would always fail. |
/hold just did a test which should successfully create a VM but it got stuck in "creating" |
Found the issue of my setup. |
/unhold |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Hello @rishabh-11, congratulations on merging that feature! Could you please say when it will be available in Gardener Canary ? |
@YakovKugel it will come with the next release of https://github.com/gardener/gardener-extension-provider-azure probably in the next couple weeks. |
Hello @rishabh-11 , is that feature already in Gardener Canary and we could use ? |
What this PR does / why we need it:
Adds the ability to attach dataDisks with image references.
Which issue(s) this PR fixes:
Related to: gardener/gardener-extension-provider-azure#788
Special notes for your reviewer:
For now it's not possible to create a dataDisk with imageReference afaik.
Therefore we create a general Disk with the imageReference before creating the VM.
This disk is then attached in the VM creation process.
Release note: