-
Notifications
You must be signed in to change notification settings - Fork 500
[Bug] fix: update metaPods cache to use namespace/name as the key #1015
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
cc02721 to
1169792
Compare
pkg/cache/cache_impl.go
Outdated
| func (c *Store) GetPod(podName string) (*v1.Pod, error) { | ||
| metaPod, ok := c.metaPods.Load(podName) | ||
| func (c *Store) GetPod(podName, podNamespace string) (*v1.Pod, error) { | ||
| key := fmt.Sprintf("%s/%s", podNamespace, podName) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
Better to make a util method here.
-
Update error messages as well, for example
fmt.Errorf("pod does not exist in the cache: %s", podName)->fmt.Errorf("key does not exist in the cache: %s", key)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applies to all methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add GeneratePodKey func in util package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
pkg/cache/cache_metrics.go
Outdated
| c.metaPods.Range(func(podName string, metaPod *Pod) bool { | ||
| c.metaPods.Range(func(key string, metaPod *Pod) bool { | ||
| // Split the key into namespace and name | ||
| parts := strings.Split(key, "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can add a util method here as well to check if key is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add ParsePodKey func in util package
|
overall LGTM, couple of nits. |
ff30126 to
af0984e
Compare
Signed-off-by: googs1025 <[email protected]>
kerthcet
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also LGTM, I think namespaced Pod name is enough now, in kubernetes, we may sometimes use pid to avoid conflict.
…lm-project#1015) Signed-off-by: googs1025 <[email protected]>
Pull Request Description
[Please provide a clear and concise description of your changes here]
Previously, the metaPods cache used only the
nameas the key, which could lead tokey collisions when Pods with the same name existed in different namespaces.
This pr updates cache to use
namespace/nameas the key, ensuring uniquenessand avoiding potential conflicts. This aligns with Kubernetes' common practice of
using
namespace/nameto uniquely identify resources.Related Issues
Resolves: #1008
Important: Before submitting, please complete the description above and review the checklist below.
Contribution Guidelines (Expand for Details)
We appreciate your contribution to aibrix! To ensure a smooth review process and maintain high code quality, please adhere to the following guidelines:
Pull Request Title Format
Your PR title should start with one of these prefixes to indicate the nature of the change:
[Bug]: Corrections to existing functionality[CI]: Changes to build process or CI pipeline[Docs]: Updates or additions to documentation[API]: Modifications to aibrix's API or interface[CLI]: Changes or additions to the Command Line Interface[Misc]: For changes not covered above (use sparingly)Note: For changes spanning multiple categories, use multiple prefixes in order of importance.
Submission Checklist
By submitting this PR, you confirm that you've read these guidelines and your changes align with the project's contribution standards.