Skip to content

Commit 34c4e15

Browse files
dinhxuanvutimflannagan
authored andcommitted
Add conditions array to OperatorCondition's spec (openshift#119)
* Add conditions array to OperatorCondition's spec The conditions array in the spec is now available for operator to create/update as the operator progresses through installation process. As the spec is updated, the object generation will be incremented and it can be used for tracking object changes. Signed-off-by: Vu Dinh <[email protected]> * Add OperatorCondition v2 with spec.conditions array Signed-off-by: Vu Dinh <[email protected]> Upstream-repository: api Upstream-commit: bb9b80e8278978efdb06a6f5d5682eb3cad330ec
1 parent 96d4948 commit 34c4e15

File tree

6 files changed

+389
-1
lines changed

6 files changed

+389
-1
lines changed

staging/api/crds/operators.coreos.com_operatorconditions.yaml

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,167 @@ spec:
135135
type: string
136136
maxLength: 316
137137
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])$
138+
served: false
139+
storage: false
140+
- name: v2
141+
schema:
142+
openAPIV3Schema:
143+
description: OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator.
144+
type: object
145+
required:
146+
- metadata
147+
properties:
148+
apiVersion:
149+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
150+
type: string
151+
kind:
152+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
153+
type: string
154+
metadata:
155+
type: object
156+
spec:
157+
description: OperatorConditionSpec allows a cluster admin to convey information about the state of an operator to OLM, potentially overriding state reported by the operator.
158+
type: object
159+
properties:
160+
deployments:
161+
type: array
162+
items:
163+
type: string
164+
overrides:
165+
type: array
166+
items:
167+
description: "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 []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
168+
type: object
169+
required:
170+
- message
171+
- reason
172+
- status
173+
- type
174+
properties:
175+
lastTransitionTime:
176+
description: 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.
177+
type: string
178+
format: date-time
179+
message:
180+
description: message is a human readable message indicating details about the transition. This may be an empty string.
181+
type: string
182+
maxLength: 32768
183+
observedGeneration:
184+
description: 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.
185+
type: integer
186+
format: int64
187+
minimum: 0
188+
reason:
189+
description: 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.
190+
type: string
191+
maxLength: 1024
192+
minLength: 1
193+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
194+
status:
195+
description: status of the condition, one of True, False, Unknown.
196+
type: string
197+
enum:
198+
- "True"
199+
- "False"
200+
- Unknown
201+
type:
202+
description: 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)
203+
type: string
204+
maxLength: 316
205+
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])$
206+
conditions:
207+
type: array
208+
items:
209+
description: "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 []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
210+
type: object
211+
required:
212+
- message
213+
- reason
214+
- status
215+
- type
216+
properties:
217+
lastTransitionTime:
218+
description: 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.
219+
type: string
220+
format: date-time
221+
message:
222+
description: message is a human readable message indicating details about the transition. This may be an empty string.
223+
type: string
224+
maxLength: 32768
225+
observedGeneration:
226+
description: 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.
227+
type: integer
228+
format: int64
229+
minimum: 0
230+
reason:
231+
description: 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.
232+
type: string
233+
maxLength: 1024
234+
minLength: 1
235+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
236+
status:
237+
description: status of the condition, one of True, False, Unknown.
238+
type: string
239+
enum:
240+
- "True"
241+
- "False"
242+
- Unknown
243+
type:
244+
description: 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)
245+
type: string
246+
maxLength: 316
247+
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])$
248+
serviceAccounts:
249+
type: array
250+
items:
251+
type: string
252+
status:
253+
description: OperatorConditionStatus allows an operator to convey information its state to OLM. The status may trail the actual state of a system.
254+
type: object
255+
properties:
256+
conditions:
257+
type: array
258+
items:
259+
description: "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 []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
260+
type: object
261+
required:
262+
- lastTransitionTime
263+
- message
264+
- reason
265+
- status
266+
- type
267+
properties:
268+
lastTransitionTime:
269+
description: 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.
270+
type: string
271+
format: date-time
272+
message:
273+
description: message is a human readable message indicating details about the transition. This may be an empty string.
274+
type: string
275+
maxLength: 32768
276+
observedGeneration:
277+
description: 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.
278+
type: integer
279+
format: int64
280+
minimum: 0
281+
reason:
282+
description: 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.
283+
type: string
284+
maxLength: 1024
285+
minLength: 1
286+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
287+
status:
288+
description: status of the condition, one of True, False, Unknown.
289+
type: string
290+
enum:
291+
- "True"
292+
- "False"
293+
- Unknown
294+
type:
295+
description: 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)
296+
type: string
297+
maxLength: 316
298+
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])$
138299
served: true
139300
storage: true
140301
subresources:

