Skip to content

GetSandboxPodIP seems not right #189

@hzxuzhonghu

Description

@hzxuzhonghu

It can get ip from a providing pod, but if we look into agent-sandbox project, we can see if no warmpool used, the sandbox created by agentcube will be be patched SanboxPodNameAnnotation, that means no pod can be found from it.

if podName, exists := createdSandbox.Annotations[controllers.SanboxPodNameAnnotation]; exists {
sandboxPodName = podName
}
podIP, err := s.k8sClient.GetSandboxPodIP(ctx, sandbox.Namespace, sandbox.Name, sandboxPodName)

The GetSandboxPodIP falls back to list by label selector

pods, err := c.podLister.Pods(namespace).List(labels.SelectorFromSet(map[string]string{SandboxNameLabelKey: sandboxName}))

Yes, for sandbox creating, it set SandboxNameLabelKey

sandbox.Spec.PodTemplate.ObjectMeta.Labels[SandboxNameLabelKey] = params.sandboxName

But for sandboxClaim case, we donot set this label.

There will be a case, like sandboxclaim is created, but we cannot find the pod

pod, err := c.podLister.Pods(namespace).Get(podName)
Maybe because of cache not synced back yet. We would meet an error.

I think #185 is related @YaoZengzeng

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions