Skip to content

Commit faa9f65

Browse files
committed
STOR-2859: Add APIs for disabling force detach in KCM operator
1 parent c16ec2b commit faa9f65

9 files changed

Lines changed: 659 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
2+
name: "ControllerManager"
3+
crdName: controllermanagers.config.openshift.io
4+
tests:
5+
onCreate:
6+
- name: Should be able to create with default values
7+
initial: |
8+
apiVersion: config.openshift.io/v1
9+
kind: ControllerManager
10+
spec:
11+
forceDetachOnTimeout:
12+
expected: |
13+
apiVersion: config.openshift.io/v1
14+
kind: ControllerManager
15+
spec:
16+
forceDetachOnTimeout: Enabled
17+
- name: Should be able to create with force detach enabled
18+
initial: |
19+
apiVersion: config.openshift.io/v1
20+
kind: ControllerManager
21+
spec:
22+
forceDetachOnTimeout: Enabled
23+
expected: |
24+
apiVersion: config.openshift.io/v1
25+
kind: ControllerManager
26+
spec:
27+
forceDetachOnTimeout: Enabled
28+
- name: Should be able to create with force detach disabled
29+
initial: |
30+
apiVersion: config.openshift.io/v1
31+
kind: ControllerManager
32+
spec:
33+
forceDetachOnTimeout: Disabled
34+
expected: |
35+
apiVersion: config.openshift.io/v1
36+
kind: ControllerManager
37+
spec:
38+
forceDetachOnTimeout: Disabled
39+
- name: Should reject unsupported value of forceDetachOnTimeout
40+
initial: |
41+
apiVersion: config.openshift.io/v1
42+
kind: ControllerManager
43+
spec:
44+
forceDetachOnTimeout: INVALID
45+
expectedError: "spec.forceDetachOnTimeout: Unsupported value: \"INVALID\": supported values: \"Enabled\", \"Disabled\""
46+
onUpdate:
47+
- name: Enabled to Disabled
48+
initial: |
49+
apiVersion: config.openshift.io/v1
50+
kind: ControllerManager
51+
spec:
52+
forceDetachOnTimeout: Enabled
53+
updated: |
54+
apiVersion: config.openshift.io/v1
55+
kind: ControllerManager
56+
spec:
57+
forceDetachOnTimeout: Disabled
58+
expected: |
59+
apiVersion: config.openshift.io/v1
60+
kind: ControllerManager
61+
spec:
62+
forceDetachOnTimeout: Disabled
63+
- name: Disabled to default value
64+
initial: |
65+
apiVersion: config.openshift.io/v1
66+
kind: ControllerManager
67+
spec:
68+
forceDetachOnTimeout: Disabled
69+
updated: |
70+
apiVersion: config.openshift.io/v1
71+
kind: ControllerManager
72+
spec:
73+
forceDetachOnTimeout:
74+
expected: |
75+
apiVersion: config.openshift.io/v1
76+
kind: ControllerManager
77+
spec:
78+
forceDetachOnTimeout: Enabled
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package v1
2+
3+
import metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4+
5+
// +genclient
6+
// +genclient:nonNamespaced
7+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
8+
9+
// ControllerManager holds cluster-wide config information to run the Kubernetes controller manager
10+
// and influence its placement decisions. The canonical name for this config is `cluster`.
11+
//
12+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
13+
// +openshift:compatibility-gen:level=1
14+
// +openshift:api-approved.openshift.io=https://github.com/openshift/api/pull/2668
15+
// +openshift:file-pattern=cvoRunLevel=0000_10,operatorName=config-operator,operatorOrdering=01
16+
// +kubebuilder:object:root=true
17+
// +kubebuilder:resource:path=controllermanagers,scope=Cluster
18+
// +kubebuilder:subresource:status
19+
// +kubebuilder:metadata:annotations=release.openshift.io/bootstrap-required=true
20+
type ControllerManager struct {
21+
metav1.TypeMeta `json:",inline"`
22+
23+
// metadata is the standard object's metadata.
24+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
25+
// +optional
26+
metav1.ObjectMeta `json:"metadata,omitzero"`
27+
// spec holds user settable values for configuration
28+
// +required
29+
Spec ControllerManagerSpec `json:"spec,omitzero"`
30+
// status holds observed values from the cluster. They may not be overridden.
31+
// +optional
32+
Status ControllerManagerStatus `json:"status,omitzero"`
33+
}
34+
35+
// ControllerManagerSpec defines the desired state of the Kubernetes controller manager
36+
// +kubebuilder:validation:MinProperties=1
37+
type ControllerManagerSpec struct {
38+
// forceDetachOnTimeout expresses whether to allow kube-controller-manager
39+
// to force detach volumes when unmount takes longer than the timeout.
40+
// Valid values are Enabled and Disabled. If omitted, the default is Enabled.
41+
// +default="Enabled"
42+
// +optional
43+
ForceDetachOnTimeout ForceDetachOnTimeoutPolicy `json:"forceDetachOnTimeout,omitempty"`
44+
}
45+
46+
// +kubebuilder:validation:Enum=Enabled;Disabled
47+
type ForceDetachOnTimeoutPolicy string
48+
49+
const (
50+
// ForceDetachOnTimeoutEnabled will allow kube-controller-manager to
51+
// force detach volumes based on maximum unmount time and node status.
52+
ForceDetachOnTimeoutEnabled ForceDetachOnTimeoutPolicy = "Enabled"
53+
// ForceDetachOnTimeoutDisabled will prevent kube-controller-manager
54+
// from force detaching volumes.
55+
ForceDetachOnTimeoutDisabled ForceDetachOnTimeoutPolicy = "Disabled"
56+
)
57+
58+
// ControllerManagerStatus defines the observed state of the Kubernetes controller manager
59+
// +kubebuilder:validation:MinProperties=1
60+
type ControllerManagerStatus struct {
61+
}
62+
63+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
64+
65+
// Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
66+
// +openshift:compatibility-gen:level=1
67+
type ControllerManagerList struct {
68+
metav1.TypeMeta `json:",inline"`
69+
70+
// metadata is the standard list's metadata.
71+
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
72+
metav1.ListMeta `json:"metadata"`
73+
74+
Items []ControllerManager `json:"items"`
75+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
apiVersion: apiextensions.k8s.io/v1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
annotations:
5+
api-approved.openshift.io: https://github.com/openshift/api/pull/2668
6+
api.openshift.io/merged-by-featuregates: "true"
7+
include.release.openshift.io/ibm-cloud-managed: "true"
8+
include.release.openshift.io/self-managed-high-availability: "true"
9+
release.openshift.io/bootstrap-required: "true"
10+
name: controllermanagers.config.openshift.io
11+
spec:
12+
group: config.openshift.io
13+
names:
14+
kind: ControllerManager
15+
listKind: ControllerManagerList
16+
plural: controllermanagers
17+
singular: controllermanager
18+
scope: Cluster
19+
versions:
20+
- name: v1
21+
schema:
22+
openAPIV3Schema:
23+
description: |-
24+
ControllerManager holds cluster-wide config information to run the Kubernetes controller manager
25+
and influence its placement decisions. The canonical name for this config is `cluster`.
26+
27+
Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer).
28+
properties:
29+
apiVersion:
30+
description: |-
31+
APIVersion defines the versioned schema of this representation of an object.
32+
Servers should convert recognized schemas to the latest internal value, and
33+
may reject unrecognized values.
34+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
35+
type: string
36+
kind:
37+
description: |-
38+
Kind is a string value representing the REST resource this object represents.
39+
Servers may infer this from the endpoint the client submits requests to.
40+
Cannot be updated.
41+
In CamelCase.
42+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
43+
type: string
44+
metadata:
45+
type: object
46+
spec:
47+
description: spec holds user settable values for configuration
48+
minProperties: 1
49+
properties:
50+
forceDetachOnTimeout:
51+
default: Enabled
52+
description: |-
53+
forceDetachOnTimeout expresses whether to allow kube-controller-manager
54+
to force detach volumes when unmount takes longer than the timeout.
55+
Valid values are Enabled and Disabled. If omitted, the default is Enabled.
56+
enum:
57+
- Enabled
58+
- Disabled
59+
type: string
60+
type: object
61+
status:
62+
description: status holds observed values from the cluster. They may not
63+
be overridden.
64+
minProperties: 1
65+
type: object
66+
required:
67+
- spec
68+
type: object
69+
served: true
70+
storage: true
71+
subresources:
72+
status: {}

config/v1/zz_generated.deepcopy.go

Lines changed: 93 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/v1/zz_generated.featuregated-crd-manifests.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,28 @@ consoles.config.openshift.io:
197197
TopLevelFeatureGates: []
198198
Version: v1
199199

200+
controllermanagers.config.openshift.io:
201+
Annotations:
202+
release.openshift.io/bootstrap-required: "true"
203+
ApprovedPRNumber: https://github.com/openshift/api/pull/2668
204+
CRDName: controllermanagers.config.openshift.io
205+
Capability: ""
206+
Category: ""
207+
FeatureGates: []
208+
FilenameOperatorName: config-operator
209+
FilenameOperatorOrdering: "01"
210+
FilenameRunLevel: "0000_10"
211+
GroupName: config.openshift.io
212+
HasStatus: true
213+
KindName: ControllerManager
214+
Labels: {}
215+
PluralName: controllermanagers
216+
PrinterColumns: []
217+
Scope: Cluster
218+
ShortNames: null
219+
TopLevelFeatureGates: []
220+
Version: v1
221+
200222
dnses.config.openshift.io:
201223
Annotations:
202224
release.openshift.io/bootstrap-required: "true"

0 commit comments

Comments
 (0)