Skip to content

Commit 8a6ce81

Browse files
authored
[Backport release-1.6] feat(etcd-operator): bump to v0.5.5 and vendor EtcdDefragPolicy CRDs (#4151)
# Description Backport of #3968 to `release-1.6`.
2 parents c86d366 + cf9c77d commit 8a6ce81

9 files changed

Lines changed: 625 additions & 15 deletions

File tree

‎packages/system/etcd-operator-crds/Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ export NAMESPACE=cozy-etcd-operator
44
include ../../../hack/package.mk
55

66
# Pinned ref of github.com/cozystack/etcd-operator to vendor CRDs from.
7-
ETCD_OPERATOR_REF ?= v0.5.4
7+
ETCD_OPERATOR_REF ?= v0.5.5
88

99
# controller-gen writes the CRDs to charts/etcd-operator/crd-bases/ upstream (there
1010
# is no config/crd kustomization). Vendor each verbatim and stamp
1111
# helm.sh/resource-policy: keep so a chart uninstall never garbage-collects the
1212
# CRDs and, with them, every EtcdCluster/EtcdMember/EtcdSnapshot in the cluster.
13-
CRDS = etcdclusters etcdmembers etcdsnapshots
13+
CRDS = etcdclusters etcddefragpolicies etcddefrags etcdmembers etcdsnapshots
1414
update:
1515
rm -rf templates
1616
mkdir templates

‎packages/system/etcd-operator-crds/templates/etcddefragpolicies.yaml‎

Lines changed: 318 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.18.0
7+
helm.sh/resource-policy: keep
8+
name: etcddefrags.etcd-operator.cozystack.io
9+
spec:
10+
group: etcd-operator.cozystack.io
11+
names:
12+
kind: EtcdDefrag
13+
listKind: EtcdDefragList
14+
plural: etcddefrags
15+
singular: etcddefrag
16+
scope: Namespaced
17+
versions:
18+
- additionalPrinterColumns:
19+
- jsonPath: .spec.clusterRef.name
20+
name: Cluster
21+
type: string
22+
- jsonPath: .status.phase
23+
name: Phase
24+
type: string
25+
- jsonPath: .status.defragmented
26+
name: Defragmented
27+
type: integer
28+
- jsonPath: .metadata.creationTimestamp
29+
name: Age
30+
type: date
31+
name: v1alpha2
32+
schema:
33+
openAPIV3Schema:
34+
description: |-
35+
EtcdDefrag is the Schema for the etcddefrags API. It requests a one-shot,
36+
run-to-completion defragmentation of an EtcdCluster's members. Like
37+
EtcdSnapshot it is a record: the operator drives it through status.phase and
38+
it never re-runs.
39+
properties:
40+
apiVersion:
41+
description: |-
42+
APIVersion defines the versioned schema of this representation of an object.
43+
Servers should convert recognized schemas to the latest internal value, and
44+
may reject unrecognized values.
45+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
46+
type: string
47+
kind:
48+
description: |-
49+
Kind is a string value representing the REST resource this object represents.
50+
Servers may infer this from the endpoint the client submits requests to.
51+
Cannot be updated.
52+
In CamelCase.
53+
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
54+
type: string
55+
metadata:
56+
type: object
57+
spec:
58+
description: |-
59+
EtcdDefragSpec is the desired state of an EtcdDefrag: a one-shot request to
60+
defragment an EtcdCluster's members.
61+
properties:
62+
clusterRef:
63+
description: ClusterRef names the EtcdCluster (same namespace) to
64+
defragment.
65+
properties:
66+
name:
67+
default: ""
68+
description: |-
69+
Name of the referent.
70+
This field is effectively required, but due to backwards compatibility is
71+
allowed to be empty. Instances of this type with an empty value here are
72+
almost certainly wrong.
73+
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
74+
type: string
75+
type: object
76+
x-kubernetes-map-type: atomic
77+
rule:
78+
description: |-
79+
Rule decides which members this run touches. Absent is equivalent to an
80+
empty rule: the default gate (freeSpaceAbove 200Mi). To defragment every
81+
member unconditionally, set rule.all: true.
82+
properties:
83+
all:
84+
description: |-
85+
All defragments every member unconditionally, regardless of size — the
86+
explicit "do it now". Mutually exclusive with the threshold fields below.
87+
type: boolean
88+
freeSpaceAbove:
89+
anyOf:
90+
- type: integer
91+
- type: string
92+
description: |-
93+
FreeSpaceAbove defragments a member whose reclaimable space
94+
(DbSize-DbSizeInUse) exceeds this. The primary, always-applied gate.
95+
Absent means the built-in default (200Mi).
96+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
97+
x-kubernetes-int-or-string: true
98+
minReclaim:
99+
anyOf:
100+
- type: integer
101+
- type: string
102+
description: |-
103+
MinReclaim floors the quota arm: even under quota pressure, skip a member
104+
that would reclaim less than this. Only meaningful with QuotaUsageAbove,
105+
and must not exceed FreeSpaceAbove. Absent means the built-in default
106+
(32Mi).
107+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
108+
x-kubernetes-int-or-string: true
109+
quotaUsageAbove:
110+
description: |-
111+
QuotaUsageAbove: when DbSize exceeds this fraction of the backend quota
112+
(approaching NOSPACE), lower the reclaimable floor to MinReclaim so small
113+
wins are taken under pressure. A member is never defragmented when its
114+
reclaimable space is below MinReclaim. Integer percent 1..99 with a "%"
115+
suffix, e.g. "80%"; 100% is rejected because a backend never exceeds its
116+
quota (etcd raises NOSPACE first), so the arm could never fire.
117+
pattern: ^[1-9][0-9]?%$
118+
type: string
119+
type: object
120+
x-kubernetes-validations:
121+
- message: rule.all cannot be combined with freeSpaceAbove/quotaUsageAbove/minReclaim
122+
rule: '!(has(self.all) && self.all) || (!has(self.freeSpaceAbove)
123+
&& !has(self.quotaUsageAbove) && !has(self.minReclaim))'
124+
- message: freeSpaceAbove must be greater than 0
125+
rule: '!has(self.freeSpaceAbove) || quantity(string(self.freeSpaceAbove)).isGreaterThan(quantity(''0''))'
126+
- message: minReclaim must be greater than 0
127+
rule: '!has(self.minReclaim) || quantity(string(self.minReclaim)).isGreaterThan(quantity(''0''))'
128+
- message: minReclaim is only meaningful with quotaUsageAbove
129+
rule: '!has(self.minReclaim) || has(self.quotaUsageAbove)'
130+
- message: minReclaim must not exceed freeSpaceAbove
131+
rule: '!(has(self.minReclaim) && has(self.freeSpaceAbove)) || quantity(string(self.minReclaim)).compareTo(quantity(string(self.freeSpaceAbove)))
132+
<= 0'
133+
ttlSecondsAfterFinished:
134+
description: |-
135+
TTLSecondsAfterFinished records how long after a terminal phase this
136+
object should be garbage-collected — meaningful for objects a scheduler
137+
stamps out. Acted on by the reconciling controller; the API server does not
138+
garbage-collect custom resources on its own. Absent means the record is kept.
139+
format: int32
140+
minimum: 0
141+
type: integer
142+
required:
143+
- clusterRef
144+
type: object
145+
x-kubernetes-validations:
146+
- message: spec.clusterRef.name is required
147+
rule: size(self.clusterRef.name) != 0
148+
status:
149+
description: EtcdDefragStatus is the observed state of an EtcdDefrag.
150+
properties:
151+
completedAt:
152+
description: CompletedAt is when the sweep reached a terminal phase.
153+
format: date-time
154+
type: string
155+
conditions:
156+
description: |-
157+
Conditions represent the latest available observations — including why a
158+
Pending run is being deferred (e.g. the cluster is not fully healthy).
159+
items:
160+
description: Condition contains details for one aspect of the current
161+
state of this API Resource.
162+
properties:
163+
lastTransitionTime:
164+
description: |-
165+
lastTransitionTime is the last time the condition transitioned from one status to another.
166+
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
167+
format: date-time
168+
type: string
169+
message:
170+
description: |-
171+
message is a human readable message indicating details about the transition.
172+
This may be an empty string.
173+
maxLength: 32768
174+
type: string
175+
observedGeneration:
176+
description: |-
177+
observedGeneration represents the .metadata.generation that the condition was set based upon.
178+
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
179+
with respect to the current state of the instance.
180+
format: int64
181+
minimum: 0
182+
type: integer
183+
reason:
184+
description: |-
185+
reason contains a programmatic identifier indicating the reason for the condition's last transition.
186+
Producers of specific condition types may define expected values and meanings for this field,
187+
and whether the values are considered a guaranteed API.
188+
The value should be a CamelCase string.
189+
This field may not be empty.
190+
maxLength: 1024
191+
minLength: 1
192+
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
193+
type: string
194+
status:
195+
description: status of the condition, one of True, False, Unknown.
196+
enum:
197+
- "True"
198+
- "False"
199+
- Unknown
200+
type: string
201+
type:
202+
description: type of condition in CamelCase or in foo.example.com/CamelCase.
203+
maxLength: 316
204+
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])$
205+
type: string
206+
required:
207+
- lastTransitionTime
208+
- message
209+
- reason
210+
- status
211+
- type
212+
type: object
213+
type: array
214+
defragmented:
215+
description: Defragmented counts members actually defragmented this
216+
run.
217+
format: int32
218+
type: integer
219+
members:
220+
description: Members holds the per-member outcome of the sweep, keyed
221+
by member name.
222+
items:
223+
description: MemberDefragStatus is the outcome of defragmenting
224+
a single member.
225+
properties:
226+
dbSizeAfter:
227+
description: DBSizeAfter is the physical backend size after
228+
defragmenting.
229+
format: int64
230+
type: integer
231+
dbSizeBefore:
232+
description: DBSizeBefore is the member's physical backend size
233+
before defragmenting.
234+
format: int64
235+
type: integer
236+
finishedAt:
237+
description: FinishedAt is when this member was processed.
238+
format: date-time
239+
type: string
240+
name:
241+
description: Name is the EtcdMember this row describes.
242+
type: string
243+
outcome:
244+
description: Outcome is the result of processing this member.
245+
type: string
246+
reason:
247+
description: |-
248+
Reason qualifies the outcome (e.g. BelowThreshold, ClusterNotHealthy,
249+
RPCError), in condition-reason style.
250+
type: string
251+
reclaimedBytes:
252+
description: ReclaimedBytes is DBSizeBefore-DBSizeAfter for
253+
a completed defrag.
254+
format: int64
255+
type: integer
256+
role:
257+
description: Role is the member's raft role at the time it was
258+
processed.
259+
type: string
260+
required:
261+
- name
262+
type: object
263+
type: array
264+
x-kubernetes-list-map-keys:
265+
- name
266+
x-kubernetes-list-type: map
267+
phase:
268+
description: Phase is the high-level lifecycle phase.
269+
type: string
270+
startedAt:
271+
description: StartedAt is when the sweep began.
272+
format: date-time
273+
type: string
274+
type: object
275+
type: object
276+
served: true
277+
storage: true
278+
subresources:
279+
status: {}

