You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "pjfanning (via GitHub)" <gi...@apache.org> on 2026/10/08 12:00:46 UTC
[PR] Do not keep underscores when sanitising Kubernetes resource paths [pekko-management]
pjfanning opened a new pull request, #1003:
URL: https://github.com/apache/pekko-management/pull/1003
### Motivation
The lease and PodCost path sanitisers strip characters with the regex `[^\d\w\-\.]`. `\w` matches `_`, so underscores are kept even though Kubernetes resource names (RFC 1123 subdomains) don't allow them.
### Modification
Replace `\w` with an explicit `a-zA-Z` class in:
- lease `KubernetesApiImpl.pathForLease` and `NativeKubernetesApiImpl.pathForLease`
- rolling-update `KubernetesApiImpl.pathForPodCostResource`
### Result
Underscores are removed from the request path like any other invalid character.
- Lease names already go through `makeDNS1039Compatible` before they reach the API, so lease paths don't change in practice.
- A user-set `custom-resource.cr-name` containing `_` is still sent as `metadata.name`, which the API server already rejected. Behaviour that works today is unaffected.
Note: #1002 touches the same lines (precompiling these regexes). Whichever merges second will need a trivial rebase.
### Tests
- New path tests in lease `KubernetesApiSpec` and `NativeKubernetesApiSpec`, and in rolling-update `KubernetesApiSpec` (the rolling-update test checks the DELETE URL that was sent, because a 404 also returns `Done`). All three fail before the fix and pass after.
- `sbt lease-kubernetes/test`: 122 passed
- `sbt rolling-update-kubernetes/test`: 20 passed
- `sbt scalafmtCheckAll`: passed
- MiMa not run: only method bodies changed
### References
Follow-up from review of #1002
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Do not keep underscores when sanitising Kubernetes resource paths [pekko-management]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on PR #1003:
URL: https://github.com/apache/pekko-management/pull/1003#issuecomment-6077323154
Thanks @Philippus - I applied your suggestions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Do not keep underscores when sanitising Kubernetes resource paths [pekko-management]
Posted by "Philippus (via GitHub)" <gi...@apache.org>.
Philippus commented on code in PR #1003:
URL: https://github.com/apache/pekko-management/pull/1003#discussion_r4227904956
##########
lease-kubernetes/src/test/scala/org/apache/pekko/coordination/lease/kubernetes/KubernetesApiSpec.scala:
##########
@@ -208,9 +208,9 @@ class KubernetesApiSpec
response shouldEqual Left(LeaseResource(Some(conflictedOwner), updatedVersion, timestamp))
}
- "strip characters that are not allowed in a resource name from the lease path" in {
+ "strip characters that are not valid in a resource name, including underscores, from the lease path" in {
Review Comment:
I don't think we need the emphasis on underscores in the test descriptions.
```suggestion
"strip characters that are not valid in a resource name from the lease path" in {
```
##########
lease-kubernetes/src/test/scala/org/apache/pekko/coordination/lease/kubernetes/NativeKubernetesApiSpec.scala:
##########
@@ -189,9 +189,9 @@ class NativeKubernetesApiSpec
fromRFC3339MicroString(timestamp)))
}
- "strip characters that are not allowed in a resource name from the lease path" in {
+ "strip characters that are not valid in a resource name, including underscores, from the lease path" in {
Review Comment:
```suggestion
"strip characters that are not valid in a resource name from the lease path" in {
```
##########
rolling-update-kubernetes/src/test/scala/org/apache/pekko/rollingupdate/kubernetes/KubernetesApiSpec.scala:
##########
@@ -238,5 +241,12 @@ class KubernetesApiSpec
kubernetesApi.readRevision().futureValue should be("1")
}
}
+
+ "strip characters that are not valid in a resource name, including underscores, from the PodCost path" in {
Review Comment:
```suggestion
"strip characters that are not valid in a resource name from the PodCost path" in {
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
Re: [PR] Do not keep underscores when sanitising Kubernetes resource paths [pekko-management]
Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning merged PR #1003:
URL: https://github.com/apache/pekko-management/pull/1003
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org