From 3acfcb30628ed937200a144817f52ee52cfc2e40 Mon Sep 17 00:00:00 2001 From: Peter Hunt Date: Thu, 1 Aug 2019 14:12:32 -0400 Subject: Deduplicate capabilities in generate kube capabilities that were added and dropped were several times duplicated. Fix this Signed-off-by: Peter Hunt --- libpod/kube.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libpod') diff --git a/libpod/kube.go b/libpod/kube.go index 084a3df4f..d46a82856 100644 --- a/libpod/kube.go +++ b/libpod/kube.go @@ -406,18 +406,26 @@ func determineCapAddDropFromCapabilities(defaultCaps, containerCaps []string) *v drop []v1.Capability add []v1.Capability ) + dedupDrop := make(map[string]bool) + dedupAdd := make(map[string]bool) // Find caps in the defaultCaps but not in the container's // those indicate a dropped cap for _, capability := range defaultCaps { if !util.StringInSlice(capability, containerCaps) { - drop = append(drop, v1.Capability(capability)) + if _, ok := dedupDrop[capability]; !ok { + drop = append(drop, v1.Capability(capability)) + dedupDrop[capability] = true + } } } // Find caps in the container but not in the defaults; those indicate // an added cap for _, capability := range containerCaps { if !util.StringInSlice(capability, defaultCaps) { - add = append(add, v1.Capability(capability)) + if _, ok := dedupAdd[string(capability)]; !ok { + add = append(add, v1.Capability(capability)) + dedupAdd[capability] = true + } } } -- cgit v1.2.3-54-g00ecf