‎packages/system/etcd-operator-crds/templates/etcdmembers.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,7 @@ spec:
11781178
description: |-
11791179
Restore is set only on the bootstrap seed when the parent cluster's
11801180
spec.bootstrap.restore is configured. It causes the member controller
1181-
to run a restore initContainer that populates the data dir from the
1181+
to run restore initContainers that populate the data dir from the
11821182
snapshot before etcd starts. Inert once the data dir is initialized.
11831183
properties:
11841184
source:

‎packages/system/etcd-operator/Chart.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ name: cozy-etcd-operator
33
description: Cozystack etcd-operator (etcd-operator.cozystack.io/v1alpha2) controller-manager
44
type: application
55
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process
6-
appVersion: v0.5.4
6+
appVersion: v0.5.5

‎packages/system/etcd-operator/Makefile‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ include ../../../hack/package.mk
66
# Pinned ref of github.com/cozystack/etcd-operator to vendor the manager
77
# ClusterRole from. The Deployment is cozystack-authored (image, cluster
88
# domain, VPA), so only the RBAC role is re-vendored; refresh templates/rbac.yaml
9-
# by hand from config/rbac/role.yaml at this ref. CRDs live in the sibling
10-
# etcd-operator-crds package.
11-
ETCD_OPERATOR_REF ?= v0.5.4
9+
# by hand from charts/etcd-operator/files/manager-role-rules.yaml at this ref.
10+
# CRDs live in the sibling etcd-operator-crds package.
11+
ETCD_OPERATOR_REF ?= v0.5.5
1212

