Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.17] OCPBUGS-42620: Include bootstrap IP in etcd endpoints list #1814

Open
wants to merge 1 commit into
base: release-4.17
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions pkg/operator/configobserver/etcd/observe_etcd_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ const (
etcdEndpointName = "etcd-endpoints"

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

var (
Expand Down Expand Up @@ -94,12 +95,19 @@ func innerObserveStorageURLs(fallbackObserver fallBackObserverFn, alwaysAppendLo
return previouslyObservedConfig, append(errs, err)
}

// note: etcd bootstrap should never be added to the in-cluster kube-apiserver
// this can result in some early pods crashlooping, but ensures that we never contact the bootstrap machine from
// the in-cluster kube-apiserver so we can safely teardown out of order.

allEtcdEnpoints := []string{}
for k := range etcdEndpoints.Data {
address := etcdEndpoints.Data[k]
allEtcdEnpoints = append(allEtcdEnpoints, etcdEndpoints.Data[k])
}

// include etcd bootstrap IP in the list
// this ensures that all masters use it and their local etcd can be torn down / updated
// and this won't block revision rollout
if bootstrapIP, found := etcdEndpoints.GetAnnotations()[BootstrapIPAnnotationKey]; found {
allEtcdEnpoints = append(allEtcdEnpoints, bootstrapIP)
}

for _, address := range allEtcdEnpoints {
ip := net.ParseIP(address)
if ip == nil {
ipErr := fmt.Errorf("configmaps/%s in the %s namespace: %v is not a valid IP address", etcdEndpointName, EtcdEndpointNamespace, address)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@ func TestInnerObserveStorageURLs(t *testing.T) {
expectErrors: true,
},
{
name: "IgnoreBootstrap",
name: "BootstrapIncluded",
currentConfigFor: observedConfigFor(withStorageURLFor("https://previous.url:2379")),
endpoint: endpoints(
withBootstrap("10.0.0.2"),
withAddress("10.0.0.1"),
),
expectedConfigFor: observedConfigFor(withStorageURLFor("https://10.0.0.1:2379")),
expectedConfigFor: observedConfigFor(withStorageURLFor("https://10.0.0.1:2379"), withStorageURLFor("https://10.0.0.2:2379")),
},
}
for _, tt := range tests {
Expand Down