Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing tags to []conditions which got reported by crd checker #584

Closed
wants to merge 1 commit into from
Closed
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
55 changes: 49 additions & 6 deletions modules/common/condition/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,50 @@ const (
)

// Type - A summarizing name for a given condition
// ---
// 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)
// +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 Type string

// Reason - Why a particular condition is true, false or unknown
// 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.
// +kubebuilder:validation:MaxLength=1024
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Pattern=`^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$`
type Reason string

// Condition defines an observation of a API resource operational state.
// 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,
//
// 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 []condition.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
//
// // other fields
// }
type Condition struct {
// Type of condition in CamelCase.
// +required
// +kubebuilder:validation:Required
Type Type `json:"type"`

// Status of the condition, one of True, False, Unknown.
// status of the condition, one of True, False, Unknown.
// +required
Copy link
Contributor

@bogdando bogdando Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as Conditions got included into CRDs, we cannot change optional fields to become required, do we?
Also, how that change passes the crd checker? Let's try to include this into some operator as a dependency and see if crd checker allows that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is already required.

              conditions:
                description: Conditions
                items:
                  description: Condition defines an observation of a API resource
                    operational state.
                  properties:
                    lastTransitionTime:
                      description: 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.
                      format: date-time
                      type: string
                    message:
                      description: A human readable message indicating details about
                        the transition.
                      type: string
                    reason:
                      description: The reason for the condition's last transition
                        in CamelCase.
                      type: string
                    severity:
                      description: Severity provides a classification of Reason code,
                        so the current situation is immediately understandable and
                        could act accordingly. It is meant for situations where Status=False
                        and it should be indicated if it is just informational, warning
                        (next reconciliation might fix it) or an error (e.g. DB create
                        issue and no actions to automatically resolve the issue can/should
                        be done). For conditions where Status=Unknown or Status=True
                        the Severity should be SeverityNone.
                      type: string
                    status:
                      description: Status of the condition, one of True, False, Unknown.
                      type: string
                    type:
                      description: Type of condition in CamelCase.
                      type: string
                  required:
                  - lastTransitionTime
                  - status
                  - type
                  type: object
                type: array

but we probably go just with #585 for now.

// +kubebuilder:validation:Required
// +kubebuilder:validation:Enum=True;False;Unknown
Status corev1.ConditionStatus `json:"status"`

// Severity provides a classification of Reason code, so the current situation is immediately
Expand All @@ -62,20 +95,30 @@ type Condition struct {
// For conditions where Status=Unknown or Status=True the Severity should be SeverityNone.
Severity Severity `json:"severity,omitempty"`

// 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.
// 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"`

// The reason for the condition's last transition in CamelCase.
// +optional
Reason Reason `json:"reason,omitempty"`

// A human readable message indicating details about the transition.
// message is a human readable message indicating details about the transition.
// This may be an empty string.
// +optional
// +kubebuilder:validation:MaxLength=32768
Message string `json:"message,omitempty"`
}

// Conditions provide observations of the operational state of a API resource.
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
type Conditions []Condition

// conditionGroup defines a group of conditions with the same status and severity,
Expand Down
Loading