Skip to content

CNV#50738: Doc: Update downstream doc Delete Protection for VMs #90981

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

Merged
merged 1 commit into from
Apr 23, 2025

Conversation

aspauldi
Copy link

@aspauldi aspauldi commented Mar 24, 2025

Version(s): 4.19+

Issues: CNV-50738 and CNV-45952

Links to docs preview:

QE review:

  • QE has approved this change.

Additional information: This PR covers both the CLI (CNV-50738) and the web console (CNV-49592) implementations of the VM delete protection feature. SMEs Javier Cano Cano and Phillip Rhodes and QE engineers Leon Kladnitsky and Geetika Kapoor have all approved this PR.

@openshift-ci openshift-ci bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 24, 2025
@aspauldi aspauldi closed this Mar 24, 2025
@aspauldi aspauldi reopened this Mar 24, 2025
@openshift-ci openshift-ci bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Mar 24, 2025
@aspauldi aspauldi closed this Mar 25, 2025
@aspauldi aspauldi reopened this Mar 25, 2025
@aspauldi aspauldi changed the title CNV#50738: Doc: Update downstream doc Delete Protection for VMs CNV#50738 and HPUX-549: Doc: Update downstream doc Delete Protection for VMs Mar 25, 2025
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 25, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 25, 2025

@aspauldi: This pull request references HPUX-549 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.19.0" version, but no target version was set.

In response to this:

Version(s): 4.19+

Issue: CNV-50738

Link to docs preview:

QE review:

  • QE has approved this change.

Additional information:

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 openshift-eng/jira-lifecycle-plugin repository.

@aspauldi aspauldi changed the title CNV#50738 and HPUX-549: Doc: Update downstream doc Delete Protection for VMs CNV#50738 and CNV-45952: Doc: Update downstream doc Delete Protection for VMs Mar 25, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 25, 2025

@aspauldi: This pull request references CNV-45952 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "4.19.0" version, but no target version was set.

In response to this:

Version(s): 4.19+

Issue: CNV-50738

Link to docs preview:

QE review:

  • QE has approved this change.

Additional information:

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 openshift-eng/jira-lifecycle-plugin repository.

@aspauldi aspauldi changed the title CNV#50738 and CNV-45952: Doc: Update downstream doc Delete Protection for VMs CNV#50738 and CNV#45952: Doc: Update downstream doc Delete Protection for VMs Mar 25, 2025
@openshift-ci-robot openshift-ci-robot removed the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 25, 2025
@openshift-ci-robot
Copy link

@aspauldi: No Jira issue is referenced in the title of this pull request.
To reference a jira issue, add 'XYZ-NNN:' to the title of this pull request and request another refresh with /jira refresh.

In response to this:

Version(s): 4.19+

Issue: CNV-50738

Link to docs preview:

QE review:

  • QE has approved this change.

Additional information:

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 openshift-eng/jira-lifecycle-plugin repository.

@aspauldi aspauldi changed the title CNV#50738 and CNV#45952: Doc: Update downstream doc Delete Protection for VMs CNV#50738 and CNV#49592: Doc: Update downstream doc Delete Protection for VMs Mar 25, 2025
Copy link

@jcanocan jcanocan left a comment

Choose a reason for hiding this comment

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

As general comment, I would state that the VM delete protection is off by default or is an opt-in feature.

Also, I think we should include a section of opt-out VM delete protection entirely. In other words, how can cluster admins can prevent cluster users to enable this feature in their deployments.

@aspauldi aspauldi changed the title CNV#50738 and CNV#49592: Doc: Update downstream doc Delete Protection for VMs CNV#50738: Doc: Update downstream doc Delete Protection for VMs Mar 26, 2025
@openshift-ci openshift-ci bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 2, 2025
// * virt/managing-vms/virt-enabling-disabling-vm-delete-protection.adoc

