From 06b1a7d513c4121fc2d2af7e587c0dacc2f4cc7e Mon Sep 17 00:00:00 2001 From: Dan Mace Date: Wed, 15 Jul 2020 16:03:59 -0400 Subject: [PATCH] WIP: Introduce an etcd operator leader status field This patch explores adding an etcd operator status field which reports leader member information. Exposing this would allow, for example, smarter decision-making by the MCO regarding reboot ordering by providing a hint to help minimize disruption via excessive leader changes. --- operator/v1/0000_20_etcd-operator_01.crd.yaml | 11 +++++++++++ operator/v1/types_etcd.go | 12 ++++++++++++ operator/v1/zz_generated.deepcopy.go | 17 +++++++++++++++++ 3 files changed, 40 insertions(+) diff --git a/operator/v1/0000_20_etcd-operator_01.crd.yaml b/operator/v1/0000_20_etcd-operator_01.crd.yaml index ad1eadc5fd7..445f7e00229 100644 --- a/operator/v1/0000_20_etcd-operator_01.crd.yaml +++ b/operator/v1/0000_20_etcd-operator_01.crd.yaml @@ -149,6 +149,17 @@ spec: description: latestAvailableRevisionReason describe the detailed reason for the most recent deployment type: string + leader: + description: leader describes the etcd member which is currently the + leader. This field is a hint and shouldn't be considered authoritative. + type: object + properties: + name: + description: name is the etcd leader member name, if available. + type: string + node: + description: node is the etcd leader member node, if available. + type: string nodeStatuses: description: nodeStatuses track the deployment values and errors across individual nodes diff --git a/operator/v1/types_etcd.go b/operator/v1/types_etcd.go index 6a2fbdb9acf..6a9685445ac 100644 --- a/operator/v1/types_etcd.go +++ b/operator/v1/types_etcd.go @@ -26,6 +26,18 @@ type EtcdSpec struct { type EtcdStatus struct { StaticPodOperatorStatus `json:",inline"` + + // leader describes the etcd member which is currently the leader. This field + // is a hint and shouldn't be considered authoritative. + Leader LeaderStatus `json:"leader"` +} + +// leaderStatus describes the etcd leader member details. +type LeaderStatus struct { + // name is the etcd leader member name, if available. + Name string `json:"name,omitempty"` + // node is the etcd leader member node, if available. + Node string `json:"node,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/operator/v1/zz_generated.deepcopy.go b/operator/v1/zz_generated.deepcopy.go index 110dae102e7..b02344250c5 100644 --- a/operator/v1/zz_generated.deepcopy.go +++ b/operator/v1/zz_generated.deepcopy.go @@ -776,6 +776,7 @@ func (in *EtcdSpec) DeepCopy() *EtcdSpec { func (in *EtcdStatus) DeepCopyInto(out *EtcdStatus) { *out = *in in.StaticPodOperatorStatus.DeepCopyInto(&out.StaticPodOperatorStatus) + out.Leader = in.Leader return } @@ -1476,6 +1477,22 @@ func (in *KuryrConfig) DeepCopy() *KuryrConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *LeaderStatus) DeepCopyInto(out *LeaderStatus) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LeaderStatus. +func (in *LeaderStatus) DeepCopy() *LeaderStatus { + if in == nil { + return nil + } + out := new(LeaderStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LoadBalancerStrategy) DeepCopyInto(out *LoadBalancerStrategy) { *out = *in