Skip to content

Commit

Permalink
puts podUID!="" into IsNotPod
Browse files Browse the repository at this point in the history
Fixes lint

Signed-off-by: Christian Görg <christian.goerg@trumpf.com>
  • Loading branch information
goergch committed Jul 27, 2022
1 parent d4eccac commit 2579119
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/agent/plugin/workloadattestor/k8s/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (p *Plugin) Attest(ctx context.Context, req *workloadattestorv1.AttestReque
var attestResponse *workloadattestorv1.AttestResponse
for _, item := range list.Items {
item := item
if podUID != "" && isNotPod(item.UID, podUID) {
if isNotPod(item.UID, podUID) {
continue
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/plugin/workloadattestor/k8s/k8s_posix.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,5 +177,5 @@ func canonicalizePodUID(uid string) types.UID {
}

func isNotPod(itemPodUID, podUID types.UID) bool {
return itemPodUID != podUID
return podUID != "" && itemPodUID != podUID
}
8 changes: 4 additions & 4 deletions pkg/agent/plugin/workloadattestor/k8s/k8s_posix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
const (
kindPodListFilePath = "testdata/kind_pod_list.json"
crioPodListFilePath = "testdata/crio_pod_list.json"
crioPodListDuplicateContainerIdFilePath = "testdata/crio_pod_list_duplicate_containerId.json"
crioPodListDuplicateContainerIDFilePath = "testdata/crio_pod_list_duplicate_containerId.json"

cgPidInPodFilePath = "testdata/cgroups_pid_in_pod.txt"
cgPidInKindPodFilePath = "testdata/cgroups_pid_in_kind_pod.txt"
Expand Down Expand Up @@ -132,7 +132,7 @@ func (s *Suite) TestAttestFailDuplicateContainerId() {
s.startInsecureKubelet()
p := s.loadInsecurePlugin()

s.requireAttestFailWithDuplicateContainerId(p)
s.requireAttestFailWithDuplicateContainerID(p)
}

func (s *Suite) TestAttestWithPidInPodSystemdCgroups() {
Expand Down Expand Up @@ -183,8 +183,8 @@ func (s *Suite) requireAttestSuccessWithCrioPod(p workloadattestor.WorkloadAttes
s.requireAttestSuccess(p, testCrioPodSelectors)
}

func (s *Suite) requireAttestFailWithDuplicateContainerId(p workloadattestor.WorkloadAttestor) {
s.addPodListResponse(crioPodListDuplicateContainerIdFilePath)
func (s *Suite) requireAttestFailWithDuplicateContainerID(p workloadattestor.WorkloadAttestor) {
s.addPodListResponse(crioPodListDuplicateContainerIDFilePath)
s.addCgroupsResponse(cgPidInCrioPodFilePath)
s.requireAttestFailure(p, codes.Internal, "two pods found with same container Id")
}
Expand Down

0 comments on commit 2579119

Please sign in to comment.