-
Notifications
You must be signed in to change notification settings - Fork 6
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
fix: update status with up-to-date agent image #24
Conversation
Signed-off-by: Zespre Chang <zespre.chang@suse.com>
pkg/controller/ippool/controller.go
Outdated
@@ -281,6 +281,8 @@ func (h *Handler) DeployAgent(ipPool *networkv1.IPPool, status networkv1.IPPoolS | |||
} | |||
|
|||
if ipPool.Status.AgentPodRef != nil { | |||
status.AgentPodRef.Image = h.agentImage.String() |
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.
Do we allow the agent image to be not replaced per kind of annotations, for easy debug ?
Seems not; please consider add;
and, better to add a check of deletion timestamp before call h.podClient.Delete
, as last time deleting may not finish yet.
func (h *Handler) MonitorAgent(ipPool *networkv1.IPPool, status networkv1.IPPoolStatus) (networkv1.IPPoolStatus, error) {
...
if agentPod.GetUID() != ipPool.Status.AgentPodRef.UID || agentPod.Spec.Containers[0].Image != ipPool.Status.AgentPodRef.Image {
return status, h.podClient.Delete(agentPod.Namespace, agentPod.Name, &metav1.DeleteOptions{})
}
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.
Currently none. We could support adding an annotation per IPPool object to individually hold back the upgrade for agent.
Thanks for the input!
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.
Tested it, it works well and I'm curious about a question, do we need to add ownerReference in agent pod?
One NIT: I didn't notice the MonitorAgent
this naming will delete unexpected pods, I thought it just collected something like logs or metrics. How is it if add some comments like MonitorAgent checks the agent pod's image information is same as IPPool object. If it's not same, delete agent pod
@Yu-Jack Thanks for your time. IIRC, the built-in OwnerReference does not support referencing objects in other namespaces. So we cannot simply add the reference and let Kubernetes handle the cascade deletion. For |
I have a idea, we could merge |
I was once thinking about the idea you proposed. Still, later, I broke them into two control loops, i.e., This is more like design concepts for Kubernetes controllers. I'm trying to avoid state machine-like design and approaching the idea of orthogonality, if that makes sense. Reference: What the heck are Conditions in Kubernetes controllers? | maelvls dev blog |
It makes more sense, thanks! |
Signed-off-by: Zespre Chang <zespre.chang@suse.com>
Signed-off-by: Zespre Chang <zespre.chang@suse.com>
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.
LGTM, thanks.
Signed-off-by: Zespre Chang <zespre.chang@suse.com>
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.
LGTM, thanks!
IMPORTANT: Please do not create a Pull Request without creating an issue first.
Problem:
The controller does not upgrade agent Pods after the controller is upgraded to a newer version.
Solution:
Make sure the
ippool-register
control loop always update the image handle ofAgentPodRef
for each IPPool object being reconciled so that theippool-agent-monitor
control loop could remove the obsolete agent Pods according to that information.Related Issue:
harvester/harvester#5188
Test plan:
For developers who want to verifying the fix:
harvester-vm-dhcp-controller
experimental add-on with the default value content (should be an empty string) on the clusterAgentReady==True
)harvester-vm-dhcp-controller
Addon object to upgrade to the version you built in step 1, for example:For QAs, there's no need to custom-build the artifacts. Just verify if the fix works by using the
main-head
tag (since the PR will have been merged then). QAs can start from step 2.