Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/apis/serving/fieldmask.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"slices"

corev1 "k8s.io/api/core/v1"

"knative.dev/serving/pkg/apis/config"
)

Expand Down Expand Up @@ -384,6 +385,7 @@ func ProbeMask(in *corev1.Probe) *corev1.Probe {
out.PeriodSeconds = in.PeriodSeconds
out.SuccessThreshold = in.SuccessThreshold
out.FailureThreshold = in.FailureThreshold
out.TerminationGracePeriodSeconds = in.TerminationGracePeriodSeconds

return out
}
Expand Down
14 changes: 8 additions & 6 deletions pkg/apis/serving/fieldmask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"k8s.io/apimachinery/pkg/util/intstr"
"knative.dev/pkg/kmp"
"knative.dev/pkg/ptr"

"knative.dev/serving/pkg/apis/config"
)

Expand Down Expand Up @@ -395,12 +396,13 @@ func TestVolumeMountMask_FeatMountPropagation(t *testing.T) {

func TestProbeMask(t *testing.T) {
want := &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{},
InitialDelaySeconds: 42,
TimeoutSeconds: 42,
PeriodSeconds: 42,
SuccessThreshold: 42,
FailureThreshold: 42,
ProbeHandler: corev1.ProbeHandler{},
InitialDelaySeconds: 42,
TimeoutSeconds: 42,
PeriodSeconds: 42,
SuccessThreshold: 42,
FailureThreshold: 42,
TerminationGracePeriodSeconds: ptr.Int64(30),
}
in := want

Expand Down
53 changes: 53 additions & 0 deletions pkg/apis/serving/k8s_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,7 @@ func TestUserContainerValidation(t *testing.T) {
ProbeHandler: corev1.ProbeHandler{
Exec: &corev1.ExecAction{},
},
TerminationGracePeriodSeconds: ptr.Int64(10),
},
},
want: nil,
Expand Down Expand Up @@ -1859,6 +1860,7 @@ func TestUserContainerValidation(t *testing.T) {
Path: "/",
},
},
TerminationGracePeriodSeconds: ptr.Int64(10),
},
},
want: nil,
Expand Down Expand Up @@ -1913,6 +1915,7 @@ func TestUserContainerValidation(t *testing.T) {
Port: intstr.FromInt(5000),
},
},
TerminationGracePeriodSeconds: ptr.Int64(10),
},
},
want: nil,
Expand Down Expand Up @@ -2173,6 +2176,18 @@ func TestSidecarContainerValidation(t *testing.T) {
TCPSocket: &corev1.TCPSocketAction{},
},
},
StartupProbe: &corev1.Probe{
PeriodSeconds: 1,
TimeoutSeconds: 1,
SuccessThreshold: 1,
FailureThreshold: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
},
},
TerminationGracePeriodSeconds: ptr.Int64(10),
},
},
want: apis.ErrDisallowedFields("livenessProbe", "readinessProbe", "readinessProbe.failureThreshold", "readinessProbe.periodSeconds", "readinessProbe.successThreshold", "readinessProbe.timeoutSeconds"),
}, {
Expand Down Expand Up @@ -2223,6 +2238,43 @@ func TestSidecarContainerValidation(t *testing.T) {
},
cfgOpts: []configOption{withMultiContainerProbesEnabled()},
want: nil,
}, {
name: "invalid with startup probe",
c: corev1.Container{
Image: "foo",
StartupProbe: &corev1.Probe{
PeriodSeconds: 1,
TimeoutSeconds: 1,
SuccessThreshold: 1,
FailureThreshold: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
},
},
TerminationGracePeriodSeconds: ptr.Int64(10),
},
},
want: nil,
}, {
name: "valid with startup probe and multi container probing",
c: corev1.Container{
Image: "foo",
StartupProbe: &corev1.Probe{
PeriodSeconds: 1,
TimeoutSeconds: 1,
SuccessThreshold: 1,
FailureThreshold: 3,
ProbeHandler: corev1.ProbeHandler{
HTTPGet: &corev1.HTTPGetAction{
Path: "/",
},
},
TerminationGracePeriodSeconds: ptr.Int64(10),
},
},
cfgOpts: []configOption{withMultiContainerProbesEnabled()},
want: nil,
}, {
name: "invalid with no handler",
c: corev1.Container{
Expand Down Expand Up @@ -2283,6 +2335,7 @@ func TestSidecarContainerValidation(t *testing.T) {
Port: intstr.FromInt(5000),
},
},
TerminationGracePeriodSeconds: ptr.Int64(10),
},
},
cfgOpts: []configOption{withMultiContainerProbesEnabled()},
Expand Down
Loading