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

hyperv: fix machine rm -r #22140

Merged
merged 1 commit into from
Mar 26, 2024
Merged

Conversation

baude
Copy link
Member

@baude baude commented Mar 22, 2024

this pr fixes two hyperv bugs. previous podman 5 versions of hyperv failed to actually remove the vm from hyperv when machine rm -f was called.

also fixes an annoying bug where removal of the hyperv ignition entries were failing because this can only be done (with the current api) when the vm is running. new api in latest libhvee fixes this.

Does this PR introduce a user-facing change?

Fixes bug where virtual machines were not deleted on hyperv when using rm -f on an active vm

Copy link
Contributor

openshift-ci bot commented Mar 22, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 22, 2024
@baude
Copy link
Member Author

baude commented Mar 22, 2024

/cherry-pick v5.0

@openshift-cherrypick-robot
Copy link
Collaborator

@baude: once the present PR merges, I will cherry-pick it on top of v5.0 in a new PR and assign it to you.

In response to this:

/cherry-pick v5.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

1 similar comment
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

this pr fixes two hyperv bugs.  previous podman 5 versions of hyperv
failed to actually remove the vm from hyperv when machine rm -f was
called.

also fixes an annoying bug where removal of the hyperv ignition entries
were failing because this can only be done (with the current api) when
the vm is running.  new api in latest libhvee fixes this.

Signed-off-by: Brent Baude <[email protected]>
@baude baude added the No New Tests Allow PR to proceed without adding regression tests label Mar 22, 2024
Copy link

Cockpit tests failed for commit a6ffb56. @martinpitt, @jelly, @mvollmer please check.

Comment on lines +499 to +507
// because the vm is down at this point, we cannot query hyperv for these key value pairs.
// therefore we blindly iterate from 0-50 and delete the key/value pairs. hyperv does not
// raise an error if the key is not present
//
for i := 0; i < 50; i++ {
// this is a well known "key" defined in libhvee and is the vm name
// plus an index starting at 0
key := fmt.Sprintf("%s%d", vm.ElementName, i)
if err := vm.RemoveKeyValuePairNoWait(key); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Ok not like I undersatnd the windows code so consider this non blocking.

First where does this 50 came from? How do we know this is enough or wont change?

Second why is it our task to remove hyper registry keys here, I would think this should be done by the vm.Remove() call in libhvee?

Copy link
Member Author

Choose a reason for hiding this comment

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

the 50 is related to the number of 1023 byte chunks needed to describe the ignition file. windows registry values can only be 1023 bytes long. So, we had to pick a number because you cannot query the vm for how many keys it has when the vm is down ... that is why we had the error before

as for libhvee, it was meant to be a generic library, not something strictly for podman ... i would not object to long term having this code live in there and it just be an API call. But for now, and 5.0.1 plans, this fixes things and puts it behind us.

@mheon
Copy link
Member

mheon commented Mar 25, 2024

LGTM

@n1hility
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Mar 26, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 5c39ddc into containers:main Mar 26, 2024
91 of 94 checks passed
@openshift-cherrypick-robot
Copy link
Collaborator

@baude: #22140 failed to apply on top of branch "v5.0":

Applying: hyperv: fix machine rm -r
Using index info to reconstruct a base tree...
M	go.mod
M	go.sum
M	vendor/modules.txt
Falling back to patching base and 3-way merge...
Auto-merging vendor/modules.txt
Auto-merging go.sum
Auto-merging go.mod
CONFLICT (content): Merge conflict in go.mod
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 hyperv: fix machine rm -r
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick v5.0

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@edsantiago edsantiago mentioned this pull request May 15, 2024
@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Jun 25, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Jun 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. machine No New Tests Allow PR to proceed without adding regression tests release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants