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

ETCD-520: add etcd dbsize field #1736

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
1 change: 1 addition & 0 deletions features.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
| CSIDriverSharedResource| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| DNSNameResolver| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| DynamicResourceAllocation| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| EtcdBackendQuota| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| Example| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| ExternalRouteCertificate| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
| GCPClusterHostedDNS| | | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> | <span style="background-color: #519450">Enabled</span> |
Expand Down
7 changes: 7 additions & 0 deletions features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,13 @@ var (
enableIn(configv1.DevPreviewNoUpgrade, configv1.TechPreviewNoUpgrade).
mustRegister()

FeatureGateBackendQuotaGiB = newFeatureGate("EtcdBackendQuota").
reportProblemsToJiraComponent("etcd").
contactPerson("hasbro17").
productScope(ocpSpecific).
enableIn(configv1.DevPreviewNoUpgrade, configv1.TechPreviewNoUpgrade).
mustRegister()

FeatureGateAutomatedEtcdBackup = newFeatureGate("AutomatedEtcdBackup").
reportProblemsToJiraComponent("etcd").
contactPerson("hasbro17").
Expand Down
8 changes: 8 additions & 0 deletions openapi/generated_openapi/zz_generated.openapi.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions openapi/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -27072,6 +27072,12 @@
"forceRedeploymentReason"
],
"properties": {
"backendQuotaGiB": {
"description": "backendQuotaGiB sets the etcd backend storage size limit in gibibytes. The value should be an integer not less than 8 and not more than 32. When not specified, the default value is 8.",
"type": "integer",
"format": "int32",
"default": 8
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not right, this should be 8, whys the tag not worked 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no idea why .. the taga are correct

},
"controlPlaneHardwareSpeed": {
"description": "HardwareSpeed allows user to change the etcd tuning profile which configures the latency parameters for heartbeat interval and leader election timeouts allowing the cluster to tolerate longer round-trip-times between etcd members. Valid values are \"\", \"Standard\" and \"Slower\".\n\t\"\" means no opinion and the platform is left to choose a reasonable default\n\twhich is subject to change without notice.\n\nPossible enum values:\n - `\"Slower\"` provides more tolerance for slower hardware and/or higher latency networks. Sets (values subject to change): ETCD_HEARTBEAT_INTERVAL: 5x Standard ETCD_LEADER_ELECTION_TIMEOUT: 2.5x Standard\n - `\"Standard\"` provides the normal tolerances for hardware speed and latency. Currently sets (values subject to change at any time): ETCD_HEARTBEAT_INTERVAL: 100ms ETCD_LEADER_ELECTION_TIMEOUT: 1000ms",
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "Etcd"
crdName: etcds.operator.openshift.io
featureGate: -EtcdBackendQuota
tests:
onCreate:
- name: Should be able to create a minimal Etcd
Expand Down
149 changes: 149 additions & 0 deletions operator/v1/tests/etcds.operator.openshift.io/EtcdBackendQuota.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
apiVersion: apiextensions.k8s.io/v1 # Hack because controller-gen complains if we don't have this
name: "Etcd"
crdName: etcds.operator.openshift.io
featureGate: EtcdBackendQuota
tests:
onCreate:
- name: Should be able to create with 8 BackendQuotaGiB
initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib8
spec:
backendQuotaGiB: 8
expected: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: default
spec:
logLevel: Normal
operatorLogLevel: Normal
backendQuotaGiB: 8
- name: Should be able to create with 16 BackendQuotaGiB
initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib16
spec:
backendQuotaGiB: 16
expected: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib16
spec:
logLevel: Normal
operatorLogLevel: Normal
backendQuotaGiB: 16
- name: Should be able to create with 20 BackendQuotaGiB
initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib20
spec:
backendQuotaGiB: 20
expected: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib20
spec:
logLevel: Normal
operatorLogLevel: Normal
backendQuotaGiB: 20
- name: Should be able to create with 32 BackendQuotaGiB
initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib32
spec:
backendQuotaGiB: 32
expected: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib32
spec:
logLevel: Normal
operatorLogLevel: Normal
backendQuotaGiB: 32
- name: Should not be able to create with less than 8 BackendQuotaGiB
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoelSpeed this is to test the case of violating the minimum of 8

initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib6
spec:
backendQuotaGiB: 6
expectedError: "spec.backendQuotaGiB: Invalid value: 6: spec.backendQuotaGiB in body should be greater than or equal to 8"
- name: Should not be able to create with more than 32 BackendQuotaGiB
initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib40
spec:
backendQuotaGiB: 40
expectedError: "spec.backendQuotaGiB: Invalid value: 40: spec.backendQuotaGiB in body should be less than or equal to 32"
onUpdate:
- name: Should be able to create with default then upgrade to 16
initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: default
spec:
backendQuotaGiB: 8
updated: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib16
spec:
backendQuotaGiB: 16
expected: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib16
spec:
logLevel: Normal
operatorLogLevel: Normal
backendQuotaGiB: 16
- name: Should not be allowed to try to decrease BackendQuotaGiB
initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib16
spec:
backendQuotaGiB: 16
updated: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib8
spec:
backendQuotaGiB: 8
expectedError: etcd backendQuotaGiB may not be decreased
- name: Should not be allowed to upgrade to more than 32 BackendQuotaGiB
initial: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib16
spec:
backendQuotaGiB: 16
updated: |
apiVersion: operator.openshift.io/v1
kind: Etcd
metadata:
name: gib40
spec:
backendQuotaGiB: 40
expectedError: "spec.backendQuotaGiB: Invalid value: 40: spec.backendQuotaGiB in body should be less than or equal to 32"
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ tests:
logLevel: Normal
operatorLogLevel: Normal
controlPlaneHardwareSpeed: Standard
backendQuotaGiB: 8
- name: Should be able to create with Slower hardware speed
initial: |
apiVersion: operator.openshift.io/v1
Expand All @@ -30,6 +31,7 @@ tests:
logLevel: Normal
operatorLogLevel: Normal
controlPlaneHardwareSpeed: Slower
backendQuotaGiB: 8
onUpdate:
- name: Should be able to create with Standard, then set to Slower
initial: |
Expand All @@ -49,6 +51,7 @@ tests:
logLevel: Normal
operatorLogLevel: Normal
controlPlaneHardwareSpeed: Slower
backendQuotaGiB: 8
- name: Should not be allowed to try to set invalid hardware speed
initial: |
apiVersion: operator.openshift.io/v1
Expand Down
12 changes: 12 additions & 0 deletions operator/v1/types_etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ type EtcdSpec struct {
// +openshift:enable:FeatureGate=HardwareSpeed
// +optional
HardwareSpeed ControlPlaneHardwareSpeed `json:"controlPlaneHardwareSpeed"`

// backendQuotaGiB sets the etcd backend storage size limit in gibibytes.
// The value should be an integer not less than 8 and not more than 32.
// When not specified, the default value is 8.
// +kubebuilder:default:=8
// +kubebuilder:validation:Minimum=8
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoelSpeed adding minimum and removing default is the only way the integration does not fail

// +kubebuilder:validation:Maximum=32
Comment on lines +51 to +52
Copy link
Contributor

Choose a reason for hiding this comment

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

To have a default, you need omitempty and two tags

// +kubebuilder:default:=8
// +default:=8

With omtiempty, I expect:

  • Writes without the field should succeed
  • Reads will then return the value with the default (which passes validation)
  • User writes should be acceptable provided they are within bounds
  • Any existing tests that exist with an expected value, will need to be updated to include the new default value where this feature gate is present (eg CustomNoUpgrade tests)

I would hope to see tests for creating both with and without the value initially, and tests for adding the value and trying to increase and decrease the value with the appropriate pass and failure

Copy link
Contributor

Choose a reason for hiding this comment

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

Why did the minimum disappear?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@JoelSpeed i used the default to replace Minimum

Copy link
Contributor Author

Choose a reason for hiding this comment

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

as we discussed in the call, i used default back && omitempty

no need to minimum anymore, or ?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I think you need a minimum still, otherwise I could create the object with a lower value

// +kubebuilder:validation:XValidation:rule="self>=oldSelf",message="etcd backendQuotaGiB may not be decreased"
// +openshift:enable:FeatureGate=EtcdBackendQuota
// +default=8
// +optional
BackendQuotaGiB int32 `json:"backendQuotaGiB,omitempty"`
}

type EtcdStatus struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ spec:
type: object
spec:
properties:
backendQuotaGiB:
default: 8
description: backendQuotaGiB sets the etcd backend storage size limit
in gibibytes. The value should be an integer not less than 8 and
not more than 32. When not specified, the default value is 8.
format: int32
maximum: 32
minimum: 8
type: integer
x-kubernetes-validations:
- message: etcd backendQuotaGiB may not be decreased
rule: self>=oldSelf
controlPlaneHardwareSpeed:
description: HardwareSpeed allows user to change the etcd tuning profile
which configures the latency parameters for heartbeat interval and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ spec:
type: object
spec:
properties:
backendQuotaGiB:
default: 8
description: backendQuotaGiB sets the etcd backend storage size limit
in gibibytes. The value should be an integer not less than 8 and
not more than 32. When not specified, the default value is 8.
format: int32
maximum: 32
minimum: 8
type: integer
x-kubernetes-validations:
- message: etcd backendQuotaGiB may not be decreased
rule: self>=oldSelf
controlPlaneHardwareSpeed:
description: HardwareSpeed allows user to change the etcd tuning profile
which configures the latency parameters for heartbeat interval and
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ spec:
type: object
spec:
properties:
backendQuotaGiB:
default: 8
description: backendQuotaGiB sets the etcd backend storage size limit
in gibibytes. The value should be an integer not less than 8 and
not more than 32. When not specified, the default value is 8.
format: int32
maximum: 32
minimum: 8
type: integer
x-kubernetes-validations:
- message: etcd backendQuotaGiB may not be decreased
rule: self>=oldSelf
controlPlaneHardwareSpeed:
description: HardwareSpeed allows user to change the etcd tuning profile
which configures the latency parameters for heartbeat interval and
Expand Down
1 change: 1 addition & 0 deletions operator/v1/zz_generated.featuregated-crd-manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ etcds.operator.openshift.io:
Capability: ""
Category: coreoperators
FeatureGates:
- EtcdBackendQuota
Elbehery marked this conversation as resolved.
Show resolved Hide resolved
- HardwareSpeed
FilenameOperatorName: etcd
FilenameOperatorOrdering: "01"
Expand Down
Loading