diff --git a/felix/bpf/maps/maps.go b/felix/bpf/maps/maps.go index ddb90a4d8ee..c1fce18e431 100644 --- a/felix/bpf/maps/maps.go +++ b/felix/bpf/maps/maps.go @@ -360,7 +360,7 @@ func (b *PinnedMap) Iter(f IterCallback) error { if action == IterDelete { // The previous iteration asked us to delete its key; do that now before we check for the end of // the iteration. - err := DeleteMapEntry(b.MapFD(), keyToDelete, valueSize) + err := DeleteMapEntry(b.MapFD(), keyToDelete) if err != nil && !IsNotExists(err) { return fmt.Errorf("failed to delete map entry: %w", err) } @@ -416,21 +416,11 @@ func (b *PinnedMap) Get(k []byte) ([]byte, error) { } func (b *PinnedMap) Delete(k []byte) error { - valueSize := b.ValueSize - if b.perCPU { - valueSize = b.ValueSize * NumPossibleCPUs() - log.Debugf("Set value size to %v for deleting an entry from Per-CPU map", valueSize) - } - return DeleteMapEntry(b.fd, k, valueSize) + return DeleteMapEntry(b.fd, k) } func (b *PinnedMap) DeleteIfExists(k []byte) error { - valueSize := b.ValueSize - if b.perCPU { - valueSize = b.ValueSize * NumPossibleCPUs() - log.Debugf("Set value size to %v for deleting an entry from Per-CPU map", valueSize) - } - return DeleteMapEntryIfExists(b.fd, k, valueSize) + return DeleteMapEntryIfExists(b.fd, k) } func (b *PinnedMap) updateDeltaEntries() error { diff --git a/felix/bpf/maps/syscall.go b/felix/bpf/maps/syscall.go index 5c6cc66ee26..a6810c887df 100644 --- a/felix/bpf/maps/syscall.go +++ b/felix/bpf/maps/syscall.go @@ -156,10 +156,10 @@ func GetMapInfo(fd FD) (*MapInfo, error) { }, nil } -func DeleteMapEntry(mapFD FD, k []byte, valueSize int) error { - log.Debugf("DeleteMapEntry(%v, %v, %v)", mapFD, k, valueSize) +func DeleteMapEntry(mapFD FD, k []byte) error { + log.Debugf("DeleteMapEntry(%v, %v)", mapFD, k) - err := checkMapIfDebug(mapFD, len(k), valueSize) + err := checkMapIfDebug(mapFD, len(k), -1) if err != nil { return err } @@ -173,8 +173,8 @@ func DeleteMapEntry(mapFD FD, k []byte, valueSize int) error { return nil } -func DeleteMapEntryIfExists(mapFD FD, k []byte, valueSize int) error { - err := DeleteMapEntry(mapFD, k, valueSize) +func DeleteMapEntryIfExists(mapFD FD, k []byte) error { + err := DeleteMapEntry(mapFD, k) if err == unix.ENOENT { // Delete failed because entry did not exist. err = nil diff --git a/felix/bpf/ut/bpf_prog_test.go b/felix/bpf/ut/bpf_prog_test.go index 320afb21a6b..6e3f107f0ab 100644 --- a/felix/bpf/ut/bpf_prog_test.go +++ b/felix/bpf/ut/bpf_prog_test.go @@ -1510,18 +1510,18 @@ func TestJumpMap(t *testing.T) { err = maps.UpdateMapEntry(jumpMapFD, k, v) Expect(err).NotTo(HaveOccurred()) - err = maps.DeleteMapEntry(jumpMapFD, k, 4) + err = maps.DeleteMapEntry(jumpMapFD, k) Expect(err).NotTo(HaveOccurred()) err = maps.UpdateMapEntry(jumpMapFD, k, v) Expect(err).NotTo(HaveOccurred()) - err = maps.DeleteMapEntryIfExists(jumpMapFD, k, 4) + err = maps.DeleteMapEntryIfExists(jumpMapFD, k) Expect(err).NotTo(HaveOccurred()) - err = maps.DeleteMapEntryIfExists(jumpMapFD, k, 4) + err = maps.DeleteMapEntryIfExists(jumpMapFD, k) Expect(err).NotTo(HaveOccurred()) - err = maps.DeleteMapEntry(jumpMapFD, k, 4) + err = maps.DeleteMapEntry(jumpMapFD, k) Expect(err).To(HaveOccurred()) } diff --git a/node/pkg/cni/token_watch.go b/node/pkg/cni/token_watch.go index 91915780b64..ad60157480c 100644 --- a/node/pkg/cni/token_watch.go +++ b/node/pkg/cni/token_watch.go @@ -222,7 +222,7 @@ func Run() { for tu := range tokenChan { logrus.Info("Update of CNI kubeconfig triggered based on elapsed time.") - cfg, err := rest.InClusterConfig() + cfg, err := clientcmd.BuildConfigFromFlags("", os.Getenv("KUBECONFIG")) if err != nil { logrus.WithError(err).Error("Error generating kube config.") continue diff --git a/node/pkg/lifecycle/shutdown/shutdown.go b/node/pkg/lifecycle/shutdown/shutdown.go index 9b80525a70e..21a3fc06cd7 100644 --- a/node/pkg/lifecycle/shutdown/shutdown.go +++ b/node/pkg/lifecycle/shutdown/shutdown.go @@ -19,7 +19,7 @@ import ( log "github.com/sirupsen/logrus" "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" + "k8s.io/client-go/tools/clientcmd" "github.com/projectcalico/calico/node/pkg/lifecycle/utils" ) @@ -43,7 +43,7 @@ func Run() { var clientset *kubernetes.Clientset // If running under kubernetes with secrets to call k8s API - if config, err := rest.InClusterConfig(); err == nil { + if config, err := clientcmd.BuildConfigFromFlags("", os.Getenv("KUBECONFIG")); err == nil { // default timeout is 30 seconds, which isn't appropriate for this kind of // shutdown action because network services, like kube-proxy might not be // running and we don't want to block the full 30 seconds if they are just diff --git a/node/pkg/lifecycle/startup/startup.go b/node/pkg/lifecycle/startup/startup.go index 7d7e1c91784..45b4cb79acb 100644 --- a/node/pkg/lifecycle/startup/startup.go +++ b/node/pkg/lifecycle/startup/startup.go @@ -31,6 +31,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" "k8s.io/client-go/rest" + "k8s.io/client-go/tools/clientcmd" api "github.com/projectcalico/api/pkg/apis/projectcalico/v3" "github.com/projectcalico/api/pkg/lib/numorstring" @@ -129,7 +130,7 @@ func Run() { } // If running under kubernetes with secrets to call k8s API - if config, err := rest.InClusterConfig(); err == nil { + if config, err := clientcmd.BuildConfigFromFlags("", os.Getenv("KUBECONFIG")); err == nil { // default timeout is 30 seconds, which isn't appropriate for this kind of // startup action because network services, like kube-proxy might not be // running and we don't want to block the full 30 seconds if they are just @@ -329,7 +330,7 @@ func MonitorIPAddressSubnets() { if nodeRef := os.Getenv("CALICO_K8S_NODE_REF"); nodeRef != "" { k8sNodeName = nodeRef } - if config, err = rest.InClusterConfig(); err == nil { + if config, err = clientcmd.BuildConfigFromFlags("", os.Getenv("KUBECONFIG")); err == nil { // Create the k8s clientset. clientset, err = kubernetes.NewForConfig(config) if err != nil { diff --git a/pod2daemon/Makefile b/pod2daemon/Makefile index bb75f8c2c0d..cfae9039201 100644 --- a/pod2daemon/Makefile +++ b/pod2daemon/Makefile @@ -231,15 +231,15 @@ release-build: .release-$(VERSION).created $(MAKE) clean image-all RELEASE=true $(MAKE) retag-build-images-with-registries IMAGETAG=$(VERSION) RELEASE=true $(MAKE) retag-build-images-with-registries IMAGETAG=latest RELEASE=true - $(MAKE) FIPS=true retag-build-images-with-registries IMAGETAG=$(VERSION)-fips RELEASE=true LATEST_IMAGE_TAG=latest-fips - $(MAKE) FIPS=true retag-build-images-with-registries RELEASE=true IMAGETAG=latest-fips LATEST_IMAGE_TAG=latest-fips + $(MAKE) FIPS=true BUILD_IMAGES='$(CSI_IMAGE) $(REGISTRAR_IMAGE)' retag-build-images-with-registries IMAGETAG=$(VERSION)-fips RELEASE=true LATEST_IMAGE_TAG=latest-fips + $(MAKE) FIPS=true BUILD_IMAGES='$(CSI_IMAGE) $(REGISTRAR_IMAGE)' retag-build-images-with-registries RELEASE=true IMAGETAG=latest-fips LATEST_IMAGE_TAG=latest-fips touch $@ ## Pushes a github release and release artifacts produced by `make release-build`. release-publish: release-prereqs .release-$(VERSION).published .release-$(VERSION).published: $(MAKE) push-images-to-registries push-manifests IMAGETAG=$(VERSION) RELEASE=$(RELEASE) CONFIRM=$(CONFIRM) - $(MAKE) FIPS=true push-images-to-registries push-manifests IMAGETAG=$(VERSION)-fips RELEASE=$(RELEASE) CONFIRM=$(CONFIRM) + $(MAKE) FIPS=true BUILD_IMAGES='$(CSI_IMAGE) $(REGISTRAR_IMAGE)' push-images-to-registries push-manifests IMAGETAG=$(VERSION)-fips RELEASE=$(RELEASE) CONFIRM=$(CONFIRM) touch $@ # WARNING: Only run this target if this release is the latest stable release. Do NOT @@ -247,4 +247,4 @@ release-publish: release-prereqs .release-$(VERSION).published ## Pushes `latest` release images. WARNING: Only run this for latest stable releases. release-publish-latest: release-prereqs $(MAKE) push-images-to-registries push-manifests IMAGETAG=latest RELEASE=$(RELEASE) CONFIRM=$(CONFIRM) - $(MAKE) FIPS=true push-images-to-registries push-manifests IMAGETAG=$(VERSION)-fips RELEASE=$(RELEASE) CONFIRM=$(CONFIRM) + $(MAKE) FIPS=true BUILD_IMAGES='$(CSI_IMAGE) $(REGISTRAR_IMAGE)' push-images-to-registries push-manifests IMAGETAG=$(VERSION)-fips RELEASE=$(RELEASE) CONFIRM=$(CONFIRM)