From 70e048e1cbb6b948072508a4b9d3602039bbfbc4 Mon Sep 17 00:00:00 2001 From: caseydavenport <1944093+caseydavenport@users.noreply.github.com> Date: Wed, 17 Jun 2026 20:42:23 +0000 Subject: [PATCH] Automatic API update from projectcalico/calico master --- build/update-client-gen.sh | 6 + config/.gitattributes | 1 + .../projectcalico.org_bgpconfigurations.yaml | 10 +- ...projectcalico.org_felixconfigurations.yaml | 32 +- config/crd/projectcalico.org_ipamblocks.yaml | 4 +- deps.txt | 30 +- go.mod | 95 +++-- go.sum | 87 ++-- lib.Makefile | 372 +++++++++++++----- metadata.mk | 53 ++- ...0004-Fix-informer-GVR-plural-strings.patch | 102 +++++ pkg/.gitattributes | 1 + pkg/apis/projectcalico/v3/bgpconfig.go | 10 +- pkg/apis/projectcalico/v3/felixconfig.go | 33 +- .../projectcalico/v3/zz_generated.deepcopy.go | 14 +- .../projectcalico/v3/zz_generated.defaults.go | 19 - pkg/client/.gitattributes | 4 + .../internal/internal.go | 16 +- .../v3/felixconfigurationspec.go | 37 +- .../clientset/fake/clientset_generated.go | 2 +- .../externalversions/factory.go | 110 +++++- .../internalinterfaces/factory_interfaces.go | 19 + .../projectcalico/v3/bgpconfiguration.go | 48 ++- .../projectcalico/v3/bgpfilter.go | 48 ++- .../projectcalico/v3/bgppeer.go | 48 ++- .../projectcalico/v3/blockaffinity.go | 48 ++- .../projectcalico/v3/caliconodestatus.go | 48 ++- .../projectcalico/v3/clusterinformation.go | 48 ++- .../projectcalico/v3/felixconfiguration.go | 48 ++- .../projectcalico/v3/globalnetworkpolicy.go | 48 ++- .../projectcalico/v3/globalnetworkset.go | 48 ++- .../projectcalico/v3/hostendpoint.go | 48 ++- .../projectcalico/v3/ipamblock.go | 48 ++- .../projectcalico/v3/ipamconfiguration.go | 48 ++- .../projectcalico/v3/ipamhandle.go | 48 ++- .../projectcalico/v3/ippool.go | 48 ++- .../projectcalico/v3/ipreservation.go | 48 ++- .../v3/kubecontrollersconfiguration.go | 48 ++- .../projectcalico/v3/networkpolicy.go | 48 ++- .../projectcalico/v3/networkset.go | 48 ++- .../projectcalico/v3/profile.go | 48 ++- .../v3/stagedglobalnetworkpolicy.go | 48 ++- .../v3/stagedkubernetesnetworkpolicy.go | 48 ++- .../projectcalico/v3/stagednetworkpolicy.go | 48 ++- .../externalversions/projectcalico/v3/tier.go | 48 ++- pkg/lib/numorstring/dscp.go | 3 - pkg/openapi/generated.openapi.go | 303 +++++++++++--- 47 files changed, 1722 insertions(+), 745 deletions(-) create mode 100644 config/.gitattributes create mode 100644 patches/0004-Fix-informer-GVR-plural-strings.patch create mode 100644 pkg/.gitattributes delete mode 100644 pkg/apis/projectcalico/v3/zz_generated.defaults.go create mode 100644 pkg/client/.gitattributes diff --git a/build/update-client-gen.sh b/build/update-client-gen.sh index 91d843725..a0bc9978c 100755 --- a/build/update-client-gen.sh +++ b/build/update-client-gen.sh @@ -69,3 +69,9 @@ informer-gen "$@" \ --output-dir "${REPO_ROOT}/pkg/client/informers_generated" \ --output-pkg "github.com/projectcalico/api/pkg/client/informers_generated" \ "github.com/projectcalico/api/pkg/apis/projectcalico/v3" + +# Patch informer-gen bug (see patches/0004-*): the WithInformerName(gvr) +# resource name is built with a naive plural that doesn't match the real +# API plural for 7 v3 types. Will fail loudly once upstream is fixed and +# the patch becomes a no-op. +patch -p2 -d "${REPO_ROOT}" < "${REPO_ROOT}/patches/0004-Fix-informer-GVR-plural-strings.patch" diff --git a/config/.gitattributes b/config/.gitattributes new file mode 100644 index 000000000..17d842d0c --- /dev/null +++ b/config/.gitattributes @@ -0,0 +1 @@ +crd/*.yaml linguist-generated=true diff --git a/config/crd/projectcalico.org_bgpconfigurations.yaml b/config/crd/projectcalico.org_bgpconfigurations.yaml index 3590a345f..ebf7a35a8 100644 --- a/config/crd/projectcalico.org_bgpconfigurations.yaml +++ b/config/crd/projectcalico.org_bgpconfigurations.yaml @@ -82,7 +82,7 @@ spec: x-kubernetes-map-type: atomic maxItems: 500 type: array - x-kubernetes-list-type: set + x-kubernetes-list-type: atomic ignoredInterfaces: description: IgnoredInterfaces indicates the network interfaces that @@ -204,7 +204,7 @@ spec: x-kubernetes-map-type: atomic maxItems: 500 type: array - x-kubernetes-list-type: set + x-kubernetes-list-type: atomic programClusterRoutes: description: |- ProgramClusterRoutes controls how a cluster node gets a route to a workload on another node, @@ -230,7 +230,7 @@ spec: type: object x-kubernetes-map-type: atomic type: array - x-kubernetes-list-type: set + x-kubernetes-list-type: atomic serviceExternalIPs: description: |- ServiceExternalIPs are the CIDR blocks for Kubernetes Service External IPs. @@ -246,7 +246,7 @@ spec: type: object x-kubernetes-map-type: atomic type: array - x-kubernetes-list-type: set + x-kubernetes-list-type: atomic serviceLoadBalancerAggregation: default: Enabled description: |- @@ -273,7 +273,7 @@ spec: type: object x-kubernetes-map-type: atomic type: array - x-kubernetes-list-type: set + x-kubernetes-list-type: atomic type: object x-kubernetes-validations: - message: diff --git a/config/crd/projectcalico.org_felixconfigurations.yaml b/config/crd/projectcalico.org_felixconfigurations.yaml index 5691f46c5..77342d58c 100644 --- a/config/crd/projectcalico.org_felixconfigurations.yaml +++ b/config/crd/projectcalico.org_felixconfigurations.yaml @@ -861,7 +861,9 @@ spec: IptablesMarkMask is the mask that Felix selects its IPTables Mark bits from. Should be a 32 bit hexadecimal number with at least 8 bits set, none of which clash with any other mark bits in use on the system. [Default: 0xffff0000] - format: int32 + format: int64 + maximum: 4294967295 + minimum: 0 type: integer iptablesNATOutgoingInterfaceFilter: description: |- @@ -928,12 +930,14 @@ spec: - Disabled type: string istioDSCPMark: + anyOf: + - type: integer + - type: string description: |- IstioDSCPMark sets the value to use when directing traffic to Istio ZTunnel, when Istio is enabled. The mark is set only on SYN packets at the final hop to avoid interference with other protocols. This value is reserved by Calico and must not be used with other Istio installation. [Default: 23] pattern: ^.* - type: integer x-kubernetes-int-or-string: true kubeNodePortRanges: description: |- @@ -954,6 +958,26 @@ spec: reverting to normal priority. [Default: 30s] pattern: ^([0-9]+(\.[0-9]+)?(ms|s|m|h))*$ type: string + localSubnetL2Reachability: + description: |- + LocalSubnetL2Reachability controls whether Felix automatically responds to + ARP (IPv4) and NDP (IPv6) requests on host interfaces for local pod IPs and + selected LoadBalancer VIPs that fall within the same subnet as the host + interface. When set to PodsAndLoadBalancers, pods and LB VIPs on the host + subnet are reachable from the local L2 segment without BGP. [Default: Disabled] + enum: + - Disabled + - PodsAndLoadBalancers + type: string + localSubnetL2ReachabilityRefreshInterval: + description: |- + LocalSubnetL2ReachabilityRefreshInterval controls how often Felix re-announces + (gratuitous ARP / unsolicited NA) every IP it proxies ARP/NDP for when + LocalSubnetL2Reachability is enabled, keeping neighbor caches and switch + forwarding tables warm even when the set of proxied IPs is unchanged. Set to 0 + to disable periodic re-announcement, leaving only the one-shot announce when an + IP is added. [Default: 120s] + type: string logActionRateLimit: description: |- LogActionRateLimit sets the rate of hitting a Log action. The value must be in the format "N/unit", @@ -1091,7 +1115,9 @@ spec: NftablesMarkMask is the mask that Felix selects its nftables Mark bits from. Should be a 32 bit hexadecimal number with at least 8 bits set, none of which clash with any other mark bits in use on the system. [Default: 0xffff0000] - format: int32 + format: int64 + maximum: 4294967295 + minimum: 0 type: integer nftablesMode: default: Auto diff --git a/config/crd/projectcalico.org_ipamblocks.yaml b/config/crd/projectcalico.org_ipamblocks.yaml index d4bf6eb7c..70cfbe995 100644 --- a/config/crd/projectcalico.org_ipamblocks.yaml +++ b/config/crd/projectcalico.org_ipamblocks.yaml @@ -69,10 +69,8 @@ spec: For non-nil entries at index i, the index is the ordinal of the allocation within this block and the value is the index of the associated attributes in the Attributes array. items: - type: integer - # TODO: This nullable is manually added in. We should update controller-gen - # to handle []*int properly itself. nullable: true + type: integer type: array x-kubernetes-list-type: atomic attributes: diff --git a/deps.txt b/deps.txt index 7a53496cb..89a9e1756 100644 --- a/deps.txt +++ b/deps.txt @@ -1,21 +1,21 @@ !!! GENERATED FILE, DO NOT EDIT !!! Run 'make gen-deps-files' to regenerate. -go 1.26.2 +go 1.26.4 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc github.com/emicklei/go-restful v2.15.0+incompatible github.com/emicklei/go-restful/v3 v3.13.0 github.com/fxamacker/cbor/v2 v2.9.0 github.com/go-logr/logr v1.4.3 -github.com/go-openapi/jsonpointer v0.21.0 -github.com/go-openapi/jsonreference v0.20.2 -github.com/go-openapi/swag v0.23.0 +github.com/go-openapi/jsonpointer v0.22.4 +github.com/go-openapi/jsonreference v0.21.4 +github.com/go-openapi/swag v0.23.1 github.com/google/gnostic-models v0.7.0 github.com/google/uuid v1.6.0 github.com/jinzhu/copier v0.4.0 github.com/josharian/intern v1.0.0 github.com/json-iterator/go v1.1.12 -github.com/mailru/easyjson v0.7.7 +github.com/mailru/easyjson v0.9.1 github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 @@ -25,23 +25,23 @@ github.com/spf13/pflag v1.0.10 github.com/x448/float16 v0.8.4 go.yaml.in/yaml/v2 v2.4.4 go.yaml.in/yaml/v3 v3.0.4 -golang.org/x/net v0.53.0 +golang.org/x/net v0.56.0 golang.org/x/oauth2 v0.36.0 -golang.org/x/sys v0.43.0 -golang.org/x/term v0.42.0 -golang.org/x/text v0.36.0 +golang.org/x/sys v0.46.0 +golang.org/x/term v0.44.0 +golang.org/x/text v0.38.0 golang.org/x/time v0.15.0 -google.golang.org/protobuf v1.36.11 +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af gopkg.in/evanphx/json-patch.v4 v4.13.0 gopkg.in/inf.v0 v0.9.1 gopkg.in/yaml.v3 v3.0.1 -k8s.io/api v0.35.4 -k8s.io/apiextensions-apiserver v0.35.4 -k8s.io/apimachinery v0.35.4 -k8s.io/client-go v0.35.4 +k8s.io/api v0.36.2 +k8s.io/apiextensions-apiserver v0.36.2 +k8s.io/apimachinery v0.36.2 +k8s.io/client-go v0.36.2 k8s.io/klog v0.2.0 k8s.io/klog/v2 v2.140.0 -k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 +k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 sigs.k8s.io/randfill v1.0.0 diff --git a/go.mod b/go.mod index 410cca3c0..6b7c9dab5 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,16 @@ module github.com/projectcalico/api -go 1.26.2 +go 1.26.4 require ( github.com/jinzhu/copier v0.4.0 - github.com/onsi/ginkgo/v2 v2.28.1 - github.com/onsi/gomega v1.39.1 - k8s.io/api v0.35.4 - k8s.io/apiextensions-apiserver v0.35.4 - k8s.io/apimachinery v0.35.4 - k8s.io/client-go v0.35.4 - k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 + github.com/onsi/ginkgo/v2 v2.31.0 + github.com/onsi/gomega v1.42.0 + k8s.io/api v0.36.2 + k8s.io/apiextensions-apiserver v0.36.2 + k8s.io/apimachinery v0.36.2 + k8s.io/client-go v0.36.2 + k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a sigs.k8s.io/structured-merge-diff/v6 v6.4.0 sigs.k8s.io/yaml v1.6.0 ) @@ -18,7 +18,7 @@ require ( require ( github.com/Masterminds/semver/v3 v3.4.0 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/emicklei/go-restful/v3 v3.12.2 // indirect + github.com/emicklei/go-restful/v3 v3.13.0 // indirect github.com/fxamacker/cbor/v2 v2.9.0 // indirect github.com/go-logr/logr v1.4.3 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect @@ -27,7 +27,7 @@ require ( github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/gnostic-models v0.7.0 // indirect github.com/google/go-cmp v0.7.0 // indirect - github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 // indirect + github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect github.com/google/uuid v1.6.0 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect @@ -35,54 +35,53 @@ require ( github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/spf13/pflag v1.0.9 // indirect github.com/x448/float16 v0.8.4 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect - golang.org/x/mod v0.32.0 // indirect - golang.org/x/net v0.49.0 // indirect - golang.org/x/oauth2 v0.30.0 // indirect - golang.org/x/sync v0.19.0 // indirect - golang.org/x/sys v0.40.0 // indirect - golang.org/x/term v0.39.0 // indirect - golang.org/x/text v0.33.0 // indirect - golang.org/x/time v0.9.0 // indirect - golang.org/x/tools v0.41.0 // indirect - google.golang.org/protobuf v1.36.8 // indirect + golang.org/x/mod v0.37.0 // indirect + golang.org/x/net v0.56.0 // indirect + golang.org/x/oauth2 v0.36.0 // indirect + golang.org/x/sync v0.21.0 // indirect + golang.org/x/sys v0.46.0 // indirect + golang.org/x/term v0.44.0 // indirect + golang.org/x/text v0.38.0 // indirect + golang.org/x/time v0.15.0 // indirect + golang.org/x/tools v0.46.0 // indirect + google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af // indirect gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/klog/v2 v2.130.1 // indirect - k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 // indirect + k8s.io/klog/v2 v2.140.0 // indirect + k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 // indirect sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect sigs.k8s.io/randfill v1.0.0 // indirect ) replace ( - k8s.io/api => k8s.io/api v0.35.4 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.35.4 - k8s.io/apimachinery => k8s.io/apimachinery v0.35.4 - k8s.io/apiserver => k8s.io/apiserver v0.35.4 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.35.4 - k8s.io/client-go => k8s.io/client-go v0.35.4 - k8s.io/cloud-provider => k8s.io/cloud-provider v0.35.4 - k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.35.4 - k8s.io/code-generator => k8s.io/code-generator v0.35.4 - k8s.io/component-base => k8s.io/component-base v0.35.4 - k8s.io/component-helpers => k8s.io/component-helpers v0.35.4 - k8s.io/controller-manager => k8s.io/controller-manager v0.35.4 - k8s.io/cri-api => k8s.io/cri-api v0.35.4 - k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.35.4 - k8s.io/externaljwt => k8s.io/externaljwt v0.35.4 - k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.35.4 - k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.35.4 - k8s.io/kube-proxy => k8s.io/kube-proxy v0.35.4 - k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.35.4 - k8s.io/kubectl => k8s.io/kubectl v0.35.4 - k8s.io/kubelet => k8s.io/kubelet v0.35.4 - k8s.io/metrics => k8s.io/metrics v0.35.4 - k8s.io/mount-utils => k8s.io/mount-utils v0.35.4 - k8s.io/node-api => k8s.io/node-api v0.35.4 - k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.35.4 + k8s.io/api => k8s.io/api v0.36.2 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.36.2 + k8s.io/apimachinery => k8s.io/apimachinery v0.36.2 + k8s.io/apiserver => k8s.io/apiserver v0.36.2 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.36.2 + k8s.io/client-go => k8s.io/client-go v0.36.2 + k8s.io/cloud-provider => k8s.io/cloud-provider v0.36.2 + k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.36.2 + k8s.io/code-generator => k8s.io/code-generator v0.36.2 + k8s.io/component-base => k8s.io/component-base v0.36.2 + k8s.io/component-helpers => k8s.io/component-helpers v0.36.2 + k8s.io/controller-manager => k8s.io/controller-manager v0.36.2 + k8s.io/cri-api => k8s.io/cri-api v0.36.2 + k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.36.2 + k8s.io/externaljwt => k8s.io/externaljwt v0.36.2 + k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.36.2 + k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.36.2 + k8s.io/kube-proxy => k8s.io/kube-proxy v0.36.2 + k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.36.2 + k8s.io/kubectl => k8s.io/kubectl v0.36.2 + k8s.io/kubelet => k8s.io/kubelet v0.36.2 + k8s.io/metrics => k8s.io/metrics v0.36.2 + k8s.io/mount-utils => k8s.io/mount-utils v0.36.2 + k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.36.2 ) diff --git a/go.sum b/go.sum index 8c7b26e48..5ccfd2cd4 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/emicklei/go-restful/v3 v3.12.2 h1:DhwDP0vY3k8ZzE0RunuJy8GhNpPL6zqLkDf9B/a0/xU= -github.com/emicklei/go-restful/v3 v3.12.2/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes= +github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM= github.com/fxamacker/cbor/v2 v2.9.0/go.mod h1:vM4b+DJCtHn+zz7h3FFp/hDAI9WNWCsZj23V5ytsSxQ= github.com/gkampitakis/ciinfo v0.3.2 h1:JcuOPk8ZU7nZQjdUhctuhQofk7BGHuIy0c9Ez8BNhXs= @@ -34,8 +34,8 @@ github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7O github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83 h1:z2ogiKUYzX5Is6zr/vP9vJGqPwcdqsWjOt+V8J7+bTc= -github.com/google/pprof v0.0.0-20260115054156-294ebfa9ad83/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= +github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 h1:EwtI+Al+DeppwYX2oXJCETMO23COyaKGP6fHVpkpWpg= +github.com/google/pprof v0.0.0-20260402051712-545e8a4df936/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/jinzhu/copier v0.4.0 h1:w3ciUoD19shMCRargcpm0cm91ytaBhDvuRpz1ODO/U8= @@ -67,12 +67,13 @@ github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee h1:W5t00kpgFd github.com/modern-go/reflect2 v1.0.3-0.20250322232337-35a7c28c31ee/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/onsi/ginkgo/v2 v2.28.1 h1:S4hj+HbZp40fNKuLUQOYLDgZLwNUVn19N3Atb98NCyI= -github.com/onsi/ginkgo/v2 v2.28.1/go.mod h1:CLtbVInNckU3/+gC8LzkGUb9oF+e8W8TdUsxPwvdOgE= -github.com/onsi/gomega v1.39.1 h1:1IJLAad4zjPn2PsnhH70V4DKRFlrCzGBNrNaru+Vf28= -github.com/onsi/gomega v1.39.1/go.mod h1:hL6yVALoTOxeWudERyfppUcZXjMwIMLnuSfruD2lcfg= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/onsi/ginkgo/v2 v2.31.0 h1:GtuJos5DFUV9EerYJo8RhYxosYNGvOdDE5haKq6Grfs= +github.com/onsi/ginkgo/v2 v2.31.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44= +github.com/onsi/gomega v1.42.0 h1:CJby8u36xb7v34W78F8WKvqTQP7PCMIPB78IVDB73l4= +github.com/onsi/gomega v1.42.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/spf13/pflag v1.0.9 h1:9exaQaMOCwffKiiiYk6/BndUBv+iRViNW+4lEMi0PvY= @@ -104,26 +105,26 @@ go.yaml.in/yaml/v2 v2.4.3 h1:6gvOSjQoTB3vt1l+CU+tSyi/HOjfOjRLJ4YwYZGwRO0= go.yaml.in/yaml/v2 v2.4.3/go.mod h1:zSxWcmIDjOzPXpjlTTbAsKokqkDNAVtZO0WOMiT90s8= go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= -golang.org/x/mod v0.32.0 h1:9F4d3PHLljb6x//jOyokMv3eX+YDeepZSEo3mFJy93c= -golang.org/x/mod v0.32.0/go.mod h1:SgipZ/3h2Ci89DlEtEXWUk/HteuRin+HHhN+WbNhguU= -golang.org/x/net v0.49.0 h1:eeHFmOGUTtaaPSGNmjBKpbng9MulQsJURQUAfUwY++o= -golang.org/x/net v0.49.0/go.mod h1:/ysNB2EvaqvesRkuLAyjI1ycPZlQHM3q01F02UY/MV8= -golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= -golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= -golang.org/x/sync v0.19.0 h1:vV+1eWNmZ5geRlYjzm2adRgW2/mcpevXNg50YZtPCE4= -golang.org/x/sync v0.19.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= -golang.org/x/sys v0.40.0 h1:DBZZqJ2Rkml6QMQsZywtnjnnGvHza6BTfYFWY9kjEWQ= -golang.org/x/sys v0.40.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= -golang.org/x/term v0.39.0 h1:RclSuaJf32jOqZz74CkPA9qFuVTX7vhLlpfj/IGWlqY= -golang.org/x/term v0.39.0/go.mod h1:yxzUCTP/U+FzoxfdKmLaA0RV1WgE0VY7hXBwKtY/4ww= -golang.org/x/text v0.33.0 h1:B3njUFyqtHDUI5jMn1YIr5B0IE2U0qck04r6d4KPAxE= -golang.org/x/text v0.33.0/go.mod h1:LuMebE6+rBincTi9+xWTY8TztLzKHc/9C1uBCG27+q8= -golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY= -golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.41.0 h1:a9b8iMweWG+S0OBnlU36rzLp20z1Rp10w+IY2czHTQc= -golang.org/x/tools v0.41.0/go.mod h1:XSY6eDqxVNiYgezAVqqCeihT4j1U2CCsqvH3WhQpnlg= -google.golang.org/protobuf v1.36.8 h1:xHScyCOEuuwZEc6UtSOvPbAT4zRh0xcNRYekJwfqyMc= -google.golang.org/protobuf v1.36.8/go.mod h1:fuxRtAxBytpl4zzqUh6/eyUujkJdNiuEkXntxiD/uRU= +golang.org/x/mod v0.37.0 h1:vF1DjpVEshcIqoEaauuHebaLk1O1forxjxBaVn884JQ= +golang.org/x/mod v0.37.0/go.mod h1:m8S8VeM9r4dzDwjrKO0a1sZP3YjeMamRRlD+fmR2Q/0= +golang.org/x/net v0.56.0 h1:Rw8j/hFzGvJUZwNBXnAtf5sVDVt+65SK2C7IxCxZt5o= +golang.org/x/net v0.56.0/go.mod h1:D3Ku6r+V6JROoZK144D2XfMHFcMq/0zSfLelVTCFKec= +golang.org/x/oauth2 v0.36.0 h1:peZ/1z27fi9hUOFCAZaHyrpWG5lwe0RJEEEeH0ThlIs= +golang.org/x/oauth2 v0.36.0/go.mod h1:YDBUJMTkDnJS+A4BP4eZBjCqtokkg1hODuPjwiGPO7Q= +golang.org/x/sync v0.21.0 h1:HLII4xRRTtCRkxYp4HNFF0Js/Og6q2i++KXbg0gHCwM= +golang.org/x/sync v0.21.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0= +golang.org/x/sys v0.46.0 h1:noSf2Fq6F8DBgS+LysIkx7rIExoNHJsxOAtPp4rthXw= +golang.org/x/sys v0.46.0/go.mod h1:4GL1E5IUh+htKOUEOaiffhrAeqysfVGipDYzABqnCmw= +golang.org/x/term v0.44.0 h1:0rLvDRCtNj0gZkyIXhCyOb2OAzEhLVqc4B+hrsBhrmc= +golang.org/x/term v0.44.0/go.mod h1:7ze4MdzUzLXpSAoFP1H0bOI9aXDqveSvatT5vKcFh2Y= +golang.org/x/text v0.38.0 h1:sXmwo9DwP3OK9EZ7PqAdaooSGozfl/3a6/xJcbzPRhE= +golang.org/x/text v0.38.0/go.mod h1:YXZt3QhHUKYT53r2lLKFIVi6Ao1jdzrTR/KQ09qyxF4= +golang.org/x/time v0.15.0 h1:bbrp8t3bGUeFOx08pvsMYRTCVSMk89u4tKbNOZbp88U= +golang.org/x/time v0.15.0/go.mod h1:Y4YMaQmXwGQZoFaVFk4YpCt4FLQMYKZe9oeV/f4MSno= +golang.org/x/tools v0.46.0 h1:7jTurBkPZu4moS/Uy4OQT1M+QBlsj3wejyZwsT8Z7rk= +golang.org/x/tools v0.46.0/go.mod h1:FrD85F8l+NWL+9XWBSyVSHO6Ne4jutsfIFba7AWQ5Ys= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af h1:+5/Sw3GsDNlEmu7TfklWKPdQ0Ykja5VEmq2i817+jbI= +google.golang.org/protobuf v1.36.12-0.20260120151049-f2248ac996af/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= @@ -134,20 +135,20 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -k8s.io/api v0.35.4 h1:P7nFYKl5vo9AGUp1Z+Pmd3p2tA7bX2wbFWCvDeRv988= -k8s.io/api v0.35.4/go.mod h1:yl4lqySWOgYJJf9RERXKUwE9g2y+CkuwG+xmcOK8wXU= -k8s.io/apiextensions-apiserver v0.35.4 h1:HeP+Upp7ItdvnyGmub0yoix+2z5+ev4M5cE5TCgtOUU= -k8s.io/apiextensions-apiserver v0.35.4/go.mod h1:ogQlk+stIE8mnoRthSYCwlOS12fVqgWFiErMwPaXA7c= -k8s.io/apimachinery v0.35.4 h1:xtdom9RG7e+yDp71uoXoJDWEE2eOiHgeO4GdBzwWpds= -k8s.io/apimachinery v0.35.4/go.mod h1:NNi1taPOpep0jOj+oRha3mBJPqvi0hGdaV8TCqGQ+cc= -k8s.io/client-go v0.35.4 h1:DN6fyaGuzK64UvnKO5fOA6ymSjvfGAnCAHAR0C66kD8= -k8s.io/client-go v0.35.4/go.mod h1:2Pg9WpsS4NeOpoYTfHHfMxBG8zFMSAUi4O/qoiJC3nY= -k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk= -k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE= -k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 h1:Y3gxNAuB0OBLImH611+UDZcmKS3g6CthxToOb37KgwE= -k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912/go.mod h1:kdmbQkyfwUagLfXIad1y2TdrjPFWp2Q89B3qkRwf/pQ= -k8s.io/utils v0.0.0-20251002143259-bc988d571ff4 h1:SjGebBtkBqHFOli+05xYbK8YF1Dzkbzn+gDM4X9T4Ck= -k8s.io/utils v0.0.0-20251002143259-bc988d571ff4/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +k8s.io/api v0.36.2 h1:TF6YDLIzKfccK7cq9YpTcGX8TJmEkHVRv78DM51fRYY= +k8s.io/api v0.36.2/go.mod h1:F4LbMO4brjZYh7yFkXWhynSvtB7YauxV4c+HHkNRGNg= +k8s.io/apiextensions-apiserver v0.36.2 h1:3O5gqOj/dt2XWWbpMe+TXWpE9yU6pjM/tXxtHHJT/K4= +k8s.io/apiextensions-apiserver v0.36.2/go.mod h1:cL1tBWe8XSaP1H30iWKGo7hf6iAUUUJPEU70dskmAnA= +k8s.io/apimachinery v0.36.2 h1:0PE/W/WNy1UX61NLbXY5TMbJ6UwLL6E6lAPkYrKFxbQ= +k8s.io/apimachinery v0.36.2/go.mod h1:fvf/HOLXq9RId0rnDIbN1OEBvHXdQbLMM8nu0LcBUf4= +k8s.io/client-go v0.36.2 h1:bfgxmFKc9CgqsgX4xKLAAdmTQlWee7Ob/HlDOrJ5TBI= +k8s.io/client-go v0.36.2/go.mod h1:1vgO4OAlfPnoLcb+Rze2GF5rAr14w8qjrYMoyXJzQj0= +k8s.io/klog/v2 v2.140.0 h1:Tf+J3AH7xnUzZyVVXhTgGhEKnFqye14aadWv7bzXdzc= +k8s.io/klog/v2 v2.140.0/go.mod h1:o+/RWfJ6PwpnFn7OyAG3QnO47BFsymfEfrz6XyYSSp0= +k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a h1:xCeOEAOoGYl2jnJoHkC3hkbPJgdATINPMAxaynU2Ovg= +k8s.io/kube-openapi v0.0.0-20260317180543-43fb72c5454a/go.mod h1:uGBT7iTA6c6MvqUvSXIaYZo9ukscABYi2btjhvgKGZ0= +k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 h1:AZYQSJemyQB5eRxqcPky+/7EdBj0xi3g0ZcxxJ7vbWU= +k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk= sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg= sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg= sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU= diff --git a/lib.Makefile b/lib.Makefile index 97b6f7159..14e68c4cf 100644 --- a/lib.Makefile +++ b/lib.Makefile @@ -52,14 +52,18 @@ ifeq ($(ARCH),x86_64) override ARCH=amd64 endif -# detect the local outbound ip address +# detect the local outbound ip address (only used by FV/etcd targets that don't run on Windows) +ifneq ($(OS),Windows_NT) LOCAL_IP_ENV?=$(shell ip route get 8.8.8.8 | head -1 | awk '{print $$7}') +endif LATEST_IMAGE_TAG?=latest # these macros create a list of valid architectures for pushing manifests comma := , +ifneq ($(OS),Windows_NT) double_quote := $(shell echo '"') +endif ## Targets used when cross building. .PHONY: native register @@ -75,7 +79,7 @@ endif .PHONY: register register: ifneq ($(BUILDARCH),$(ARCH)) - docker run --privileged --rm calico/binfmt:qemu-v10.1.4 --install all || true + docker run --privileged --rm calico/binfmt:qemu-v10.2.2 --install all || true endif # If this is a release, also tag and push additional images. @@ -123,6 +127,21 @@ endif endif endif +# Optional cap on go build/test package parallelism. Appended to GOFLAGS so +# it flows through every docker invocation that already passes GOFLAGS in. +# Useful for limiting memory pressure when running multiple parallel builds +# on a workstation (each in-flight package can fork its own compiler). +ifneq ($(GO_BUILD_PARALLELISM),) +GOFLAGS := $(GOFLAGS) -p=$(GO_BUILD_PARALLELISM) +endif + +# Outer parallelism for image / kind-build-images / kind-reload. Each parallel +# job spawns a docker go-build container, so `-j$(nproc)` on a workstation with +# limited RAM (e.g. 32G running alongside an IDE/LSP/AI session) will thrash +# into swap. Default to a conservative 4. Raise via NUM_BUILD_JOBS=N for a +# bigger machine. +NUM_BUILD_JOBS ?= 4 + # For building, we use the go-build image for the *host* architecture, even if the target is different # the one for the host should contain all the necessary cross-compilation tools # we do not need to use the arch since go-build:v0.15 now is multi-arch manifest @@ -132,10 +151,10 @@ CALICO_BUILD = $(GO_BUILD_IMAGE):$(GO_BUILD_VER) RUST_BUILD_IMAGE ?= calico/rust-build CALICO_RUST_BUILD = $(RUST_BUILD_IMAGE):$(RUST_BUILD_VER) -# We use BoringCrypto as FIPS validated cryptography in order to allow users to run in FIPS Mode (amd64 only). +# On amd64 we build with CGO enabled (libbpf and other cgo deps require it); +# other architectures default to pure-Go builds. ifeq ($(ARCH), $(filter $(ARCH),amd64)) -GOEXPERIMENT?=boringcrypto -TAGS?=boringcrypto,osusergo,netgo +TAGS?=osusergo,netgo CGO_ENABLED?=1 else CGO_ENABLED?=0 @@ -147,9 +166,15 @@ endif # slow QEMU emulation for CGO builds. # # Map Go ARCH names to clang target triples. -# Only arm64 and ppc64le need cross-compilation support (CGO is not enabled for s390x). CLANG_CROSS_TRIPLE_arm64 := aarch64-linux-gnu CLANG_CROSS_TRIPLE_ppc64le := powerpc64le-linux-gnu +CLANG_CROSS_TRIPLE_s390x := s390x-linux-gnu + +# Rust target triple (long form). Injected as CARGO_BUILD_TARGET so cargo +# cross-compiles transparently. Linker/sysroot side uses CROSS_TRIPLE below. +RUST_TARGET_amd64 := x86_64-unknown-linux-gnu +RUST_TARGET_arm64 := aarch64-unknown-linux-gnu +RUST_TARGET := $(RUST_TARGET_$(ARCH)) # Set CROSS_CC and CROSS_SYSROOT when cross-compiling from amd64. ifeq ($(BUILDARCH),amd64) @@ -163,25 +188,7 @@ endif endif endif -# Build a binary with boring crypto support. -# This function expects you to pass in two arguments: -# 1st arg: path/to/input/package(s) -# 2nd arg: path/to/output/binary -# Only when arch = amd64 it will use boring crypto to build the binary. -# Uses LDFLAGS, CGO_LDFLAGS, CGO_CFLAGS when set. -# Tests that the resulting binary contains boringcrypto symbols. -define build_cgo_boring_binary - $(DOCKER_RUN) \ - -e CGO_ENABLED=1 \ - $(if $(CROSS_CC),-e CC="$(CROSS_CC)") \ - -e CGO_CFLAGS=$(CGO_CFLAGS) \ - -e CGO_LDFLAGS=$(CGO_LDFLAGS) \ - $(CALICO_BUILD) \ - sh -c '$(GIT_CONFIG_SSH) GOEXPERIMENT=boringcrypto go build -o $(2) -tags fipsstrict -v -buildvcs=false -ldflags "$(LDFLAGS)" $(1) \ - && go tool nm $(2) | grep '_Cfunc__goboringcrypto_' 1> /dev/null' -endef - -# Use this when building binaries that need cgo, but have no crypto and therefore would not contain any boring symbols. +# Use this when building binaries that need cgo (e.g. for libbpf). define build_cgo_binary $(DOCKER_RUN) \ -e CGO_ENABLED=1 \ @@ -192,7 +199,7 @@ define build_cgo_binary sh -c '$(GIT_CONFIG_SSH) go build -o $(2) -v -buildvcs=false -ldflags "$(LDFLAGS)" $(1)' endef -# For binaries that do not require boring crypto. +# For binaries that do not require cgo. define build_binary $(DOCKER_RUN) \ -e CGO_ENABLED=0 \ @@ -233,6 +240,12 @@ endif # Get version from git. We allow setting this manually for the hashrelease process. # By default, includes commit count and hash (--long). During releases (RELEASE=true), # only the tag is used without the commit count suffix. +# +# Skip on Windows: these LDFLAGS-related vars use bash `||` fallbacks that PowerShell +# can't parse, and Windows builds (e.g. fluentd-base) don't link Go binaries that +# embed buildinfo. Each $(shell git ...) call would otherwise spawn PowerShell on +# every sub-make recursion, multiplying parse time noticeably. +ifneq ($(OS),Windows_NT) GIT_VERSION ?= $(shell git describe --tags --dirty --always --abbrev=12 --long) ifeq ($(RELEASE),true) GIT_VERSION := $(shell git describe --tags --dirty --always --abbrev=12) @@ -247,6 +260,7 @@ BUILD_ID:=$(shell git rev-parse HEAD || uuidgen | sed 's/-//g') # git tag at the time we build the binary. # Variables elsewhere that depend on this (such as LDFLAGS) must also be lazy. GIT_DESCRIPTION=$(shell git describe --tags --dirty --always --abbrev=12 || echo '') +endif # Calculate a timestamp for any build artifacts. ifneq ($(OS),Windows_NT) @@ -298,6 +312,23 @@ endif EXTRA_DOCKER_ARGS += -v $(GOMOD_CACHE):/go/pkg/mod:rw +# Optional per-build resource caps. When unset, no flags are added and the +# container has full host access (current behaviour). Useful when running +# multiple parallel builds on a workstation to avoid memory thrash. +# DOCKER_CPUS=N Hard cap on total CPU bandwidth (any core). +# DOCKER_CPUSET_CPUS=0-3 Pin container to specific cores (true affinity). +# GOMAXPROCS=N Cap goroutine parallelism inside each go invocation +# (linker, vet, etc.); complements -p=N from GOFLAGS. +ifneq ($(DOCKER_CPUS),) +EXTRA_DOCKER_ARGS += --cpus=$(DOCKER_CPUS) +endif +ifneq ($(DOCKER_CPUSET_CPUS),) +EXTRA_DOCKER_ARGS += --cpuset-cpus=$(DOCKER_CPUSET_CPUS) +endif +ifneq ($(GOMAXPROCS),) +EXTRA_DOCKER_ARGS += -e GOMAXPROCS=$(GOMAXPROCS) +endif + # Define go architecture flags GOARCH_FLAGS :=-e GOARCH=$(ARCH) @@ -313,6 +344,11 @@ CERTS_PATH := $(REPO_ROOT)/hack/test/certs # /.git/worktrees/. When Docker containers need git access, # the main .git directory must also be mounted, and GIT_DIR / GIT_WORK_TREE # must be set so that git can find objects and the correct working tree. +# +# Skip on Windows: this only configures Linux Docker mounts, and the bash `2>/dev/null` +# redirection PowerShell tries to interpret as `2 > /dev/null` (writing to a file at +# C:\dev\null), which fails noisily on every parse. +ifneq ($(OS),Windows_NT) _GIT_DIR := $(shell git rev-parse --absolute-git-dir 2>/dev/null) _GIT_COMMON_DIR := $(realpath $(shell git rev-parse --git-common-dir 2>/dev/null)) ifneq ($(_GIT_DIR),$(_GIT_COMMON_DIR)) @@ -328,6 +364,7 @@ DOCKER_GIT_WORKTREE_ARGS := \ else DOCKER_GIT_WORKTREE_ARGS := endif +endif # Configure the Calico API group to use. Projects importing this Makefile can override this variable # if they need to. @@ -382,12 +419,73 @@ DOCKER_RUN := $(DOCKER_RUN_PRIV_NET) --net=host DOCKER_GO_BUILD := $(DOCKER_RUN) $(CALICO_BUILD) +# Cross-compile env for Rust + cc-rs / bindgen. Same gate as the Go side. +# Key suffixes use the long Rust triple (cc-rs convention); extend for ppc64le. +ifeq ($(BUILDARCH),amd64) +ifneq ($(ARCH),amd64) +RUST_CROSS_ENV := \ + -e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=clang \ + -e CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="-C link-arg=--target=$(CROSS_TRIPLE) -C link-arg=--sysroot=$(CROSS_SYSROOT) -C link-arg=-fuse-ld=lld" \ + -e CC_aarch64_unknown_linux_gnu=clang \ + -e CXX_aarch64_unknown_linux_gnu=clang++ \ + -e AR_aarch64_unknown_linux_gnu=$(CROSS_TRIPLE)-ar \ + -e CFLAGS_aarch64_unknown_linux_gnu="--sysroot=$(CROSS_SYSROOT) -fuse-ld=lld" \ + -e CXXFLAGS_aarch64_unknown_linux_gnu="--sysroot=$(CROSS_SYSROOT) -fuse-ld=lld" \ + -e BINDGEN_EXTRA_CLANG_ARGS_aarch64_unknown_linux_gnu="--target=$(CROSS_TRIPLE) --sysroot=$(CROSS_SYSROOT) -I$(CROSS_SYSROOT)/usr/include" +endif +endif + +############################################################################### +# Calico-patched controller-gen +# +# CRD generation uses a controller-gen with Calico-specific patches (see the +# *.patch files under //hack/cmd/calico-controller-gen): NumOrString/Port/ +# Protocol/DSCP int-or-string union schemas, and nullable slice-of-pointer +# elements. The projectcalico/toolchain repo bakes a (NumOrString-only) patched +# binary into the calico/go-build image; we build our own patched binary +# in-repo instead (download tarball -> apply patches -> go build), so CRD +# generation owns its patches and does not depend on the image's controller-gen. +# +# The controller-tools version is pinned inside build.sh (its VERSION line, the +# single source of truth). build.sh checks it against the controller-gen baked +# into the calico/go-build image and, on a mismatch, rewrites that line and +# fails so the bump is committed deliberately. We read the pin here cheaply (no +# container) for the cache key. +CONTROLLER_TOOLS_VERSION := $(shell sed -n 's/^VERSION="\(v[0-9][0-9.]*\)".*/\1/p' $(REPO_ROOT)/hack/cmd/calico-controller-gen/build.sh | head -1) +CONTROLLER_TOOLS_VERSION := $(or $(CONTROLLER_TOOLS_VERSION),v0.18.0) + +# The binary is built into the shared .go-pkg-cache (mounted as /go-cache in +# every component container, including api/'s isolated mount). It is stamped +# with the go-build image version, the controller-tools version, and a hash of +# all patches: bumping the image (which may carry a new controller-gen), the +# pinned version, or a patch yields a new path and triggers a rebuild — and a +# rebuild re-runs the image-vs-pin check in build.sh. +CALICO_CONTROLLER_GEN_HASH := $(shell cat $(REPO_ROOT)/hack/cmd/calico-controller-gen/*.patch 2>/dev/null | sha256sum | cut -c1-12) +CALICO_CONTROLLER_GEN_STAMP := $(GO_BUILD_VER)-$(CONTROLLER_TOOLS_VERSION)-$(CALICO_CONTROLLER_GEN_HASH) +# Two views of the same file: the host path Make uses as a build target, and +# the in-container path (/go-cache is the bind-mount of .go-pkg-cache) used to +# invoke it from inside the build containers. +CALICO_CONTROLLER_GEN_BIN := $(REPO_ROOT)/.go-pkg-cache/bin/calico-controller-gen-$(CALICO_CONTROLLER_GEN_STAMP) +CALICO_CONTROLLER_GEN := /go-cache/bin/calico-controller-gen-$(CALICO_CONTROLLER_GEN_STAMP) + +# Real file target (not .PHONY): Make skips it entirely — no container spin-up — +# when the binary already exists and build.sh is unchanged. Patch edits and +# version-pin bumps both land in the filename above (via the hash and the +# pinned version), so they yield a new target and trigger a rebuild. The recipe +# needs the repo root mounted (for build.sh and the patches), so components in +# their own module (api/) reach it via: +# $(MAKE) -C $(REPO_ROOT) $(CALICO_CONTROLLER_GEN_BIN) +$(CALICO_CONTROLLER_GEN_BIN): hack/cmd/calico-controller-gen/build.sh + $(DOCKER_GO_BUILD) sh -c \ + './hack/cmd/calico-controller-gen/build.sh $(CALICO_CONTROLLER_GEN)' + DOCKER_RUST_BUILD := mkdir -p bin && \ docker run --rm \ --init \ - --platform=linux/$(ARCH) \ --user $(LOCAL_USER_ID):$(LOCAL_GROUP_ID) \ $(EXTRA_DOCKER_ARGS) \ + -e CARGO_BUILD_TARGET=$(RUST_TARGET) \ + $(RUST_CROSS_ENV) \ -v $(REPO_ROOT):/rust/src/github.com/projectcalico/calico:rw \ -w /rust/src/$(PACKAGE_NAME) \ $(CALICO_RUST_BUILD) @@ -404,16 +502,25 @@ DOCKER_RUST_BUILD := mkdir -p bin && \ # IMAGE_DEPS lists non-Go files that the Docker image depends on (Dockerfiles, # config templates, scripts, etc.). Components should override or append to # this variable and include $(IMAGE_DEPS) in their .image.created prereqs. +# +# Skip on Windows: this is dependency tracking for Linux Go-based image stamps; +# Windows components (e.g. third_party/fluentd-base) build pure Docker images. +# Each $(shell find ... grep ... cut ...) call would otherwise spawn PowerShell +# (no find/grep/cut available) on every sub-make recursion. With ~20 components +# referenced from .image.created-* prerequisites below, this was the dominant +# contributor to the Windows publish job hitting Semaphore's 3h timeout. ############################################################################### +IMAGE_DEPS ?= Dockerfile + +ifneq ($(OS),Windows_NT) ifneq ($(wildcard deps.txt),) SRC_FILES := $(shell find $(addprefix $(REPO_ROOT)/,$(shell grep '^local:' deps.txt | cut -d: -f2-)) -name '*.go' 2>/dev/null) endif -IMAGE_DEPS ?= Dockerfile - # Expand a component's deps.txt local entries to the list of .go files. # Usage: $(call local-deps-go-files,) local-deps-go-files = $(shell find $(addprefix $(REPO_ROOT)/,$(shell grep '^local:' $(REPO_ROOT)/$(1)/deps.txt | cut -d: -f2-)) -name '*.go' 2>/dev/null) +endif # A target that does nothing but it always stale, used to force a rebuild on certain targets based on some non-file criteria. .PHONY: force-rebuild @@ -758,23 +865,24 @@ LINT_ARGS ?= --max-issues-per-linter 0 --max-same-issues 0 --timeout 8m golangci-lint: $(GENERATED_FILES) $(DOCKER_RUN) $(CALICO_BUILD) sh -c '$(GIT_CONFIG_SSH) golangci-lint run $(LINT_ARGS)' -REPO_DIR=$(shell if [ -e hack/format-changed-files.sh ]; then echo '.'; else echo '..'; fi ) +REPO_REL_DIR=$(shell if [ -e hack/format-changed-files.sh ]; then echo '.'; else echo '..'; fi ) .PHONY: fix-changed go-fmt-changed goimports-changed # Format changed files only. fix-changed go-fmt-changed goimports-changed: if [ "$(SKIP_FIX_CHANGED)" != "true" ]; then \ + parent_branch=`release_prefix=$(RELEASE_BRANCH_PREFIX)-v git_repo_slug=$(GIT_REPO_SLUG) $(REPO_REL_DIR)/hack/find-parent-release-branch.sh`; \ $(DOCKER_RUN) -e release_prefix=$(RELEASE_BRANCH_PREFIX)-v \ -e git_repo_slug=$(GIT_REPO_SLUG) \ - -e parent_branch=$(shell $(REPO_DIR)/hack/find-parent-release-branch.sh) \ - $(CALICO_BUILD) $(REPO_DIR)/hack/format-changed-files.sh; \ + -e parent_branch=$$parent_branch \ + $(CALICO_BUILD) $(REPO_REL_DIR)/hack/format-changed-files.sh; \ fi .PHONY: fix-all go-fmt-all goimports-all fix-all go-fmt-all goimports-all: - $(DOCKER_RUN) $(CALICO_BUILD) $(REPO_DIR)/hack/format-all-files.sh + $(DOCKER_RUN) $(CALICO_BUILD) $(REPO_REL_DIR)/hack/format-all-files.sh -GOMODDER=$(REPO_DIR)/hack/cmd/gomodder/main.go +GOMODDER=$(REPO_REL_DIR)/hack/cmd/gomodder/main.go .PHONY: verify-go-mods verify-go-mods: @@ -1062,6 +1170,14 @@ endif # retry_docker_cmd retries a docker command up to a specified number of times. # Usage: $(call retry_docker_cmd,,,,) +# +# Windows agents (Semaphore) execute recipe lines under PowerShell, which can't parse +# the bash retry loop used elsewhere; emit a single-line PowerShell loop instead. +ifeq ($(OS),Windows_NT) +define retry_docker_cmd + for ($$i=1; $$i -le $(3); $$i++) { $(2); if ($$LASTEXITCODE -eq 0) { break }; Write-Host ('WARNING: $(1) failed (attempt {0}/$(3)), retrying in $(4)s...' -f $$i); if ($$i -eq $(3)) { exit 1 }; Start-Sleep -Seconds $(4) } +endef +else define retry_docker_cmd i=1; \ while [ $$i -le $(3) ]; do \ @@ -1072,19 +1188,31 @@ define retry_docker_cmd i=$$((i + 1)); \ done endef +endif # Configuration options for retrying docker commands MANIFEST_RETRIES ?= 5 MANIFEST_RETRY_DELAY ?= 5 +# log_step prints a grep-able timing record. Bracket a long-running shell +# step with start/end calls so per-step durations can be computed from the +# CI log without per-line instrumentation. +# Usage: $(call log_step,start,