From 22c1c0e206252a2f9793ed2dcec20832e9e044f2 Mon Sep 17 00:00:00 2001 From: Mike Morris Date: Thu, 9 May 2024 21:10:04 -0400 Subject: [PATCH] apis: add GatewayClassConditionReason Unsupported (#3048) * apis: add GatewayClassConditionReason Invalid Clarify description for when GatewayClassConditionReason InvalidParameters should be preferred. * doc: clarify expected behavior for bad reference in GatewayClass ParametersRef * docs: GatewayClass SHOULD be rejected with InvalidParameters reason * apis: switch from Invalid reason to Unsupported * fixup codegen and yamllint --------- Co-authored-by: Mike Morris <1149913+mikemorris@users.noreply.github.com> --- apis/v1/gatewayclass_types.go | 19 ++++++++++++++----- ...eway.networking.k8s.io_gatewayclasses.yaml | 12 ++++++++---- ...eway.networking.k8s.io_gatewayclasses.yaml | 12 ++++++++---- pkg/generated/openapi/zz_generated.openapi.go | 2 +- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/apis/v1/gatewayclass_types.go b/apis/v1/gatewayclass_types.go index 21875dce19..66ff5ba3f6 100644 --- a/apis/v1/gatewayclass_types.go +++ b/apis/v1/gatewayclass_types.go @@ -93,8 +93,10 @@ type GatewayClassSpec struct { // or an implementation-specific custom resource. The resource can be // cluster-scoped or namespace-scoped. // - // If the referent cannot be found, the GatewayClass's "InvalidParameters" - // status condition will be true. + // If the referent cannot be found, refers to an unsupported kind, or when + // the data within that resource is malformed, the GatewayClass SHOULD be + // rejected with the "Accepted" status condition set to "False" and an + // "InvalidParameters" reason. // // A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, // the merging behavior is implementation specific. @@ -162,6 +164,7 @@ const ( // Possible reasons for this condition to be False are: // // * "InvalidParameters" + // * "Unsupported" // * "UnsupportedVersion" // // Possible reasons for this condition to be Unknown are: @@ -176,9 +179,10 @@ const ( // true. GatewayClassReasonAccepted GatewayClassConditionReason = "Accepted" - // This reason is used with the "Accepted" condition when the - // GatewayClass was not accepted because the parametersRef field - // was invalid, with more detail in the message. + // This reason is used with the "Accepted" condition when the GatewayClass + // was not accepted because the parametersRef field refers to a nonexistent + // or unsupported resource or kind, or when the data within that resource is + // malformed. GatewayClassReasonInvalidParameters GatewayClassConditionReason = "InvalidParameters" // This reason is used with the "Accepted" condition when the @@ -187,6 +191,11 @@ const ( // GatewayClass. GatewayClassReasonPending GatewayClassConditionReason = "Pending" + // This reason is used with the "Accepted" condition when the GatewayClass + // was not accepted because the implementation does not support a + // user-defined GatewayClass. + GatewayClassReasonUnsupported GatewayClassConditionReason = "Unsupported" + // Deprecated: Use "Pending" instead. GatewayClassReasonWaiting GatewayClassConditionReason = "Waiting" ) diff --git a/config/crd/experimental/gateway.networking.k8s.io_gatewayclasses.yaml b/config/crd/experimental/gateway.networking.k8s.io_gatewayclasses.yaml index 2d1095c1da..c33f0dbd3d 100644 --- a/config/crd/experimental/gateway.networking.k8s.io_gatewayclasses.yaml +++ b/config/crd/experimental/gateway.networking.k8s.io_gatewayclasses.yaml @@ -115,8 +115,10 @@ spec: cluster-scoped or namespace-scoped. - If the referent cannot be found, the GatewayClass's "InvalidParameters" - status condition will be true. + If the referent cannot be found, refers to an unsupported kind, or when + the data within that resource is malformed, the GatewayClass SHOULD be + rejected with the "Accepted" status condition set to "False" and an + "InvalidParameters" reason. A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, @@ -375,8 +377,10 @@ spec: cluster-scoped or namespace-scoped. - If the referent cannot be found, the GatewayClass's "InvalidParameters" - status condition will be true. + If the referent cannot be found, refers to an unsupported kind, or when + the data within that resource is malformed, the GatewayClass SHOULD be + rejected with the "Accepted" status condition set to "False" and an + "InvalidParameters" reason. A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, diff --git a/config/crd/standard/gateway.networking.k8s.io_gatewayclasses.yaml b/config/crd/standard/gateway.networking.k8s.io_gatewayclasses.yaml index be17e646db..5621311f44 100644 --- a/config/crd/standard/gateway.networking.k8s.io_gatewayclasses.yaml +++ b/config/crd/standard/gateway.networking.k8s.io_gatewayclasses.yaml @@ -115,8 +115,10 @@ spec: cluster-scoped or namespace-scoped. - If the referent cannot be found, the GatewayClass's "InvalidParameters" - status condition will be true. + If the referent cannot be found, refers to an unsupported kind, or when + the data within that resource is malformed, the GatewayClass SHOULD be + rejected with the "Accepted" status condition set to "False" and an + "InvalidParameters" reason. A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, @@ -363,8 +365,10 @@ spec: cluster-scoped or namespace-scoped. - If the referent cannot be found, the GatewayClass's "InvalidParameters" - status condition will be true. + If the referent cannot be found, refers to an unsupported kind, or when + the data within that resource is malformed, the GatewayClass SHOULD be + rejected with the "Accepted" status condition set to "False" and an + "InvalidParameters" reason. A Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 42b6eb6227..e9c9b17c18 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -3623,7 +3623,7 @@ func schema_sigsk8sio_gateway_api_apis_v1_GatewayClassSpec(ref common.ReferenceC }, "parametersRef": { SchemaProps: spec.SchemaProps{ - Description: "ParametersRef is a reference to a resource that contains the configuration parameters corresponding to the GatewayClass. This is optional if the controller does not require any additional configuration.\n\nParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, or an implementation-specific custom resource. The resource can be cluster-scoped or namespace-scoped.\n\nIf the referent cannot be found, the GatewayClass's \"InvalidParameters\" status condition will be true.\n\nA Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, the merging behavior is implementation specific. It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway.\n\nSupport: Implementation-specific", + Description: "ParametersRef is a reference to a resource that contains the configuration parameters corresponding to the GatewayClass. This is optional if the controller does not require any additional configuration.\n\nParametersRef can reference a standard Kubernetes resource, i.e. ConfigMap, or an implementation-specific custom resource. The resource can be cluster-scoped or namespace-scoped.\n\nIf the referent cannot be found, refers to an unsupported kind, or when the data within that resource is malformed, the GatewayClass SHOULD be rejected with the \"Accepted\" status condition set to \"False\" and an \"InvalidParameters\" reason.\n\nA Gateway for this GatewayClass may provide its own `parametersRef`. When both are specified, the merging behavior is implementation specific. It is generally recommended that GatewayClass provides defaults that can be overridden by a Gateway.\n\nSupport: Implementation-specific", Ref: ref("sigs.k8s.io/gateway-api/apis/v1.ParametersReference"), }, },