-
Notifications
You must be signed in to change notification settings - Fork 142
Prevent accidental IP deallocation in statefulsets #624
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
Prevent accidental IP deallocation in statefulsets #624
Conversation
|
@bpickard22, @thomasferrandiz, PTAL |
Pull Request Test Coverage Report for Build 16272872047Details
💛 - Coveralls |
This commit addresses a potential issue where IP allocations could be accidentally deleted when new pods with the same name and namespace are created in statefulset scenarios. The logic now correctly checks if a pod with the matching name and namespace exists and is not marked for deletion. If such a pod exists, the deallocation is skipped, preventing conflicts. The commit also includes clarified logging messages for improved debugging. Signed-off-by: Marcelo <[email protected]>
7d8e6a3 to
313ddf0
Compare
|
|
||
| // The allocation could belong to a new pod with the same name and namespace. Stateful set scenarios. | ||
| // The previous pod should be gone by the time a pod deletion event is received. | ||
| if newPod, err := pc.k8sClient.CoreV1().Pods(podNamespace).Get(context.TODO(), podName, metav1.GetOptions{}); err == nil { |
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.
should we check if the pod is owned by a statefulset so we dont break the behavior for non stateful deployments?
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.
we can check the ownerref of the pod to see if it is part of a statefulset, if it is we release the ip, if not we proceed to use the existing logic
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.
This doesn't apply to non stateful deployments. Pod name is different.
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.
@maiqueb we can assume the user is following naming conventions i guess
This commit addresses a potential issue where IP allocations could be accidentally deleted when new pods with the same name and namespace are created in statefulset scenarios. The logic now correctly checks if a pod with the matching name and namespace exists and is not marked for deletion. If such a pod exists, the deallocation is skipped, preventing conflicts. The commit also includes clarified logging messages for improved debugging.