diff --git a/pkg/apis/serving/k8s_validation.go b/pkg/apis/serving/k8s_validation.go index d9126def062d..4ad544333083 100644 --- a/pkg/apis/serving/k8s_validation.go +++ b/pkg/apis/serving/k8s_validation.go @@ -456,11 +456,17 @@ func validateReadinessProbe(p *corev1.Probe) *apis.FieldError { // PeriodSeconds == 0 indicates Knative's special probe with aggressive retries if p.PeriodSeconds == 0 { if p.FailureThreshold != 0 { - errs = errs.Also(apis.ErrDisallowedFields("failureThreshold")) + errs = errs.Also(&apis.FieldError{ + Message: "failureThreshold is disallowed when periodSeconds is zero", + Paths: []string{"failureThreshold"}, + }) } if p.TimeoutSeconds != 0 { - errs = errs.Also(apis.ErrDisallowedFields("timeoutSeconds")) + errs = errs.Also(&apis.FieldError{ + Message: "timeoutSeconds is disallowed when periodSeconds is zero", + Paths: []string{"timeoutSeconds"}, + }) } } else { if p.TimeoutSeconds < 1 { diff --git a/pkg/apis/serving/k8s_validation_test.go b/pkg/apis/serving/k8s_validation_test.go index ce62fdeaa5b2..89ca1561ba40 100644 --- a/pkg/apis/serving/k8s_validation_test.go +++ b/pkg/apis/serving/k8s_validation_test.go @@ -610,7 +610,10 @@ func TestContainerValidation(t *testing.T) { }, }, }, - want: apis.ErrDisallowedFields("readinessProbe.failureThreshold"), + want: &apis.FieldError{ + Message: "failureThreshold is disallowed when periodSeconds is zero", + Paths: []string{"readinessProbe.failureThreshold"}, + }, }, { name: "invalid readiness probe (has timeoutSeconds while using special probe)", c: corev1.Container{ @@ -626,7 +629,10 @@ func TestContainerValidation(t *testing.T) { }, }, }, - want: apis.ErrDisallowedFields("readinessProbe.timeoutSeconds"), + want: &apis.FieldError{ + Message: "timeoutSeconds is disallowed when periodSeconds is zero", + Paths: []string{"readinessProbe.timeoutSeconds"}, + }, }, { name: "out of bounds probe values", c: corev1.Container{