Skip to content

feat(vm-storage-labeling): add storage volume labeling role#15

Open
stevefulme1 wants to merge 2 commits intoredhat-cop:mainfrom
stevefulme1:feat/vm-storage-labeling
Open

feat(vm-storage-labeling): add storage volume labeling role#15
stevefulme1 wants to merge 2 commits intoredhat-cop:mainfrom
stevefulme1:feat/vm-storage-labeling

Conversation

@stevefulme1
Copy link
Copy Markdown

Summary

  • Adds new vm_storage_labeling role and playbook to apply labels, annotations, and descriptive names to PersistentVolumeClaims (PVCs) and DataVolumes at the OCP level
  • Supports targeting volumes by name or label selectors for bulk operations (addresses the "100 VMs" use case)
  • Follows existing collection patterns (vm_mac_address, vm_hot_plug) for variable naming, validation, and k8s JSON patch operations
  • If a PVC is owned by a DataVolume, labels/annotations are applied to both resources

Resolves

MFG-251 — Storage Volume Labeling and Naming

Usage Example

vm_storage_labeling_request:
  - namespace: my-vms
    names:
      - vm-disk-001
      - vm-disk-002
    labels:
      app: webserver
      environment: production
    annotations:
      description: "Production web server storage"
  - namespace: dev-vms
    label_selectors:
      - app=legacy
    labels:
      migrated: "true"

Test plan

  • Verify yamllint passes (confirmed locally — warnings only for line-length on playbook env lookups, matching existing patterns)
  • Verify ansible-lint --offline passes production profile (confirmed locally — 0 failures, 0 warnings)
  • Integration test: apply labels to PVCs by name in a test namespace
  • Integration test: apply labels to PVCs by label selector
  • Integration test: verify DataVolume-owned PVCs also patch the DataVolume
  • Verify idempotency — re-running with same labels produces no changes

🤖 Generated with Claude Code

…aming

Add a new role and playbook to apply labels, annotations, and descriptive
names to PersistentVolumeClaims and DataVolumes at the OCP level. Supports
both named volume targeting and label selector-based bulk operations for
managing storage across large VM fleets.

Resolves: MFG-251

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@stevefulme1 stevefulme1 requested a review from sabre1041 as a code owner April 6, 2026 16:24
@stevefulme1 stevefulme1 changed the title feat(vm_storage_labeling): add role for storage volume labeling and naming add role for storage volume labeling and naming Apr 6, 2026
@stevefulme1 stevefulme1 changed the title add role for storage volume labeling and naming feat(vm-storage-labeling): add role for storage volume labeling and naming Apr 6, 2026
@stevefulme1 stevefulme1 changed the title feat(vm-storage-labeling): add role for storage volume labeling and naming feat(vm-storage-labeling): add storage volume labeling role Apr 6, 2026
@sabre1041
Copy link
Copy Markdown
Contributor

@stevefulme1 Would this enhancement be better served within the infra.openshift_virtualization_ops collection instead?

@stevefulme1
Copy link
Copy Markdown
Author

yes can we move the pr there?

@sabre1041
Copy link
Copy Markdown
Contributor

yes can we move the pr there?

Unfortunately, we cannot move the PR over. It would need to be recreated in the other repository

Copy link
Copy Markdown
Contributor

@sabre1041 sabre1041 left a comment

Choose a reason for hiding this comment

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

Works well. Added one comment related to whether names/labels should be required

Let's complete the discussion in this repository and then transfer it to the ops repo

fail_msg: "Required property 'namespace' in 'vm_storage_labeling_request' Variable Not Provided"
quiet: true

- name: Verify Names or Label Selectors Provided
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a need to provide either labels or PVC names? What if we wanted to apply the same labels/annotations to all PVC's in a namespace?

Allow labeling all PVCs in a namespace when neither names nor
label_selectors is provided. Addresses review feedback.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants