AMDEPYC / AMDEPYC/kubernetes-power-manager
Cleanup after deleting the PowerProfile doesn't work if `.spec.name` is different from `.metadata.name`
- Dominant language
- Go
- Stars
- 5
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
### Prerequisites
1. Power Node Agent is running on the worker node.
2. Shared PowerWorkload is created for the worker node.
### Steps to reproduce
1. Create a PowerProfile where `.spec.name` is different from `.metadata.name`.
```bash
kubectl apply -f - << 'EOF'
apiVersion: power.intel.com/v1
kind: PowerProfile
metadata:
name: foo
namespace: power-manager
spec:
name: bar
epp: performance
EOF
```
2. Get the PowerWorkload created for the worker node (epycpwr01 in the example below).
```bash
kubectl -n power-manager get powerworkload bar-epycpwr01 -o yaml
```
3. Delete the PowerProfile.
```bash
$ kubectl -n power-manager delete powerprofile foo
powerprofile.power.intel.com "foo" deleted
```
4. Get the PowerWorkload again.
```bash
kubectl -n power-manager get powerworkload bar-epycpwr01 -o yaml
```
### Expected result
PowerWorkload has been deleted.
### Actual result
PowerWorkload still exists.
### Root cause
The PowerProfile controller derives names of created resources from `.spec.name`.
https://github.com/AMDEPYC/kubernetes-power-manager/blob/93fd3a1dc6e065eb0b53fb703fbc4efa198bf6d8/internal/controller/powerprofile_controller.go#L247-L347
But after deleting the PowerProfile, the controller doesn't have access to `.spec.name` anymore, so it uses `.metadata.name` instead to find the resources to delete. If `.spec.name` was different from `.metadata.name`, no resources will be found.
https://github.com/AMDEPYC/kubernetes-power-manager/blob/93fd3a1dc6e065eb0b53fb703fbc4efa198bf6d8/internal/controller/powerprofile_controller.go#L108-L170
### Workaround
Use the same value for `.spec.name` and `.metadata.name`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.