Skip to content

Commit c79e835

Browse files
author
Vadim Rutkovsky
committed
Include bootstrap IP in etcd endpoints list
During bootstrap kube-apiserver points to master etcd instances. These instances are being added to etcd-servers list one by one, to ensure that if any master can't reach some other etcds this revision won't block the entire rollout. However, at some point the masters may end up with just one etcd (localhost and its IP), which makes it non-HA and apiserver may lose etcd connection if this etcd is being reconfigured. This change updates the list to include bootstrap etcd so that any master would always have an etcd instance to connect to.
1 parent 4d5adc7 commit c79e835

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

pkg/operator/configobserver/etcd/observe_etcd_endpoints.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ const (
1818
etcdEndpointName = "etcd-endpoints"
1919

2020
// EtcdEndpointName points to the old host-etcd-2 endpoint applicable for clusters prior to 4.5
21-
EtcdEndpointName = "host-etcd-2"
21+
EtcdEndpointName = "host-etcd-2"
22+
BootstrapIPAnnotationKey = "alpha.installer.openshift.io/etcd-bootstrap"
2223
)
2324

2425
var (
@@ -94,12 +95,19 @@ func innerObserveStorageURLs(fallbackObserver fallBackObserverFn, alwaysAppendLo
9495
return previouslyObservedConfig, append(errs, err)
9596
}
9697

97-
// note: etcd bootstrap should never be added to the in-cluster kube-apiserver
98-
// this can result in some early pods crashlooping, but ensures that we never contact the bootstrap machine from
99-
// the in-cluster kube-apiserver so we can safely teardown out of order.
100-
98+
allEtcdEnpoints := []string{}
10199
for k := range etcdEndpoints.Data {
102-
address := etcdEndpoints.Data[k]
100+
allEtcdEnpoints = append(allEtcdEnpoints, etcdEndpoints.Data[k])
101+
}
102+
103+
// include etcd bootstrap IP in the list
104+
// this ensures that all masters use it and their local etcd can be torn down / updated
105+
// and this won't block revision rollout
106+
if bootstrapIP, found := etcdEndpoints.GetAnnotations()[BootstrapIPAnnotationKey]; found {
107+
allEtcdEnpoints = append(allEtcdEnpoints, bootstrapIP)
108+
}
109+
110+
for _, address := range allEtcdEnpoints {
103111
ip := net.ParseIP(address)
104112
if ip == nil {
105113
ipErr := fmt.Errorf("configmaps/%s in the %s namespace: %v is not a valid IP address", etcdEndpointName, EtcdEndpointNamespace, address)

pkg/operator/configobserver/etcd/observe_etcd_endpoints_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ func TestInnerObserveStorageURLs(t *testing.T) {
184184
expectErrors: true,
185185
},
186186
{
187-
name: "IgnoreBootstrap",
187+
name: "BootstrapIncluded",
188188
currentConfigFor: observedConfigFor(withStorageURLFor("https://previous.url:2379")),
189189
endpoint: endpoints(
190190
withBootstrap("10.0.0.2"),
191191
withAddress("10.0.0.1"),
192192
),
193-
expectedConfigFor: observedConfigFor(withStorageURLFor("https://10.0.0.1:2379")),
193+
expectedConfigFor: observedConfigFor(withStorageURLFor("https://10.0.0.1:2379"), withStorageURLFor("https://10.0.0.2:2379")),
194194
},
195195
}
196196
for _, tt := range tests {

0 commit comments

Comments
 (0)