AMDEPYC / AMDEPYC/kubernetes-power-manager

Cleanup after deleting the PowerProfile doesn't work if `.spec.name` is different from `.metadata.name`

Aperta
#53 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
bug
Lingua principale
Go
Stelle
5
Fork
4
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### 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`.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.