1313
update:
1414
@echo "etcd-operator is a cozystack-authored chart; refresh templates/rbac.yaml"
15-
@echo "from github.com/cozystack/etcd-operator config/rbac/role.yaml @ $(ETCD_OPERATOR_REF)"
15+
@echo "from github.com/cozystack/etcd-operator charts/etcd-operator/files/manager-role-rules.yaml @ $(ETCD_OPERATOR_REF)"
1616
@echo "and re-vendor CRDs via 'make -C ../etcd-operator-crds update'."
1717

1818
test:

‎packages/system/etcd-operator/templates/rbac.yaml‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ kind: ClusterRole
1212
metadata:
1313
name: etcd-operator-manager-role
1414
rules:
15+
- apiGroups: [""]
16+
resources: [events]
17+
verbs: [create, patch]
1518
- apiGroups: [""]
1619
resources: [persistentvolumeclaims]
1720
verbs: [create, delete, get, list, patch, update, watch]
@@ -40,10 +43,13 @@ rules:
4043
resources: [etcdclusters/finalizers, etcdmembers/finalizers, etcdsnapshots/finalizers]
4144
verbs: [update]
4245
- apiGroups: [etcd-operator.cozystack.io]
43-
resources: [etcdclusters/status, etcdmembers/status, etcdsnapshots/status]
46+
resources: [etcdclusters/status, etcddefragpolicies/status, etcddefrags/status, etcdmembers/status, etcdsnapshots/status]
4447
verbs: [get, patch, update]
4548
- apiGroups: [etcd-operator.cozystack.io]
46-
resources: [etcdmembers, etcdsnapshots]
49+
resources: [etcddefragpolicies]
50+
verbs: [get, list, patch, update, watch]
51+
- apiGroups: [etcd-operator.cozystack.io]
52+
resources: [etcddefrags, etcdmembers, etcdsnapshots]
4753
verbs: [create, delete, get, list, patch, update, watch]
4854
- apiGroups: [policy]
4955
resources: [poddisruptionbudgets]

