Skip to content
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

Merged
merged 12 commits into from
Sep 20, 2024
Merged

Conversation

hebelsan
Copy link
Contributor

@hebelsan hebelsan commented Aug 1, 2024

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:

Adds the ability to attach dataDisks with image references

@gardener-robot gardener-robot added needs/review Needs review size/m Size of pull request is medium (see gardener-robot robot/bots/size.py) labels Aug 1, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 1, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 1, 2024
@hebelsan hebelsan marked this pull request as ready for review August 1, 2024 13:48
@hebelsan hebelsan requested review from a team as code owners August 1, 2024 13:48
@hebelsan
Copy link
Contributor Author

hebelsan commented Aug 2, 2024

Copy link
Contributor

@rishabh-11 rishabh-11 left a 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.

pkg/azure/access/helpers/disk.go Show resolved Hide resolved
@@ -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"`
Copy link
Contributor

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

@@ -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) {
Copy link
Contributor

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?

Comment on lines 639 to 644
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,
}
Copy link
Contributor

@rishabh-11 rishabh-11 Aug 12, 2024

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?

Copy link
Contributor Author

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.

@gardener-robot gardener-robot added the needs/changes Needs (more) changes label Aug 12, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 13, 2024
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 13, 2024
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 13, 2024
@gardener-robot-ci-3 gardener-robot-ci-3 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 13, 2024
@rishabh-11 rishabh-11 assigned unmarshall and unassigned rishabh-11 Aug 19, 2024
pkg/azure/api/validation/validation_test.go Outdated Show resolved Hide resolved
pkg/azure/provider/helpers/connectconfig_test.go Outdated Show resolved Hide resolved
pkg/azure/provider/helpers/driver.go Outdated Show resolved Hide resolved
pkg/azure/provider/helpers/driver.go Outdated Show resolved Hide resolved
pkg/azure/provider/helpers/driver.go Outdated Show resolved Hide resolved
pkg/azure/provider/helpers/driver.go Show resolved Hide resolved
pkg/azure/provider/helpers/driver.go Show resolved Hide resolved
Tags: utils.CreateResourceTags(providerSpec.Tags),
Zones: getZonesFromProviderSpec(providerSpec),
}
err = setDiskImageReference(ctx, &params, specDataDisk, providerSpec.Location, factory, connectConfig)
Copy link
Contributor

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.

return
}

func setDiskImageReference(ctx context.Context, disk *armcompute.Disk, specDataDisk api.AzureDataDisk, location string, factory access.Factory, connectConfig access.ConnectConfig) error {
Copy link
Contributor

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.

Copy link
Contributor Author

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.

pkg/azure/provider/provider.go Show resolved Hide resolved
@unmarshall unmarshall added reviewed/do-not-merge Has no approval for merging as it may break things, be of poor quality or have (ext.) dependencies status/on-hold Issue on hold (e.g. because work was suspended) labels Aug 23, 2024
@gardener-robot gardener-robot added the needs/rebase Needs git rebase label Aug 28, 2024
@gardener-robot
Copy link

@hebelsan You need rebase this pull request with latest master branch. Please check.

@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2024
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 28, 2024
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Sep 13, 2024
@hebelsan
Copy link
Contributor Author

I tested the DeleteMachine by locally manipulating the createMachine function so it would always fail.
Then I created a shoot with two vms and verified that two disks and two nics got created although the vm creation failed.
After patching the shoot to only one vm, only one disk and one nic remained left.
I guess that should verify that in case of a failed vm the deletion still works as expected.

@hebelsan
Copy link
Contributor Author

/hold just did a test which should successfully create a VM but it got stuck in "creating"

@hebelsan
Copy link
Contributor Author

Found the issue of my setup.
The machine was stuck in creation because I used the following dataVolume image:
communityGalleryImageID: /CommunityGalleries/gardenlinux-13e998fe-534d-4b0a-8a27-f16a73aef620/Images/gardenlinux/Versions/1443.5.0
which was probably too old...
after switching to:
communityGalleryImageID: /CommunityGalleries/gardenlinux-13e998fe-534d-4b0a-8a27-f16a73aef620/Images/gardenlinux/Versions/1443.10.0
everything worked as expected.

@hebelsan hebelsan removed the reviewed/do-not-merge Has no approval for merging as it may break things, be of poor quality or have (ext.) dependencies label Sep 17, 2024
@hebelsan
Copy link
Contributor Author

/unhold

Copy link
Contributor

@rishabh-11 rishabh-11 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@gardener-robot gardener-robot added reviewed/lgtm Has approval for merging needs/changes Needs (more) changes and removed needs/changes Needs (more) changes needs/rebase Needs git rebase needs/review Needs review labels Sep 20, 2024
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Sep 20, 2024
@gardener-robot gardener-robot removed the reviewed/lgtm Has approval for merging label Sep 20, 2024
Copy link
Contributor

@unmarshall unmarshall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@gardener-robot gardener-robot added reviewed/lgtm Has approval for merging and removed needs/changes Needs (more) changes labels Sep 20, 2024
@rishabh-11 rishabh-11 merged commit 99303ed into gardener:master Sep 20, 2024
7 checks passed
@gardener-robot gardener-robot added status/closed Issue is closed (either delivered or triaged) and removed status/on-hold Issue on hold (e.g. because work was suspended) labels Sep 20, 2024
@YakovKugel
Copy link

Hello @rishabh-11, congratulations on merging that feature! Could you please say when it will be available in Gardener Canary ?

@kon-angelo
Copy link
Contributor

@YakovKugel it will come with the next release of https://github.com/gardener/gardener-extension-provider-azure probably in the next couple weeks.

@YakovKugel
Copy link

YakovKugel commented Oct 31, 2024

Hello @rishabh-11 , is that feature already in Gardener Canary and we could use ?

@hebelsan hebelsan deleted the vsmp branch October 31, 2024 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/lgtm Has approval for merging reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) size/m Size of pull request is medium (see gardener-robot robot/bots/size.py) status/closed Issue is closed (either delivered or triaged)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants