forked from projectcontour/contour
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add conditions to HTTPProxy and TLSCertificateDelegation (projectcont…
…our#2706) Updates projectcontour#2495. This adds a new `DetailedCondition` type to HTTPProxy, that allows for sub-conditions. This allows Contour to have a `Valid` condition, that has further information about how that conditions `status` has been reached, or in other words, to expose more than one error or warning about a HTTPProxy to the user. Also adds the Conditions block to TLSCertificateDelegation. Signed-off-by: Nick Young <ynick@vmware.com>
- Loading branch information
Showing
9 changed files
with
1,568 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// Copyright Project Contour 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 | ||
// | ||
// http://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. | ||
|
||
// +k8s:deepcopy-gen=package | ||
|
||
// Package v1 is the v1 version of the API. | ||
// +groupName=projectcontour.io | ||
package v1 | ||
|
||
// SubCondition is a Condition-like type intended for use as a subcondition inside a DetailedCondition. | ||
// | ||
// It contains a subset of the Condition fields. | ||
// | ||
// It is intended for warnings and errors, so `type` names should use abnormal-true polarity, | ||
// that is, they should be of the form "ErrorPresent: true". | ||
// | ||
// The expected lifecycle for these errors is that they should only be present when the error or warning is, | ||
// and should be removed when they are not relevant. | ||
type SubCondition struct { | ||
// Type of condition in `CamelCase` or in `foo.example.com/CamelCase`. | ||
// | ||
// This must be in abnormal-true polarity, that is, `ErrorFound` or `controller.io/ErrorFound`. | ||
// | ||
// The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$` | ||
// +kubebuilder:validation:MaxLength=316 | ||
Type string `json:"type" protobuf:"bytes,1,opt,name=type"` | ||
// Status of the condition, one of True, False, Unknown. | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:Enum=True;False;Unknown | ||
Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"` | ||
// Reason contains a programmatic identifier indicating the reason for the condition's last transition. | ||
// Producers of specific condition types may define expected values and meanings for this field, | ||
// and whether the values are considered a guaranteed API. | ||
// | ||
// The value should be a CamelCase string. | ||
// | ||
// This field may not be empty. | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=1024 | ||
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:Pattern=`^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$` | ||
Reason string `json:"reason" protobuf:"bytes,3,opt,name=reason"` | ||
// Message is a human readable message indicating details about the transition. | ||
// | ||
// This may be an empty string. | ||
// | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=32768 | ||
Message string `json:"message" protobuf:"bytes,4,opt,name=message"` | ||
} | ||
|
||
// TODO(youngnick): Replace the inlined Condition with metav1.Condition once we have moved to a client-go | ||
// version that includes it. Also includes deleting kubeconditions.go. | ||
|
||
// DetailedCondition is an extension of the normal Kubernetes conditions, with two extra | ||
// fields to hold sub-conditions, which provide more detailed reasons for the state (True or False) | ||
// of the condition. | ||
// | ||
// `errors` holds information about sub-conditions which are fatal to that condition and render its state False. | ||
// | ||
// `warnings` holds information about sub-conditions which are not fatal to that condition and do not force the state to be False. | ||
// | ||
// Remember that Conditions have a type, a status, and a reason. | ||
// | ||
// The type is the type of the condition, the most important one in this CRD set is `Valid`. | ||
// | ||
// In the case of `Valid`, `status: true` means that the object is has been ingested into Contour with no errors. | ||
// `warnings` may still be present, and will be indicated in the Reason field. | ||
// | ||
// `Valid`, `status: false` means that the object has had one or more fatal errors during processing into Contour. | ||
// The details of the errors will be present under the `errors` field. | ||
// | ||
// There should never be subconditions under `errors` when `status` is `true`. | ||
type DetailedCondition struct { | ||
Condition `json:",inline"` | ||
// Errors contains a slice of relevant error subconditions for this object. | ||
// | ||
// Subconditions are expected to appear when relevant (when there is a error), and disappear when not relevant. | ||
// An empty slice here indicates no errors. | ||
// +optional | ||
Errors []SubCondition `json:"errors,omitempty"` | ||
// Warnings contains a slice of relevant warning subconditions for this object. | ||
// | ||
// Subconditions are expected to appear when relevant (when there is a warning), and disappear when not relevant. | ||
// An empty slice here indicates no warnings. | ||
// +optional | ||
Warnings []SubCondition `json:"warnings,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
Copyright 2015 The Kubernetes 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 | ||
http://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. | ||
*/ | ||
|
||
// +k8s:deepcopy-gen=package | ||
|
||
// Package v1 is the v1 version of the API. | ||
// +groupName=projectcontour.io | ||
package v1 | ||
|
||
// TODO(youngnick): This whole file is a copy-and-paste from | ||
// the current upstream master of "k8s.io/apimachinery/pkg/apis/meta/v1". | ||
// This should be removed once we update to a version of client-go | ||
// that includes a metav1.Condition type. | ||
import ( | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
) | ||
|
||
type ConditionStatus string | ||
|
||
// These are valid condition statuses. "ConditionTrue" means a resource is in the condition. | ||
// "ConditionFalse" means a resource is not in the condition. "ConditionUnknown" means kubernetes | ||
// can't decide if a resource is in the condition or not. In the future, we could add other | ||
// intermediate conditions, e.g. ConditionDegraded. | ||
const ( | ||
ConditionTrue ConditionStatus = "True" | ||
ConditionFalse ConditionStatus = "False" | ||
ConditionUnknown ConditionStatus = "Unknown" | ||
) | ||
|
||
// Condition contains details for one aspect of the current state of this API Resource. | ||
// | ||
// This struct is intended for direct use as an array at the field path .status.conditions. For example, | ||
// ```go | ||
// type FooStatus struct{ | ||
// // Represents the observations of a foo's current state. | ||
// // Known .status.conditions.type are: "Available", "Progressing", and "Degraded" | ||
// // +patchMergeKey=type | ||
// // +patchStrategy=merge | ||
// // +listType=map | ||
// // +listMapKey=type | ||
// Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` | ||
// | ||
// // other fields | ||
// } | ||
// ``` | ||
type Condition struct { | ||
// Type of condition in CamelCase or in foo.example.com/CamelCase. | ||
// | ||
// Many .condition.type values are consistent across resources like Available, but because arbitrary conditions can be | ||
// useful (see .node.status.conditions), the ability to deconflict is important. | ||
// | ||
// The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:Pattern=`^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$` | ||
// +kubebuilder:validation:MaxLength=316 | ||
Type string `json:"type" protobuf:"bytes,1,opt,name=type"` | ||
// status of the condition, one of True, False, Unknown. | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:Enum=True;False;Unknown | ||
Status ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"` | ||
// observedGeneration represents the .metadata.generation that the condition was set based upon. | ||
// | ||
// For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date | ||
// with respect to the current state of the instance. | ||
// +optional | ||
// +kubebuilder:validation:Minimum=0 | ||
ObservedGeneration int64 `json:"observedGeneration,omitempty" protobuf:"varint,3,opt,name=observedGeneration"` | ||
// lastTransitionTime is the last time the condition transitioned from one status to another. | ||
// | ||
// This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable. | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:Type=string | ||
// +kubebuilder:validation:Format=date-time | ||
LastTransitionTime metav1.Time `json:"lastTransitionTime" protobuf:"bytes,4,opt,name=lastTransitionTime"` | ||
// Reason contains a programmatic identifier indicating the reason for the condition's last transition. | ||
// | ||
// Producers of specific condition types may define expected values and meanings for this field, | ||
// and whether the values are considered a guaranteed API. | ||
// | ||
// The value should be a CamelCase string. | ||
// | ||
// This field may not be empty. | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=1024 | ||
// +kubebuilder:validation:MinLength=1 | ||
// +kubebuilder:validation:Pattern=`^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$` | ||
Reason string `json:"reason" protobuf:"bytes,5,opt,name=reason"` | ||
// message is a human readable message indicating details about the transition. | ||
// | ||
// This may be an empty string. | ||
// +required | ||
// +kubebuilder:validation:Required | ||
// +kubebuilder:validation:MaxLength=32768 | ||
Message string `json:"message" protobuf:"bytes,6,opt,name=message"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.