@@ -238,6 +238,67 @@ type IssuerReference struct {
238238 Kind string `json:"kind,omitempty"`
239239}
240240
241+ // AutoCompactionMode selects etcd's auto-compaction interpretation of
242+ // the retention value: "periodic" treats it as a time duration,
243+ // "revision" as a revision-count delta.
244+ //
245+ // +kubebuilder:validation:Enum=periodic;revision
246+ type AutoCompactionMode string
247+
248+ const (
249+ // AutoCompactionModePeriodic compacts by time window (--auto-compaction-mode=periodic).
250+ AutoCompactionModePeriodic AutoCompactionMode = "periodic"
251+ // AutoCompactionModeRevision compacts by revision delta (--auto-compaction-mode=revision).
252+ AutoCompactionModeRevision AutoCompactionMode = "revision"
253+ )
254+
255+ // EtcdOptions carries the etcd server tuning flags the operator passes to
256+ // each member's `etcd` command line. Deliberately a closed, typed set — the
257+ // legacy aenix operator exposed a free-form `spec.options` map[string]string,
258+ // which let users inject arbitrary (and operator-conflicting) flags; this
259+ // port types exactly the keys Cozystack's etcd package actually used. New
260+ // flags land here as new typed fields, not as an escape hatch.
261+ //
262+ // Like spec.resources, options are latched through status.observed and take
263+ // effect on newly-created members (scale-up, replacement) only; the operator
264+ // does not roll existing Pods to apply a tuning change in place. Delete one
265+ // Pod at a time to re-template members, or recreate the cluster.
266+ type EtcdOptions struct {
267+ // QuotaBackendBytes sets --quota-backend-bytes: the backend database
268+ // size limit in bytes before the member raises the cluster-wide
269+ // NOSPACE alarm. 0 or absent means etcd's built-in default (2GiB).
270+ // etcd's documented practical maximum is 8GiB.
271+ // +kubebuilder:validation:Minimum=0
272+ // +optional
273+ QuotaBackendBytes * int64 `json:"quotaBackendBytes,omitempty"`
274+
275+ // AutoCompactionMode sets --auto-compaction-mode: how
276+ // AutoCompactionRetention is interpreted, "periodic" (time-based)
277+ // or "revision" (revision-count-based). Absent means etcd's default
278+ // ("periodic" — though compaction only activates when a retention
279+ // is set).
280+ // +optional
281+ AutoCompactionMode AutoCompactionMode `json:"autoCompactionMode,omitempty"`
282+
283+ // AutoCompactionRetention sets --auto-compaction-retention. In
284+ // periodic mode a duration ("5m", "1h"; a bare integer means hours);
285+ // in revision mode a revision count. Absent or "0" disables
286+ // auto-compaction. The pattern admits what etcd itself parses: a
287+ // bare non-negative integer or a Go duration.
288+ // +kubebuilder:validation:Pattern=`^([0-9]+(\.[0-9]+)?(ms|s|m|h))+$|^[0-9]+$`
289+ // +optional
290+ AutoCompactionRetention string `json:"autoCompactionRetention,omitempty"`
291+
292+ // SnapshotCount sets --snapshot-count: the number of committed
293+ // raft entries to retain in memory before triggering an internal
294+ // raft snapshot (this is unrelated to EtcdSnapshot backups). Absent
295+ // means etcd's built-in default. Lower values trade replay speed on
296+ // restart for a smaller memory footprint.
297+ // +kubebuilder:validation:Minimum=1
298+ // +optional
299+ SnapshotCount * int64 `json:"snapshotCount,omitempty"`
300+ }
301+
241302// Condition types for EtcdCluster.
242303const (
243304 // ClusterAvailable indicates the cluster has a healthy quorum.
@@ -486,6 +547,17 @@ type EtcdClusterSpec struct {
486547 // the operator does not roll existing Pods to apply a change in place.
487548 // +optional
488549 TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints,omitempty"`
550+
551+ // Options carries etcd server tuning flags (backend quota,
552+ // auto-compaction, raft snapshot count) passed to each member's
553+ // command line. A closed typed set — see EtcdOptions for why there
554+ // is deliberately no free-form flag map.
555+ //
556+ // Updates take effect on newly-created members (scale-up,
557+ // replacement); the operator does not roll existing Pods to apply a
558+ // tuning change in place.
559+ // +optional
560+ Options * EtcdOptions `json:"options,omitempty"`
489561}
490562
491563// AdditionalMetadata is a set of labels and annotations the operator merges
@@ -545,6 +617,13 @@ type ObservedClusterSpec struct {
545617 // objects created once the current target is reached.
546618 // +optional
547619 AdditionalMetadata * AdditionalMetadata `json:"additionalMetadata,omitempty"`
620+
621+ // Options is the locked target etcd tuning flags for member Pods.
622+ // Latched with the rest of the target spec so a mid-flight tuning
623+ // edit only applies to members created once the current target is
624+ // reached.
625+ // +optional
626+ Options * EtcdOptions `json:"options,omitempty"`
548627}
549628
550629// EtcdClusterStatus defines the observed state of an etcd cluster.
0 commit comments