Skip to content

Commit

Permalink
🔥 Apply carried patches.
Browse files Browse the repository at this point in the history
  • Loading branch information
serverless-qe committed Oct 25, 2023
1 parent 863726e commit 1335642
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 109 deletions.
3 changes: 2 additions & 1 deletion .ko.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Use :nonroot base image for all containers
defaultBaseImage: gcr.io/distroless/static:nonroot
defaultBaseImage: registry.access.redhat.com/ubi8/ubi-minimal:latest
baseImageOverrides:
knative.dev/serving/test/test_images/runtime: gcr.io/distroless/static:nonroot
knative.dev/serving/vendor/github.com/tsenart/vegeta/v12: ubuntu:latest
21 changes: 0 additions & 21 deletions config/core/100-namespace.yaml

This file was deleted.

25 changes: 25 additions & 0 deletions config/core/200-roles/config-map-view-downstream.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Extra role for downstream, so that users can get the autoscaling CM to fetch defaults.
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: knative-serving
name: openshift-serverless-view-serving-configmaps
rules:
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["config-autoscaler"]
verbs: ["get", "list", "watch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: openshift-serverless-view-serving-configmaps
namespace: knative-serving
subjects:
- kind: Group
name: system:authenticated
apiGroup: rbac.authorization.k8s.io
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: openshift-serverless-view-serving-configmaps
2 changes: 1 addition & 1 deletion config/core/deployments/activator-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ metadata:
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: devel
spec:
minAvailable: 80%
minAvailable: 1
selector:
matchLabels:
app: activator
2 changes: 1 addition & 1 deletion config/core/deployments/webhook-hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ metadata:
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: devel
spec:
minAvailable: 80%
minAvailable: 1
selector:
matchLabels:
app: webhook
52 changes: 28 additions & 24 deletions openshift/release/artifacts/serving-core.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,4 @@
---
# Copyright 2018 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: Namespace
metadata:
name: knative-serving
labels:
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: "release-v1.12"
---
# Copyright 2023 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -235,6 +213,32 @@ rules:
resources: ["images"]
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"]
---
# Extra role for downstream, so that users can get the autoscaling CM to fetch defaults.
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
namespace: knative-serving
name: openshift-serverless-view-serving-configmaps
rules:
- apiGroups: [""]
resources: ["configmaps"]
resourceNames: ["config-autoscaler"]
verbs: ["get", "list", "watch"]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: openshift-serverless-view-serving-configmaps
namespace: knative-serving
subjects:
- kind: Group
name: system:authenticated
apiGroup: rbac.authorization.k8s.io
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: openshift-serverless-view-serving-configmaps
---
# Copyright 2019 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -6147,7 +6151,7 @@ metadata:
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: "release-v1.12"
spec:
minAvailable: 80%
minAvailable: 1
selector:
matchLabels:
app: activator
Expand Down Expand Up @@ -6640,7 +6644,7 @@ metadata:
app.kubernetes.io/name: knative-serving
app.kubernetes.io/version: "release-v1.12"
spec:
minAvailable: 80%
minAvailable: 1
selector:
matchLabels:
app: webhook
Expand Down
15 changes: 3 additions & 12 deletions pkg/apis/serving/v1/revision_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,21 +189,14 @@ func (rs *RevisionSpec) defaultSecurityContext(psc *corev1.PodSecurityContext, c
if updatedSC.AllowPrivilegeEscalation == nil {
updatedSC.AllowPrivilegeEscalation = ptr.Bool(false)
}
if psc.SeccompProfile == nil || psc.SeccompProfile.Type == "" {
if updatedSC.SeccompProfile == nil {
updatedSC.SeccompProfile = &corev1.SeccompProfile{}
}
if updatedSC.SeccompProfile.Type == "" {
updatedSC.SeccompProfile.Type = corev1.SeccompProfileTypeRuntimeDefault
}
}

if updatedSC.Capabilities == nil {
updatedSC.Capabilities = &corev1.Capabilities{}
updatedSC.Capabilities.Drop = []corev1.Capability{"ALL"}
// Default in NET_BIND_SERVICE to allow binding to low-numbered ports.
needsLowPort := false
for _, p := range container.Ports {
if p.ContainerPort < 1024 {
if p.ContainerPort > 0 && p.ContainerPort < 1024 {
needsLowPort = true
break
}
Expand All @@ -212,11 +205,9 @@ func (rs *RevisionSpec) defaultSecurityContext(psc *corev1.PodSecurityContext, c
updatedSC.Capabilities.Add = []corev1.Capability{"NET_BIND_SERVICE"}
}
}

if psc.RunAsNonRoot == nil {
if psc.RunAsNonRoot == nil && updatedSC.RunAsNonRoot == nil {
updatedSC.RunAsNonRoot = ptr.Bool(true)
}

if *updatedSC != (corev1.SecurityContext{}) {
container.SecurityContext = updatedSC
}
Expand Down
21 changes: 6 additions & 15 deletions pkg/apis/serving/v1/revision_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,8 @@ func TestRevisionDefaulting(t *testing.T) {
ReadinessProbe: defaultProbe,
Resources: defaultResources,
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: ptr.Bool(true),
AllowPrivilegeEscalation: ptr.Bool(false),
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
RunAsNonRoot: ptr.Bool(true),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
Add: []corev1.Capability{"NET_BIND_SERVICE"},
Expand All @@ -914,11 +911,8 @@ func TestRevisionDefaulting(t *testing.T) {
Name: "sidecar",
Resources: defaultResources,
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: ptr.Bool(true),
AllowPrivilegeEscalation: ptr.Bool(false),
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
RunAsNonRoot: ptr.Bool(true),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
Expand All @@ -927,11 +921,8 @@ func TestRevisionDefaulting(t *testing.T) {
Name: "special-sidecar",
Resources: defaultResources,
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: ptr.Bool(true),
AllowPrivilegeEscalation: ptr.Bool(true),
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
RunAsNonRoot: ptr.Bool(true),
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{"NET_ADMIN"},
Drop: []corev1.Capability{},
Expand All @@ -941,12 +932,12 @@ func TestRevisionDefaulting(t *testing.T) {
InitContainers: []corev1.Container{{
Name: "special-init",
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: ptr.Bool(true),
AllowPrivilegeEscalation: ptr.Bool(true),
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeLocalhost,
LocalhostProfile: ptr.String("special"),
},
RunAsNonRoot: ptr.Bool(true),
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{"NET_ADMIN"},
},
Expand Down Expand Up @@ -1004,8 +995,8 @@ func TestRevisionDefaulting(t *testing.T) {
ReadinessProbe: defaultProbe,
Resources: defaultResources,
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: ptr.Bool(true),
AllowPrivilegeEscalation: ptr.Bool(false),
RunAsNonRoot: ptr.Bool(true),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
Expand All @@ -1014,8 +1005,8 @@ func TestRevisionDefaulting(t *testing.T) {
InitContainers: []corev1.Container{{
Name: "init",
SecurityContext: &corev1.SecurityContext{
RunAsNonRoot: ptr.Bool(true),
AllowPrivilegeEscalation: ptr.Bool(false),
RunAsNonRoot: ptr.Bool(true),
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
Expand Down
3 changes: 0 additions & 3 deletions pkg/reconciler/revision/resources/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ var (
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
SeccompProfile: &corev1.SeccompProfile{
Type: corev1.SeccompProfileTypeRuntimeDefault,
},
}
)

Expand Down
24 changes: 3 additions & 21 deletions test/e2e/grpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

"golang.org/x/sync/errgroup"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -68,9 +67,6 @@ func hasPort(u string) bool {

func dial(ctx *TestContext, host, domain string) (*grpc.ClientConn, error) {
defaultPort := "80"
if test.ServingFlags.HTTPS {
defaultPort = "443"
}
if !hasPort(host) {
host = net.JoinHostPort(host, defaultPort)
}
Expand All @@ -83,12 +79,6 @@ func dial(ctx *TestContext, host, domain string) (*grpc.ClientConn, error) {
}

creds := insecure.NewCredentials()
if test.ServingFlags.HTTPS {
tlsConfig := test.TLSClientConfig(context.Background(), ctx.t.Logf, ctx.clients)
// Set ServerName for pseudo hostname with TLS.
tlsConfig.ServerName = domain
creds = credentials.NewTLS(tlsConfig)
}

return grpc.Dial(
host,
Expand Down Expand Up @@ -321,11 +311,6 @@ func streamTest(tc *TestContext, host, domain string) {

func testGRPC(t *testing.T, f grpcTest, fopts ...rtesting.ServiceOption) {
t.Helper()
// TODO: https option with parallel leads to flakes.
// https://github.com/knative/serving/issues/11387
if !test.ServingFlags.HTTPS {
t.Parallel()
}

// Setup
clients := Setup(t)
Expand Down Expand Up @@ -366,16 +351,13 @@ func testGRPC(t *testing.T, f grpcTest, fopts ...rtesting.ServiceOption) {
}

host := url.Host
if !test.ServingFlags.ResolvableDomain {
if true {
addr, mapper, err := ingress.GetIngressEndpoint(context.Background(), clients.KubeClient, pkgTest.Flags.IngressEndpoint)
if err != nil {
t.Fatal("Could not get service endpoint:", err)
}
if test.ServingFlags.HTTPS {
host = net.JoinHostPort(addr, mapper("443"))
} else {
host = net.JoinHostPort(addr, mapper("80"))
}

host = net.JoinHostPort(addr, mapper("80"))
}

f(&TestContext{
Expand Down
3 changes: 0 additions & 3 deletions test/e2e/securedefaults/secure_pod_defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ func TestSecureDefaults(t *testing.T) {
if revisionSC.AllowPrivilegeEscalation == nil || *revisionSC.AllowPrivilegeEscalation {
t.Errorf("Expected allowPrivilegeEscalation: false, got %v", revisionSC.AllowPrivilegeEscalation)
}
if revisionSC.SeccompProfile == nil || revisionSC.SeccompProfile.Type != v1.SeccompProfileTypeRuntimeDefault {
t.Errorf("Expected seccompProfile to be RuntimeDefault, got: %v", revisionSC.SeccompProfile)
}
}

func TestUnsafePermitted(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions vendor/knative.dev/pkg/controller/stats_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (r *reporter) ReportReconcile(duration time.Duration, success string, key t
return err
}

metrics.RecordBatch(ctx, reconcileCountStat.M(1),
reconcileLatencyStat.M(duration.Milliseconds()))
// TODO skonto: fix latency histograms
metrics.Record(ctx, reconcileCountStat.M(1))
return nil
}
2 changes: 1 addition & 1 deletion vendor/knative.dev/pkg/test/helpers/name.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
const (
letterBytes = "abcdefghijklmnopqrstuvwxyz"
randSuffixLen = 8
nameLengthLimit = 50
nameLengthLimit = 40
sep = '-'
sepS = "-"
testNamePrefix = "Test"
Expand Down
Loading

0 comments on commit 1335642

Please sign in to comment.