staging/api/pkg/operators/v1/operatorcondition_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ type OperatorConditionStatus struct {
2424

2525
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2626
// +genclient
27-
// +kubebuilder:storageversion
2827
// +kubebuilder:resource:shortName=condition,categories=olm
2928
// +kubebuilder:subresource:status
3029
// OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator.

staging/api/pkg/operators/v2/doc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// +groupName=operators.coreos.com
2+
3+
// Package v2 contains resources types for version v2 of the operators.coreos.com API group.
4+
package v2
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// +kubebuilder:object:generate=true
2+
3+
// Package v2 contains API Schema definitions for the operator v2 API group.
4+
package v2
5+
6+
import (
7+
"k8s.io/apimachinery/pkg/runtime/schema"
8+
"sigs.k8s.io/controller-runtime/pkg/scheme"
9+
)
10+
11+
var (
12+
// GroupVersion is group version used to register these objects.
13+
GroupVersion = schema.GroupVersion{Group: "operators.coreos.com", Version: "v2"}
14+
15+
// SchemeGroupVersion is required for compatibility with client generation.
16+
SchemeGroupVersion = GroupVersion
17+
18+
// SchemeBuilder is used to add go types to the GroupVersionKind scheme.
19+
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}
20+
21+
// AddToScheme adds the types in this group-version to the given scheme.
22+
AddToScheme = SchemeBuilder.AddToScheme
23+
)
24+
25+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
26+
func Resource(resource string) schema.GroupResource {
27+
return GroupVersion.WithResource(resource).GroupResource()
28+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package v2
2+
3+
import (
4+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
5+
)
6+
7+
const (
8+
// Upgradeable indicates that the operator is upgradeable
9+
Upgradeable string = "Upgradeable"
10+
)
11+
12+
// OperatorConditionSpec allows an operator to report state to OLM and provides
13+
// cluster admin with the ability to manually override state reported by the operator.
14+
type OperatorConditionSpec struct {
15+
ServiceAccounts []string `json:"serviceAccounts,omitempty"`
16+
Deployments []string `json:"deployments,omitempty"`
17+
Overrides []metav1.Condition `json:"overrides,omitempty"`
18+
Conditions []metav1.Condition `json:"conditions,omitempty"`
19+
}
20+
21+
// OperatorConditionStatus allows OLM to convey which conditions have been observed.
22+
type OperatorConditionStatus struct {
23+
Conditions []metav1.Condition `json:"conditions,omitempty"`
24+
}
25+
26+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
27+
// +genclient
28+
// +kubebuilder:storageversion
29+
// +kubebuilder:resource:shortName=condition,categories=olm
30+
// +kubebuilder:subresource:status
31+
// OperatorCondition is a Custom Resource of type `OperatorCondition` which is used to convey information to OLM about the state of an operator.
32+
type OperatorCondition struct {
33+
metav1.TypeMeta `json:",inline"`
34+
metav1.ObjectMeta `json:"metadata"`
35+
36+
Spec OperatorConditionSpec `json:"spec,omitempty"`
37+
Status OperatorConditionStatus `json:"status,omitempty"`
38+
}
39+
40+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
41+
// OperatorConditionList represents a list of Conditions.
42+
type OperatorConditionList struct {
43+
metav1.TypeMeta `json:",inline"`
44+
metav1.ListMeta `json:"metadata"`
45+
46+
Items []OperatorCondition `json:"items"`
47+
}
48+
49+
func init() {
50+
SchemeBuilder.Register(&OperatorCondition{}, &OperatorConditionList{})
51+
}

0 commit comments

Comments
 (0)