Skip to content

Commit

Permalink
Remove deprecated API fields, CLI flag and annotation (gardener#990)
Browse files Browse the repository at this point in the history
* Remove deprecated Etcd status fields

* Remove deprecated CLI flag `IgnoreOperationAnnotation` and annotation `IgnoreReconciliationAnnotation`
  • Loading branch information
shreyas-s-rao authored Feb 3, 2025
1 parent dd09e93 commit 52e514f
Show file tree
Hide file tree
Showing 15 changed files with 4 additions and 117 deletions.
3 changes: 0 additions & 3 deletions api/v1alpha1/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ const (

// Annotation keys that can be placed on an Etcd custom resource.
const (
// IgnoreReconciliationAnnotation is an annotation set by an operator in order to stop reconciliation.
// Deprecated: Please use SuspendEtcdSpecReconcileAnnotation instead
IgnoreReconciliationAnnotation = "druid.gardener.cloud/ignore-reconciliation"
// SuspendEtcdSpecReconcileAnnotation is an annotation set by an operator to temporarily suspend any etcd spec reconciliation.
SuspendEtcdSpecReconcileAnnotation = "druid.gardener.cloud/suspend-etcd-spec-reconcile"
// DisableEtcdComponentProtectionAnnotation is an annotation set by an operator to disable protection of components created for
Expand Down
16 changes: 0 additions & 16 deletions api/v1alpha1/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,24 +386,12 @@ type EtcdStatus struct {
// Conditions represents the latest available observations of an etcd's current state.
// +optional
Conditions []Condition `json:"conditions,omitempty"`
// ServiceName is the name of the etcd service.
// Deprecated: this field will be removed in the future.
// +optional
ServiceName *string `json:"serviceName,omitempty"`
// LastError represents the last occurred error.
// Deprecated: Use LastErrors instead.
// +optional
LastError *string `json:"lastError,omitempty"`
// LastErrors captures errors that occurred during the last operation.
// +optional
LastErrors []LastError `json:"lastErrors,omitempty"`
// LastOperation indicates the last operation performed on this resource.
// +optional
LastOperation *LastOperation `json:"lastOperation,omitempty"`
// Cluster size is the current size of the etcd cluster.
// Deprecated: this field will not be populated with any value and will be removed in the future.
// +optional
ClusterSize *int32 `json:"clusterSize,omitempty"`
// CurrentReplicas is the current replica count for the etcd cluster.
// +optional
CurrentReplicas int32 `json:"currentReplicas,omitempty"`
Expand All @@ -416,10 +404,6 @@ type EtcdStatus struct {
// Ready is `true` if all etcd replicas are ready.
// +optional
Ready *bool `json:"ready,omitempty"`
// UpdatedReplicas is the count of updated replicas in the etcd cluster.
// Deprecated: this field will be removed in the future.
// +optional
UpdatedReplicas int32 `json:"updatedReplicas,omitempty"`
// LabelSelector is a label query over pods that should match the replica count.
// It must match the pod template's labels.
// Deprecated: this field will be removed in the future.
Expand Down
3 changes: 0 additions & 3 deletions api/v1alpha1/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,6 @@ func GetSuspendEtcdSpecReconcileAnnotationKey(etcdObjMeta metav1.ObjectMeta) *st
if metav1.HasAnnotation(etcdObjMeta, SuspendEtcdSpecReconcileAnnotation) {
return ptr.To(SuspendEtcdSpecReconcileAnnotation)
}
if metav1.HasAnnotation(etcdObjMeta, IgnoreReconciliationAnnotation) {
return ptr.To(IgnoreReconciliationAnnotation)
}
return nil
}

Expand Down
10 changes: 0 additions & 10 deletions api/v1alpha1/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,6 @@ func TestGetSuspendEtcdSpecReconcileAnnotationKey(t *testing.T) {
annotations: map[string]string{SuspendEtcdSpecReconcileAnnotation: ""},
expectedAnnotationKey: ptr.To(SuspendEtcdSpecReconcileAnnotation),
},
{
name: "IgnoreReconciliationAnnotation is set",
annotations: map[string]string{IgnoreReconciliationAnnotation: ""},
expectedAnnotationKey: ptr.To(IgnoreReconciliationAnnotation),
},
{
name: "Both annotations (SuspendEtcdSpecReconcileAnnotation and IgnoreReconciliationAnnotation) are set",
annotations: map[string]string{SuspendEtcdSpecReconcileAnnotation: "", IgnoreReconciliationAnnotation: ""},
expectedAnnotationKey: ptr.To(SuspendEtcdSpecReconcileAnnotation),
},
}
g := NewWithT(t)
t.Parallel()
Expand Down
15 changes: 0 additions & 15 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -1841,12 +1841,6 @@ spec:
status:
description: EtcdStatus defines the observed state of Etcd.
properties:
clusterSize:
description: |-
Cluster size is the current size of the etcd cluster.
Deprecated: this field will not be populated with any value and will be removed in the future.
format: int32
type: integer
conditions:
description: Conditions represents the latest available observations
of an etcd's current state.
Expand Down Expand Up @@ -1956,11 +1950,6 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
lastError:
description: |-
LastError represents the last occurred error.
Deprecated: Use LastErrors instead.
type: string
lastErrors:
description: LastErrors captures errors that occurred during the last
operation.
Expand Down Expand Up @@ -2075,17 +2064,6 @@ spec:
description: Replicas is the replica count of the etcd cluster.
format: int32
type: integer
serviceName:
description: |-
ServiceName is the name of the etcd service.
Deprecated: this field will be removed in the future.
type: string
updatedReplicas:
description: |-
UpdatedReplicas is the count of updated replicas in the etcd cluster.
Deprecated: this field will be removed in the future.
format: int32
type: integer
type: object
type: object
served: true
Expand Down
22 changes: 0 additions & 22 deletions config/crd/bases/crd-druid.gardener.cloud_etcds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1841,12 +1841,6 @@ spec:
status:
description: EtcdStatus defines the observed state of Etcd.
properties:
clusterSize:
description: |-
Cluster size is the current size of the etcd cluster.
Deprecated: this field will not be populated with any value and will be removed in the future.
format: int32
type: integer
conditions:
description: Conditions represents the latest available observations
of an etcd's current state.
Expand Down Expand Up @@ -1956,11 +1950,6 @@ spec:
type: object
type: object
x-kubernetes-map-type: atomic
lastError:
description: |-
LastError represents the last occurred error.
Deprecated: Use LastErrors instead.
type: string
lastErrors:
description: LastErrors captures errors that occurred during the last
operation.
Expand Down Expand Up @@ -2075,17 +2064,6 @@ spec:
description: Replicas is the replica count of the etcd cluster.
format: int32
type: integer
serviceName:
description: |-
ServiceName is the name of the etcd service.
Deprecated: this field will be removed in the future.
type: string
updatedReplicas:
description: |-
UpdatedReplicas is the count of updated replicas in the etcd cluster.
Deprecated: this field will be removed in the future.
format: int32
type: integer
type: object
type: object
served: true
Expand Down
4 changes: 0 additions & 4 deletions docs/api-reference/etcd-druid-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -418,16 +418,12 @@ _Appears in:_
| `observedGeneration` _integer_ | ObservedGeneration is the most recent generation observed for this resource. | | |
| `etcd` _[CrossVersionObjectReference](#crossversionobjectreference)_ | | | |
| `conditions` _[Condition](#condition) array_ | Conditions represents the latest available observations of an etcd's current state. | | |
| `serviceName` _string_ | ServiceName is the name of the etcd service.<br />Deprecated: this field will be removed in the future. | | |
| `lastError` _string_ | LastError represents the last occurred error.<br />Deprecated: Use LastErrors instead. | | |
| `lastErrors` _[LastError](#lasterror) array_ | LastErrors captures errors that occurred during the last operation. | | |
| `lastOperation` _[LastOperation](#lastoperation)_ | LastOperation indicates the last operation performed on this resource. | | |
| `clusterSize` _integer_ | Cluster size is the current size of the etcd cluster.<br />Deprecated: this field will not be populated with any value and will be removed in the future. | | |
| `currentReplicas` _integer_ | CurrentReplicas is the current replica count for the etcd cluster. | | |
| `replicas` _integer_ | Replicas is the replica count of the etcd cluster. | | |
| `readyReplicas` _integer_ | ReadyReplicas is the count of replicas being ready in the etcd cluster. | | |
| `ready` _boolean_ | Ready is `true` if all etcd replicas are ready. | | |
| `updatedReplicas` _integer_ | UpdatedReplicas is the count of updated replicas in the etcd cluster.<br />Deprecated: this field will be removed in the future. | | |
| `labelSelector` _[LabelSelector](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.29/#labelselector-v1-meta)_ | LabelSelector is a label query over pods that should match the replica count.<br />It must match the pod template's labels.<br />Deprecated: this field will be removed in the future. | | |
| `members` _[EtcdMemberStatus](#etcdmemberstatus) array_ | Members represents the members of the etcd cluster | | |
| `peerUrlTLSEnabled` _boolean_ | PeerUrlTLSEnabled captures the state of peer url TLS being enabled for the etcd member(s) | | |
Expand Down
1 change: 0 additions & 1 deletion docs/deployment/configure-etcd-druid.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ Following set of flags configures the reconcilers running within etcd-druid. To
| etcd-status-sync-period | `Etcd.Status` is periodically updated. This interval defines the status sync frequency. | 15s |
| etcd-member-notready-threshold | Threshold after which an etcd member is considered not ready if the status was unknown before. This is currently used to update [EtcdMemberConditionStatus](https://github.com/gardener/etcd-druid/blob/55efca1c8f6c852b0a4e97f08488ffec2eed0e68/api/v1alpha1/etcd.go#L360). | 5m |
| etcd-member-unknown-threshold | Threshold after which an etcd member is considered unknown. This is currently used to update [EtcdMemberConditionStatus](https://github.com/gardener/etcd-druid/blob/55efca1c8f6c852b0a4e97f08488ffec2eed0e68/api/v1alpha1/etcd.go#L360). | 1m |
| ignore-operation-annotation | Specifies whether to ignore or honour the annotation `gardener.cloud/operation: reconcile` on resources to be reconciled.<br />**Deprecated:** please use `--enable-etcd-spec-auto-reconcile` instead. | false |

#### Compaction Reconciler

Expand Down
5 changes: 2 additions & 3 deletions docs/usage/managing-etcd-clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,12 @@ There are two ways to control reconciliation of any changes done to `Etcd` custo

#### Auto reconciliation

If `etcd-druid` has been deployed with auto-reconciliation then any change done to an `Etcd` resource will be automatically reconciled.
Prior to v0.23.0 you can do this by using `--ignore-operation-annotation` CLI flag. This flag has been marked as deprecated and will be removed in later versions of `etcd-druid`. With etcd-druid version v0.23.x it is recommended that you use `--enable-etcd-spec-auto-reconcile` CLI flag to enable auto-reconcile.
If `etcd-druid` has been deployed with auto-reconciliation then any change done to an `Etcd` resource will be automatically reconciled. You use `--enable-etcd-spec-auto-reconcile` CLI flag to enable auto-reconciliation of the etcd spec.

> For a complete list of CLI args you can see [this](../deployment/configure-etcd-druid.md) document.
#### Explicit reconciliation
If `--enable-etcd-spec-auto-reconcile` or `--ignore-operation-annotation` is set to false or not set at all, then any change to an `Etcd` resource will not be automatically reconciled. To trigger a reconcile you must set the following annotation on the `Etcd` resource:
If `--enable-etcd-spec-auto-reconcile` is set to false or not set at all, then any change to an `Etcd` resource will not be automatically reconciled. To trigger a reconcile you must set the following annotation on the `Etcd` resource:

```bash
kubectl annotate etcd <etcd-name> gardener.cloud/operation=reconcile -n <namespace>
Expand Down
7 changes: 0 additions & 7 deletions internal/controller/etcd/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
// Flag names
const (
workersFlagName = "etcd-workers"
ignoreOperationAnnotationFlagName = "ignore-operation-annotation"
enableEtcdSpecAutoReconcileFlagName = "enable-etcd-spec-auto-reconcile"
disableEtcdServiceAccountAutomountFlagName = "disable-etcd-serviceaccount-automount"
etcdStatusSyncPeriodFlagName = "etcd-status-sync-period"
Expand All @@ -29,7 +28,6 @@ const (

const (
defaultWorkers = 3
defaultIgnoreOperationAnnotation = false
defaultDisableEtcdServiceAccountAutomount = false
defaultEnableEtcdSpecAutoReconcile = false
defaultEtcdStatusSyncPeriod = 15 * time.Second
Expand All @@ -44,9 +42,6 @@ var featureList []featuregate.Feature
type Config struct {
// Workers is the number of workers concurrently processing reconciliation requests.
Workers int
// IgnoreOperationAnnotation specifies whether to ignore or honour the operation annotation on resources to be reconciled.
// Deprecated: Use EnableEtcdSpecAutoReconcile instead.
IgnoreOperationAnnotation bool
// EnableEtcdSpecAutoReconcile controls how the Etcd Spec is reconciled. If set to true, then any change in Etcd spec
// will automatically trigger a reconciliation of the Etcd resource. If set to false, then an operator needs to
// explicitly set gardener.cloud/operation=reconcile annotation on the Etcd resource to trigger reconciliation
Expand Down Expand Up @@ -78,8 +73,6 @@ type MemberConfig struct {
func (cfg *Config) InitFromFlags(fs *flag.FlagSet) {
fs.IntVar(&cfg.Workers, workersFlagName, defaultWorkers,
"Number of workers spawned for concurrent reconciles of etcd spec and status changes. If not specified then default of 3 is assumed.")
flag.BoolVar(&cfg.IgnoreOperationAnnotation, ignoreOperationAnnotationFlagName, defaultIgnoreOperationAnnotation,
fmt.Sprintf("Specifies whether to ignore or honour the annotation `%s: %s` on resources to be reconciled. Deprecated: please use `--%s` instead.", gardenerconstants.GardenerOperation, gardenerconstants.GardenerOperationReconcile, enableEtcdSpecAutoReconcileFlagName))
flag.BoolVar(&cfg.EnableEtcdSpecAutoReconcile, enableEtcdSpecAutoReconcileFlagName, defaultEnableEtcdSpecAutoReconcile,
fmt.Sprintf("If true then automatically reconciles Etcd Spec. If false, waits for explicit annotation `%s: %s` to be placed on the Etcd resource to trigger reconcile.", gardenerconstants.GardenerOperation, gardenerconstants.GardenerOperationReconcile))
fs.BoolVar(&cfg.DisableEtcdServiceAccountAutomount, disableEtcdServiceAccountAutomountFlagName, defaultDisableEtcdServiceAccountAutomount,
Expand Down
8 changes: 1 addition & 7 deletions internal/controller/etcd/reconcile_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,8 @@ func (r *Reconciler) recordIncompleteReconcileOperation(ctx component.OperatorCo
//
// Reconciliation decision follows these rules:
// - Skipped if 'druid.gardener.cloud/suspend-etcd-spec-reconcile' annotation is present, signaling a pause in reconciliation.
// - Also skipped if the deprecated 'druid.gardener.cloud/ignore-reconciliation' annotation is set.
// - Automatic reconciliation occurs if EnableEtcdSpecAutoReconcile is true.
// - If 'gardener.cloud/operation: reconcile' annotation exists and neither 'druid.gardener.cloud/suspend-etcd-spec-reconcile' nor the deprecated 'druid.gardener.cloud/ignore-reconciliation' is set to true, reconciliation proceeds upon Etcd spec changes.
// - If 'gardener.cloud/operation: reconcile' annotation exists and 'druid.gardener.cloud/suspend-etcd-spec-reconcile' annotation is not set, reconciliation proceeds upon Etcd spec changes.
// - Reconciliation is not initiated if EnableEtcdSpecAutoReconcile is false and none of the relevant annotations are present.
func (r *Reconciler) canReconcileSpec(etcd *druidv1alpha1.Etcd) bool {
// Check if spec reconciliation has been suspended, if yes, then record the event and return false.
Expand All @@ -182,11 +181,6 @@ func (r *Reconciler) canReconcileSpec(etcd *druidv1alpha1.Etcd) bool {
return true
}

// Fallback to deprecated IgnoreOperationAnnotation if EnableEtcdSpecAutoReconcile is false.
if r.config.IgnoreOperationAnnotation {
return true
}

// Reconcile if the 'reconcile-op' annotation is present.
if hasOperationAnnotationToReconcile(etcd) {
return true
Expand Down
2 changes: 0 additions & 2 deletions internal/controller/etcd/reconcile_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,11 @@ func (r *Reconciler) inspectStatefulSetAndMutateETCDStatus(ctx component.Operato
ready, _ := utils.IsStatefulSetReady(expectedReplicas, sts)
etcd.Status.CurrentReplicas = sts.Status.CurrentReplicas
etcd.Status.ReadyReplicas = sts.Status.ReadyReplicas
etcd.Status.UpdatedReplicas = sts.Status.UpdatedReplicas
etcd.Status.Replicas = sts.Status.CurrentReplicas
etcd.Status.Ready = &ready
} else {
etcd.Status.CurrentReplicas = 0
etcd.Status.ReadyReplicas = 0
etcd.Status.UpdatedReplicas = 0
etcd.Status.Ready = ptr.To(false)
}
return ctrlutils.ContinueReconcile()
Expand Down
2 changes: 1 addition & 1 deletion internal/controller/etcd/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func (r *Reconciler) hasReconcileAnnotation() predicate.Predicate {
func (r *Reconciler) autoReconcileEnabled() predicate.Predicate {
return predicate.Funcs{
UpdateFunc: func(_ event.UpdateEvent) bool {
return r.config.EnableEtcdSpecAutoReconcile || r.config.IgnoreOperationAnnotation
return r.config.EnableEtcdSpecAutoReconcile
},
CreateFunc: func(_ event.CreateEvent) bool {
return true
Expand Down
1 change: 0 additions & 1 deletion test/utils/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ func (eb *EtcdBuilder) WithReadyStatus() *EtcdBuilder {
ReadyReplicas: eb.etcd.Spec.Replicas,
Replicas: eb.etcd.Spec.Replicas,
CurrentReplicas: eb.etcd.Spec.Replicas,
UpdatedReplicas: eb.etcd.Spec.Replicas,
Ready: ptr.To(true),
Members: members,
Conditions: []druidv1alpha1.Condition{
Expand Down

0 comments on commit 52e514f

Please sign in to comment.