Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Commit 3baf031

Browse files
Casey CallendrelloCasey Callendrello
authored andcommitted
Skip pods not created by the kubelet.
1 parent 9aeef42 commit 3baf031

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

rktlet/runtime/helpers.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,13 @@ func generateAppSandboxCommand(req *runtimeApi.RunPodSandboxRequest, uuidfile, s
394394
return cmd
395395
}
396396

397+
// isKubernetesPod determines if the pod is actually owned by Kubernetes.
398+
// It checks for critical annotations.
399+
func isKubernetesPod(pod *rkt.Pod) bool {
400+
_, ok := pod.UserAnnotations[kubernetesReservedAnnoPodUid]
401+
return ok
402+
}
403+
397404
func getKubernetesMetadata(annotations map[string]string) (*runtimeApi.PodSandboxMetadata, error) {
398405
podUid := annotations[kubernetesReservedAnnoPodUid]
399406
podName := annotations[kubernetesReservedAnnoPodName]

rktlet/runtime/pod_sandbox.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ func (r *RktRuntime) ListPodSandbox(ctx context.Context, req *runtimeApi.ListPod
193193
sandboxes := make([]*runtimeApi.PodSandbox, 0, len(pods))
194194
for i, _ := range pods {
195195
p := pods[i]
196+
if !isKubernetesPod(&p) {
197+
glog.V(6).Infof("Skipping non-kubernetes pod %s", p.UUID)
198+
continue
199+
}
196200
sandboxStatus, err := toPodSandboxStatus(&p)
197201
if err != nil {
198202
return nil, fmt.Errorf("error converting the status of pod sandbox %v: %v", p.UUID, err)

rktlet/runtime/rkt_runtime.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,10 @@ func (r *RktRuntime) ListContainers(ctx context.Context, req *runtimeApi.ListCon
189189
var containers []*runtimeApi.Container
190190
for _, p := range pods {
191191
p := p
192+
if !isKubernetesPod(&p) {
193+
glog.V(6).Infof("Skipping non-kubernetes pod %s", p.UUID)
194+
continue
195+
}
192196
for _, appName := range p.AppNames {
193197
if strings.HasPrefix(appName, internalAppPrefix) {
194198
continue

0 commit comments

Comments
 (0)