From 5b41ee2b37f20d0b06430f23aa18a6f5a4704ea1 Mon Sep 17 00:00:00 2001 From: Knative Automation Date: Fri, 7 Jun 2024 02:02:00 +0000 Subject: [PATCH] upgrade to latest dependencies bumping knative.dev/pkg fce44ea...58135c2: > 58135c2 Extra logging for leases (# 3049) bumping knative.dev/serving 2fd8465...09b4cd3: > 09b4cd3 use cgr.dev/chainguard/static:latest which is nonroot (# 15310) > 30a77d1 Add affinity-rules feature to configmap config-deployment (# 15250) > 10b9152 Update net-gateway-api nightly (# 15307) > 19055d5 upgrade to latest dependencies (# 15306) > 3e53acc Run system-internal-tls tests only for kourier (# 15299) > 5a3aa98 Update net-kourier nightly (# 15303) > 4c71c49 Update net-istio nightly (# 15301) > d3f9a04 Update net-contour nightly (# 15302) > 57d2a26 Update net-gateway-api nightly (# 15300) > bb51203 upgrade to latest dependencies (# 15297) Signed-off-by: Knative Automation --- go.mod | 4 +-- go.sum | 8 +++--- .../serving/pkg/deployment/config.go | 28 ++++++++++++++++++- .../reconciler/revision/resources/deploy.go | 21 ++++++++++++++ vendor/modules.txt | 4 +-- 5 files changed, 56 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index faa88d87b..90d691729 100644 --- a/go.mod +++ b/go.mod @@ -17,8 +17,8 @@ require ( knative.dev/caching v0.0.0-20240603132637-bb31986d9396 knative.dev/hack v0.0.0-20240529131459-3b6d6441e7ea knative.dev/networking v0.0.0-20240603133819-41aa2087242d - knative.dev/pkg v0.0.0-20240603145758-fce44ead15bd - knative.dev/serving v0.41.1-0.20240603213049-2fd8465334ec + knative.dev/pkg v0.0.0-20240604134003-58135c2c0694 + knative.dev/serving v0.41.1-0.20240606173551-09b4cd3ec097 ) require ( diff --git a/go.sum b/go.sum index bdbba357b..fef372b73 100644 --- a/go.sum +++ b/go.sum @@ -805,10 +805,10 @@ knative.dev/hack v0.0.0-20240529131459-3b6d6441e7ea h1:iWW6SNMrVd2hI5Y+ltKIEzXVe knative.dev/hack v0.0.0-20240529131459-3b6d6441e7ea/go.mod h1:yk2OjGDsbEnQjfxdm0/HJKS2WqTLEFg/N6nUs6Rqx3Q= knative.dev/networking v0.0.0-20240603133819-41aa2087242d h1:B0psbCJrgnQLE8fibEga8NHE04Ay6L8CctdG4a+1CaY= knative.dev/networking v0.0.0-20240603133819-41aa2087242d/go.mod h1:WS5A291Vy2unZ1L54ZSKBkz/gVzVmIy15cCcdA6PRN4= -knative.dev/pkg v0.0.0-20240603145758-fce44ead15bd h1:SxwfJkmXwxl2PT5xZjtKKHO7URgHuigOoyzelaIGb2g= -knative.dev/pkg v0.0.0-20240603145758-fce44ead15bd/go.mod h1:E5OxJHFsQiW7pL0lVJ02XEVm2QUc0ZVdSUHiarUJHrU= -knative.dev/serving v0.41.1-0.20240603213049-2fd8465334ec h1:aL75B5j+6B7o6tm4fVgWyrystaxzhuGh+2UQZ68RKb8= -knative.dev/serving v0.41.1-0.20240603213049-2fd8465334ec/go.mod h1:DuULKFxW70yqYzYf0+LVla73AXXyB2kgCnMZ61hFFYw= +knative.dev/pkg v0.0.0-20240604134003-58135c2c0694 h1:trbVXm0WFXxxjcuSCKrYHKQwRQCuDrE8T5+yqXAI1NA= +knative.dev/pkg v0.0.0-20240604134003-58135c2c0694/go.mod h1:E5OxJHFsQiW7pL0lVJ02XEVm2QUc0ZVdSUHiarUJHrU= +knative.dev/serving v0.41.1-0.20240606173551-09b4cd3ec097 h1:QMgemyOgb1GQJ/HS0ABNRmIj+AlFgbjCWUZVCuuWSig= +knative.dev/serving v0.41.1-0.20240606173551-09b4cd3ec097/go.mod h1:2HcdNS0hQKfa5Y1hPdqoxLNaOQAP6OXSrRFUuceUOJ8= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/vendor/knative.dev/serving/pkg/deployment/config.go b/vendor/knative.dev/serving/pkg/deployment/config.go index d35cc8141..4bb78d330 100644 --- a/vendor/knative.dev/serving/pkg/deployment/config.go +++ b/vendor/knative.dev/serving/pkg/deployment/config.go @@ -24,7 +24,6 @@ import ( corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" "k8s.io/apimachinery/pkg/util/sets" - cm "knative.dev/pkg/configmap" ) @@ -68,6 +67,9 @@ const ( // qpoptions queueSidecarTokenAudiencesKey = "queue-sidecar-token-audiences" queueSidecarRooCAKey = "queue-sidecar-rootca" + + defaultAffinityTypeKey = "default-affinity-type" + defaultAffinityTypeValue = PreferSpreadRevisionOverNodes ) var ( @@ -103,6 +105,7 @@ func defaultConfig() *Config { DigestResolutionTimeout: digestResolutionTimeoutDefault, RegistriesSkippingTagResolving: sets.New("kind.local", "ko.local", "dev.local"), QueueSidecarCPURequest: &QueueSidecarCPURequestDefault, + DefaultAffinityType: defaultAffinityTypeValue, } // The following code is needed for ConfigMap testing. // defaultConfig must match the example in deployment.yaml which includes: `queue-sidecar-token-audiences: ""` @@ -164,6 +167,14 @@ func NewConfigFromMap(configMap map[string]string) (*Config, error) { return nil, fmt.Errorf("digest-resolution-timeout cannot be a non-positive duration, was %v", nc.DigestResolutionTimeout) } + if affinity, ok := configMap[defaultAffinityTypeKey]; ok { + switch opt := AffinityType(affinity); opt { + case None, PreferSpreadRevisionOverNodes: + nc.DefaultAffinityType = opt + default: + return nil, fmt.Errorf("unsupported %s value: %q", defaultAffinityTypeKey, affinity) + } + } return nc, nil } @@ -172,6 +183,17 @@ func NewConfigFromConfigMap(config *corev1.ConfigMap) (*Config, error) { return NewConfigFromMap(config.Data) } +// AffinityType specifies which affinity requirements will be automatically applied to the PodSpec of all Knative services. +type AffinityType string + +const ( + // None is used for deactivating affinity configuration for user workloads. + None AffinityType = "none" + + // PreferSpreadRevisionOverNodes is used to set pod anti-affinity requirements for user workloads. + PreferSpreadRevisionOverNodes AffinityType = "prefer-spread-revision-over-nodes" +) + // Config includes the configurations for the controller. type Config struct { // QueueSidecarImage is the name of the image used for the queue sidecar @@ -214,4 +236,8 @@ type Config struct { // QueueSidecarRootCA is a root certificate to be trusted by the queue proxy sidecar qpoptions. QueueSidecarRootCA string + + // DefaultAffinityType is a string that controls what affinity rules will be automatically + // applied to the PodSpec of all Knative services. + DefaultAffinityType AffinityType } diff --git a/vendor/knative.dev/serving/pkg/reconciler/revision/resources/deploy.go b/vendor/knative.dev/serving/pkg/reconciler/revision/resources/deploy.go index 2df44c1bb..d17cfe830 100644 --- a/vendor/knative.dev/serving/pkg/reconciler/revision/resources/deploy.go +++ b/vendor/knative.dev/serving/pkg/reconciler/revision/resources/deploy.go @@ -39,6 +39,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" apiconfig "knative.dev/serving/pkg/apis/config" + deploymentconfig "knative.dev/serving/pkg/deployment" ) const certVolumeName = "server-certs" @@ -150,6 +151,22 @@ func rewriteUserLivenessProbe(p *corev1.Probe, userPort int) { } } +func makePreferSpreadRevisionOverNodes(revisionLabelValue string) *corev1.PodAntiAffinity { + return &corev1.PodAntiAffinity{ + PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{{ + Weight: 100, + PodAffinityTerm: corev1.PodAffinityTerm{ + TopologyKey: corev1.LabelHostname, + LabelSelector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + serving.RevisionLabelKey: revisionLabelValue, + }, + }, + }, + }}, + } +} + func makePodSpec(rev *v1.Revision, cfg *config.Config) (*corev1.PodSpec, error) { queueContainer, err := makeQueueContainer(rev, cfg) tokenVolume := varTokenVolume.DeepCopy() @@ -210,6 +227,10 @@ func makePodSpec(rev *v1.Revision, cfg *config.Config) (*corev1.PodSpec, error) } } + if cfg.Deployment.DefaultAffinityType == deploymentconfig.PreferSpreadRevisionOverNodes && rev.Spec.Affinity == nil { + podSpec.Affinity = &corev1.Affinity{PodAntiAffinity: makePreferSpreadRevisionOverNodes(rev.Name)} + } + return podSpec, nil } diff --git a/vendor/modules.txt b/vendor/modules.txt index 55121f926..d9d40e967 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1158,7 +1158,7 @@ knative.dev/networking/pkg/http/stats knative.dev/networking/pkg/ingress knative.dev/networking/pkg/k8s knative.dev/networking/pkg/prober -# knative.dev/pkg v0.0.0-20240603145758-fce44ead15bd +# knative.dev/pkg v0.0.0-20240604134003-58135c2c0694 ## explicit; go 1.21 knative.dev/pkg/apis knative.dev/pkg/apis/duck @@ -1224,7 +1224,7 @@ knative.dev/pkg/version knative.dev/pkg/webhook knative.dev/pkg/webhook/certificates/resources knative.dev/pkg/websocket -# knative.dev/serving v0.41.1-0.20240603213049-2fd8465334ec +# knative.dev/serving v0.41.1-0.20240606173551-09b4cd3ec097 ## explicit; go 1.21 knative.dev/serving/pkg/activator knative.dev/serving/pkg/apis/autoscaling