Skip to content

Commit

Permalink
Merge branch 'projectcalico:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Behnam-Shobiri authored Jun 28, 2023
2 parents 93416f7 + 8234b36 commit 9f8d233
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 31 deletions.
16 changes: 3 additions & 13 deletions felix/bpf/maps/maps.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions felix/bpf/maps/syscall.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions felix/bpf/ut/bpf_prog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
2 changes: 1 addition & 1 deletion node/pkg/cni/token_watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions node/pkg/lifecycle/shutdown/shutdown.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
Expand Down
5 changes: 3 additions & 2 deletions node/pkg/lifecycle/startup/startup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions pod2daemon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -231,20 +231,20 @@ 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
# run this target for alpha / beta / release candidate builds, or patches to earlier Calico versions.
## 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)

0 comments on commit 9f8d233

Please sign in to comment.