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

MCO-1010: Add node disruption policies to MachineConfiguration CRD #1764

Merged
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions config/v1/feature_gates.go
Original file line number Diff line number Diff line change
Expand Up @@ -553,4 +553,11 @@ var (
productScope(ocpSpecific).
enableIn(TechPreviewNoUpgrade).
mustRegister()

FeatureGateNodeDisruptionPolicy = newFeatureGate("NodeDisruptionPolicy").
reportProblemsToJiraComponent("MachineConfigOperator").
contactPerson("jerzhang").
productScope(ocpSpecific).
enableIn(TechPreviewNoUpgrade).
mustRegister()
)
1 change: 1 addition & 0 deletions features.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
| MetricsServer| | | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| MixedCPUsAllocation| | | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| NewOLM| | | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| NodeDisruptionPolicy| | | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| NodeSwap| | | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| OnClusterBuild| | | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| PinnedImages| | | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
Expand Down
566 changes: 564 additions & 2 deletions openapi/generated_openapi/zz_generated.openapi.go

Large diffs are not rendered by default.

310 changes: 310 additions & 0 deletions openapi/openapi.json

Large diffs are not rendered by default.

209 changes: 209 additions & 0 deletions operator/v1/techpreview.machineconfiguration.testsuite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,212 @@ tests:
selection:
mode: All
expectedError: "spec.managedBootImages.machineManagers[1]: Duplicate value: map[string]interface {}{\"apiGroup\":\"machine.openshift.io\", \"resource\":\"machinesets\"}"
- name: Should be able to create a valid node disruption policy
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: my.service
units:
- name: "my.service"
actions:
- type: Restart
restart:
serviceName: my-other.service
sshkey:
actions:
- type: None
expected: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
logLevel: Normal
operatorLogLevel: Normal
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: my.service
units:
- name: "my.service"
actions:
- type: Restart
restart:
serviceName: my-other.service
sshkey:
actions:
- type: None
- name: Should be able to define a node disruption policy with multiple entries of the same type
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: my.service
- path: "/etc/my-other-file"
actions:
- type: Drain
- type: Restart
restart:
serviceName: my.service
expected: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
logLevel: Normal
operatorLogLevel: Normal
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: my.service
- path: "/etc/my-other-file"
actions:
- type: Drain
- type: Restart
restart:
serviceName: my.service
- name: Node disruption policies with duplicate file entries should fail
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: my.service
- path: "/etc/my-file"
actions:
- type: Drain
- type: Reload
reload:
serviceName: my.service
expectedError: "spec.nodeDisruptionPolicy.files[1]: Duplicate value: map[string]interface {}{\"path\":\"/etc/my-file\"}"
- name: Node disruption policies that specify a reload action should fail if you don't specify the reload field
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
expectedError: "reload is required when type is Reload, and forbidden otherwise"
- name: Node disruption policies that specify a reboot action should not allow other actions in the list
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: Reboot
- type: DaemonReload
expectedError: "Reboot action can only be specified standalone, as it will override any other actions"
- name: Node disruption policies should use service name(s) which have a valid name prefix.
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: .service
expectedError: "Invalid ${NAME} in service name. Expected format is ${NAME}${SERVICETYPE}, where {NAME} must be atleast 1 character long and can only consist of alphabets, digits, \":\", \"-\", \"_\", \".\", and \"\\\""
- name: Node disruption policies should use service name(s) which have a valid name suffix.
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: service
expectedError: "Invalid ${SERVICETYPE} in service name. Expected format is ${NAME}${SERVICETYPE}, where ${SERVICETYPE} must be one of \".service\", \".socket\", \".device\", \".mount\", \".automount\", \".swap\", \".target\", \".path\", \".timer\",\".snapshot\", \".slice\" or \".scope\"."
- name: Node disruption policies should use service name(s) which have a valid name suffix.
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: serv.ice
expectedError: "Invalid ${SERVICETYPE} in service name. Expected format is ${NAME}${SERVICETYPE}, where ${SERVICETYPE} must be one of \".service\", \".socket\", \".device\", \".mount\", \".automount\", \".swap\", \".target\", \".path\", \".timer\",\".snapshot\", \".slice\" or \".scope\"."
- name: Should be able to define a node disruption policy that has a service name which has multiple permitted special characters
initial: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: a:b_c-d\.e.swap
- path: "/etc/my-other-file"
actions:
- type: Drain
- type: Restart
restart:
serviceName: a.b.c.d.e.snapshot
expected: |
apiVersion: operator.openshift.io/v1
kind: MachineConfiguration
spec:
logLevel: Normal
operatorLogLevel: Normal
nodeDisruptionPolicy:
files:
- path: "/etc/my-file"
actions:
- type: DaemonReload
- type: Reload
reload:
serviceName: a:b_c-d\.e.swap
- path: "/etc/my-other-file"
actions:
- type: Drain
- type: Restart
restart:
serviceName: a.b.c.d.e.snapshot
Loading