‎packages/system/etcd-operator/tests/deployment_test.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ tests:
2020
asserts:
2121
- equal:
2222
path: spec.template.spec.containers[0].image
23-
value: ghcr.io/cozystack/etcd-operator:v0.5.4
23+
value: ghcr.io/cozystack/etcd-operator:v0.5.5
2424
- contains:
2525
path: spec.template.spec.containers[0].env
2626
content:
2727
name: OPERATOR_IMAGE
28-
value: ghcr.io/cozystack/etcd-operator:v0.5.4
28+
value: ghcr.io/cozystack/etcd-operator:v0.5.5
2929
any: true
3030

3131
- it: "image.tag overrides the appVersion default for both the container and the agent env"

‎packages/system/etcd-operator/tests/rbac_test.yaml‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
suite: controller-manager RBAC — ServiceAccount, manager ClusterRole, and bindings
22

33
# The manager ClusterRole is vendored by hand from the operator's
4-
# config/rbac/role.yaml (see Makefile `update`), so a stale re-vendor could drop
5-
# a rule the operator needs and only surface as a runtime RBAC-forbidden error.
4+
# charts/etcd-operator/files/manager-role-rules.yaml (see Makefile `update`), so
5+
# a stale re-vendor could drop a rule the operator needs and only surface as a
6+
# runtime RBAC-forbidden error.
67
# Pin the ServiceAccount, a couple of load-bearing ClusterRole rules, and that
78
# the binding actually wires the role to the controller ServiceAccount.
89

@@ -38,8 +39,14 @@ tests:
3839
path: rules
3940
content:
4041
apiGroups: [etcd-operator.cozystack.io]
41-
resources: [etcdmembers, etcdsnapshots]
42+
resources: [etcddefrags, etcdmembers, etcdsnapshots]
4243
verbs: [create, delete, get, list, patch, update, watch]
44+
- contains:
45+
path: rules
46+
content:
47+
apiGroups: [etcd-operator.cozystack.io]
48+
resources: [etcddefragpolicies]
49+
verbs: [get, list, patch, update, watch]
4350
- contains:
4451
path: rules
4552
content:

0 commit comments

Comments
 (0)