kubeslice / kubeslice/kubeslice-controller
Bug: namespace deletion metrics always recorded with empty project label due to double GetProjectName call
- Dominant language
- Go
- Stars
- 73
- Forks
- 48
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 8
Description
### 📜 Description
`NamespaceService.DeleteNamespace` at line 192 calls `util.GetProjectName(util.GetProjectName(namespace))`. The inner call correctly extracts the project name (e.g., `"cisco"` from `"kubeslice-cisco"`). The outer call receives `"cisco"` which lacks the `"kubeslice-"` prefix and returns `""`. All Prometheus counter metrics for namespace deletion events carry `project=""`. Every other method in `namespace_service.go` calls `GetProjectName` exactly once; this is the only double-wrapped call.
### 👟 Reproduction steps
1. Read `service/namespace_service.go:192` — `n.mf.WithProject(util.GetProjectName(util.GetProjectName(namespace)))`. Compare with every other `WithProject` call in the same file; all use a single `GetProjectName`.
2. At runtime:
- Delete any Project (which triggers `DeleteNamespace`).
- Query Prometheus: `kubeslice_controller_events_total{event="EventNamespaceDeleted"}`.
3. The `project` label is `""` instead of the actual project name.
### 👍 Expected behavior
The `project` label on namespace deletion metrics should equal the actual project name extracted from the namespace string.
### 👎 Actual Behavior
`project=""` on all namespace deletion metrics because the double `GetProjectName` call strips the extracted name back to an empty string.
### 🐚 Relevant log output
```shell
```
### Version
_No response_
### 🖥️ What operating system are you seeing the problem on?
_No response_
### ✅ Proposed Solution
Remove the outer `GetProjectName` wrapper on line 192 so the call reads `util.GetProjectName(namespace)`, matching the pattern used in every other method in the file.
### 👀 Have you spent some time to check if this issue has been raised before?
- [x] I checked and didn't find any similar issue
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct
Contributor guide
Assessment
This issue has not been assessed yet.