:_mod-docs-content-type: PROCEDURE
[id="virt-removing-vm-delete-protection{context}"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤖 [error] OpenShiftAsciiDoc.IdHasContextVariable: ID is missing the '_{context}' variable at the end of the ID.


= Removing the virtual machine delete protection option

When you enable delete protection on a VM (virtual machine), you ensure that the VM cannot be inadvertently deleted. You can also choose to disable the protection for a VM.
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤖 [error] RedHat.Spacing: Keep one space between words in 'deleted. You'. For more information, see RedHat.Spacing.

+
.Example configuration file
[source,yaml]
----
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤖 [error] AsciiDoc.ValidCodeBlocks: Unterminated listing block found in file.

Copy link
Contributor

Choose a reason for hiding this comment

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

When I lint this YAML file, I get the following error:

Missing closing "quote at line 17, column 170
Implicit keys need to be on a single line at line 18, column 5

Looks like it could use a check-over.

Copy link
Author

Choose a reason for hiding this comment

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

Checking again with Javier. The YAML file had an issue earlier, and Javier provide a new file. Not sure what the issue is now.

Choose a reason for hiding this comment

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

Let's try like this now:

apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingAdmissionPolicy
metadata:
  name: "disable-vm-delete-protection"
spec:
  failurePolicy: Fail
  matchConstraints:
    resourceRules:
    - apiGroups:   ["kubevirt.io"]
      apiVersions: ["*"]
      operations:  ["UPDATE", "CREATE"]
      resources:   ["virtualmachines"]
  variables:
    - expression: string('kubevirt.io/vm-delete-protection')
      name: vmDeleteProtectionLabel
  validations:
  - expression: >- 
      !has(object.metadata.labels) || 
      !object.metadata.labels.exists(label, label == variables.vmDeleteProtectionLabel) || 
      has(oldObject.metadata.labels) &&
      oldObject.metadata.labels.exists(label, label == variables.vmDeleteProtectionLabel)
    message: "Virtual Machine delete protection feature is disabled"

----


apiVersion: admissionregistration.k8s.io/v1
Copy link
Collaborator

Choose a reason for hiding this comment

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

🤖 [error] RedHat.TermsErrors: Use 'Kubernetes' rather than 'k8s'. For more information, see RedHat.TermsErrors.

Copy link
Author

Choose a reason for hiding this comment

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

CNV docs use k8s all over the place, so no change made here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, @aireilly is that a new bug in CI? I've never seen this pop up as an error in the apiVersion field before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link

@jcanocan jcanocan left a comment

Choose a reason for hiding this comment

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

This is looking great! Just a couple of suggestions.


= Enabling or disabling virtual machine delete protection by using the command line

To prevent the inadvertent deletion of a virtual machine, you can enable virtual machine delete protection by using the command line. The feature is disabled by default.
Copy link

Choose a reason for hiding this comment

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

Suggested change
To prevent the inadvertent deletion of a virtual machine, you can enable virtual machine delete protection by using the command line. The feature is disabled by default.
To prevent the inadvertent deletion of a virtual machine, you can enable virtual machine delete protection by using the command line. Virtual machines are not delete protected by default.

Feel free to ignore this suggestion. But I feel that this may lead to think that you need to enable the feature cluster-wide and then enable the protection for each vm.


= Enabling or disabling virtual machine delete protection by using the web console

To prevent the inadvertent deletion of a virtual machine, you can enable virtual machine delete protection by using the {product-title} web console. The feature is disabled by default.
Copy link

Choose a reason for hiding this comment

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

Same as above.

@jcanocan
Copy link

jcanocan commented Apr 4, 2025

Thanks for all effort @aspauldi!
IHMO, it looks awesome! 😊

@openshift-ci openshift-ci bot added the CNV Label for all CNV PRs label Apr 15, 2025
@bergerhoffer
Copy link
Contributor

/label peer-review-in-progress

@openshift-ci openshift-ci bot added the peer-review-in-progress Signifies that the peer review team is reviewing this PR label Apr 15, 2025
Copy link
Contributor

@bergerhoffer bergerhoffer left a comment

Choose a reason for hiding this comment

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

A few bits of feedback, let me know if you have any questions!


When you enable delete protection on a VM (virtual machine), you ensure that the VM cannot be inadvertently deleted. You can also choose to disable the protection for a VM.

As a cluster administrator, you can choose not to make the VM delete protection option available. VMs with delete protection already enabled retain that setting; for any new VMs that are created, enabling the option is not allowed.
Copy link
Contributor

Choose a reason for hiding this comment

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

"choose not to make" sounds a little wordy. Maybe something like this?

Also a suggestion for the second sentence.

Suggested change
As a cluster administrator, you can choose not to make the VM delete protection option available. VMs with delete protection already enabled retain that setting; for any new VMs that are created, enabling the option is not allowed.
As a cluster administrator, you can remove the VM delete protection option completely. VMs with delete protection already enabled retain that setting; any new VMs that are created do not have delete protection as an option.

Copy link
Contributor

Choose a reason for hiding this comment

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

@aspauldi Looks like this comment was missed.

validationActions: [Deny]
matchResources:
----

Copy link
Contributor

Choose a reason for hiding this comment

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

This procedure only creates the YAML files - it doesn't actually apply them to the cluster. I'd recommend adding two more steps for applying them.

Here's an example of another procedure that does this: https://docs.redhat.com/en/documentation/openshift_container_platform/4.18/html-single/security_and_compliance/index#installing-nbde-tang-server-operator-using-cli_installing-nbde-tang-server-operator

Copy link
Author

@aspauldi aspauldi Apr 16, 2025

Choose a reason for hiding this comment

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

@jcanocan and @geetikakay, the documentation peer reviewer Andrea Hoffer recommended adding two steps to this procedure. Can you please take a look and see if what I have added is correct? Thanks! The procedure is documented here: https://90981--ocpdocs-pr.netlify.app/openshift-enterprise/latest/virt/managing_vms/virt-enabling-disabling-vm-delete-protection#virt-removing-vm-delete-protection_virt-enabling-disabling-vm-delete-protection

Copy link

@geetikakay geetikakay Apr 17, 2025

Choose a reason for hiding this comment

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

@aspauldi Sure, I will review again. But I have a quick question:
When enabling vm-delete-protection, we patch the VM with a label like this:

-- enable labels
$ oc patch vm <vm_name> --type merge -p '{"metadata":{"labels":{"kubevirt.io/vm-delete-protection":"True"}}}' -n

To disable it, there can be two approaches:

  1. Set the label value to "False"

$ oc patch vm <vm_name> --type merge -p '{"metadata":{"labels":{"kubevirt.io/vm-delete-protection":"False"}}}' -n

  1. Remove the label entirely
    $ oc patch vm <vm_name> --type json -p '[{"op": "remove", "path": "/metadata/labels/kubevirt.io~1vm-delete-protection"}]' -n

Should we treat disabling (setting to "False") and removing the label as two different cases? Technically, both result in the same outcomethe protection is no longer enforced. But from a documentation or behavior clarity perspective, does it make sense to distinguish between them?

cc @jcanocan

Copy link
Author

Choose a reason for hiding this comment

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

Hi @geetikakay, I think that we can keep the procedure just to one method to make it easier for the users. Thanks!

Choose a reason for hiding this comment

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

@bergerhoffer's suggestion sounds fine to me! Great idea.
@geetikakay's suggestion makes sense. However, I have chosen the approach of removing the label to keep the final yaml manifest as sort as possible. I tend to agree with @aspauldi. Thanks for the suggestion, nevertheless.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this was done, as I see an oc apply here. Is this resolved?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, the steps were added.

@bergerhoffer
Copy link
Contributor

/label peer-review-done
/remove-label peer-review-needed
/remove-label peer-review-in-progress

@openshift-ci openshift-ci bot added peer-review-done Signifies that the peer review team has reviewed this PR and removed peer-review-needed Signifies that the peer review team needs to review this PR peer-review-in-progress Signifies that the peer review team is reviewing this PR labels Apr 15, 2025
@aspauldi aspauldi force-pushed the CNV-50738 branch 2 times, most recently from 1860b47 to 27fce7c Compare April 21, 2025 15:13
@openshift-ci openshift-ci bot added the merge-review-needed Signifies that the merge review team needs to review this PR label Apr 21, 2025
@aspauldi
Copy link
Author

@geetikakay, can you confirm that you approve this PR? Thanks.

@ShaunaDiaz ShaunaDiaz removed the merge-review-needed Signifies that the merge review team needs to review this PR label Apr 21, 2025
Copy link
Contributor

@ShaunaDiaz ShaunaDiaz left a comment

Choose a reason for hiding this comment

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

Couple of pre-merge Qs, @aspauldi. Thank you!


When you enable delete protection on a VM (virtual machine), you ensure that the VM cannot be inadvertently deleted. You can also choose to disable the protection for a VM.

As a cluster administrator, you can choose not to make the VM delete protection option available. VMs with delete protection already enabled retain that setting; for any new VMs that are created, enabling the option is not allowed.
Copy link
Contributor

Choose a reason for hiding this comment

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

@aspauldi Looks like this comment was missed.

+
.Example configuration file
[source,yaml]
----
Copy link
Contributor

Choose a reason for hiding this comment

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

When I lint this YAML file, I get the following error:

Missing closing "quote at line 17, column 170
Implicit keys need to be on a single line at line 18, column 5

Looks like it could use a check-over.

validationActions: [Deny]
matchResources:
----

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like this was done, as I see an oc apply here. Is this resolved?

@geetikakay
Copy link

lgtm

@aspauldi
Copy link
Author

@ShaunaDiaz, can you take another look? I believe all the merge review comments have been resolved. Thanks!

Copy link
Contributor

@ShaunaDiaz ShaunaDiaz left a comment

Choose a reason for hiding this comment

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

a few nits; still one unresolved comment from peer review


:_mod-docs-content-type: PROCEDURE
[id="virt-enabling-disabling-vm-delete-protection-cli_{context}"]

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

delete extra line

:_mod-docs-content-type: PROCEDURE
[id="virt-enabling-disabling-vm-delete-protection-cli_{context}"]

= Enabling or disabling virtual machine delete protection by using the command line
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
= Enabling or disabling virtual machine delete protection by using the command line
= Enabling or disabling VM delete protection by using the command line

I think you can get away with VM in the headline since you define it right away in text. Be more scannable for users.


= Enabling or disabling virtual machine delete protection by using the command line

To prevent the inadvertent deletion of a virtual machine (VM), you can enable virtual machine delete protection by using the command line. You can also disable delete protection for a VM.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To prevent the inadvertent deletion of a virtual machine (VM), you can enable virtual machine delete protection by using the command line. You can also disable delete protection for a VM.
To prevent the inadvertent deletion of a virtual machine (VM), you can enable VM delete protection by using the command line. You can also disable delete protection for a VM.

// * virt/managing-vms/virt-enabling-disabling-vm-delete-protection.adoc

:_mod-docs-content-type: PROCEDURE
[id="virt-enabling-disabling-vm-delete-protection-cli_{context}"]
Copy link
Contributor

Choose a reason for hiding this comment

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

IMHO these should be two separate one-command procedures, not a single one. Probably want to modularize these some time later prior to DITA migration.

Copy link
Author

Choose a reason for hiding this comment

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

I can do that in another PR; thanks.


.Prerequisites

* You have installed the {oc-first}.
Copy link
Contributor

Choose a reason for hiding this comment

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

You also need to know the VMs you want to protect or allow to be deleted, right?

Copy link
Author

Choose a reason for hiding this comment

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

Andrea had me remove that prereq in her peer review.

:_mod-docs-content-type: PROCEDURE
[id="virt-enabling-disabling-vm-delete-protection-web_{context}"]

= Enabling or disabling virtual machine delete protection by using the web console
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
= Enabling or disabling virtual machine delete protection by using the web console
= Enabling or disabling VM delete protection by using the web console


= Enabling or disabling virtual machine delete protection by using the web console

To prevent the inadvertent deletion of a virtual machine (VM), you can enable virtual machine delete protection by using the {product-title} web console. You can also disable delete protection for a VM.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
To prevent the inadvertent deletion of a virtual machine (VM), you can enable virtual machine delete protection by using the {product-title} web console. You can also disable delete protection for a VM.
To prevent the inadvertent deletion of a virtual machine (VM), you can enable VM delete protection by using the {product-title} web console. You can also disable delete protection for a VM.

:_mod-docs-content-type: PROCEDURE
[id="virt-removing-vm-delete-protection_{context}"]

= Removing the virtual machine delete protection option
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
= Removing the virtual machine delete protection option
= Removing the VM delete protection option


:_mod-docs-content-type: PROCEDURE
[id="virt-removing-vm-delete-protection_{context}"]

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@openshift-ci openshift-ci bot added the merge-review-needed Signifies that the merge review team needs to review this PR label Apr 22, 2025
Copy link

openshift-ci bot commented Apr 22, 2025

@aspauldi: all tests passed!

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@aspauldi
Copy link
Author

/label merge-review-needed

@jab-rh jab-rh added merge-review-in-progress Signifies that the merge review team is reviewing this PR and removed merge-review-needed Signifies that the merge review team needs to review this PR labels Apr 23, 2025
@jab-rh jab-rh merged commit 81bb74b into openshift:main Apr 23, 2025
2 checks passed
@jab-rh
Copy link
Contributor

jab-rh commented Apr 23, 2025

/cherry-pick enterprise-4.19

@openshift-cherrypick-robot

@jab-rh: new pull request created: #92505

In response to this:

/cherry-pick enterprise-4.19

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-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CNV Label for all CNV PRs merge-review-in-progress Signifies that the merge review team is reviewing this PR peer-review-done Signifies that the peer review team has reviewed this PR size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.