Skip to content

Commit 2a82fec

Browse files
Merge pull request #1866 from giladravid16/tnf
OCPBUGS-58232: Don't wait for 2 etcd members when the cluster is TNF installed with assisted-installer
2 parents bac08ba + d738a31 commit 2a82fec

File tree

2 files changed

+31
-16
lines changed

2 files changed

+31
-16
lines changed

pkg/operator/starter.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,21 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle
208208
var notOnSingleReplicaTopology resourceapply.ConditionalFunction = func() bool {
209209
return infrastructure.Status.ControlPlaneTopology != configv1.SingleReplicaTopologyMode
210210
}
211+
isMultipleEtcdEndpointsRequired := true
212+
switch infrastructure.Status.ControlPlaneTopology {
213+
case configv1.SingleReplicaTopologyMode:
214+
isMultipleEtcdEndpointsRequired = false
215+
case configv1.DualReplicaTopologyMode:
216+
etcdNamespace, err := kubeClient.CoreV1().Namespaces().Get(ctx, "openshift-etcd", metav1.GetOptions{})
217+
if err != nil {
218+
return err
219+
}
220+
_, hasDelayedBootstrapAnnotation := etcdNamespace.Annotations["openshift.io/delayed-bootstrap"]
221+
isMultipleEtcdEndpointsRequired = !hasDelayedBootstrapAnnotation
222+
}
223+
var requireMultipleEtcdEndpoints resourceapply.ConditionalFunction = func() bool {
224+
return isMultipleEtcdEndpointsRequired
225+
}
211226

212227
staticResourceController := staticresourcecontroller.NewStaticResourceController(
213228
"KubeAPIServerStaticResources",
@@ -269,7 +284,7 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle
269284
kubeInformersForNamespaces,
270285
kubeClient,
271286
startupmonitorreadiness.IsStartupMonitorEnabledFunction(configInformers.Config().V1().Infrastructures().Lister(), operatorClient),
272-
notOnSingleReplicaTopology,
287+
requireMultipleEtcdEndpoints,
273288
controllerContext.EventRecorder,
274289
)
275290

pkg/operator/targetconfigcontroller/targetconfigcontroller.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ type TargetConfigController struct {
5656
kubeClient kubernetes.Interface
5757
configMapLister corev1listers.ConfigMapLister
5858

59-
isStartupMonitorEnabledFn func() (bool, error)
60-
notOnSingleReplicaTopologyFn func() bool
59+
isStartupMonitorEnabledFn func() (bool, error)
60+
requireMultipleEtcdEndpointsFn func() bool
6161
}
6262

6363
func NewTargetConfigController(
@@ -67,18 +67,18 @@ func NewTargetConfigController(
6767
kubeInformersForNamespaces v1helpers.KubeInformersForNamespaces,
6868
kubeClient kubernetes.Interface,
6969
isStartupMonitorEnabledFn func() (bool, error),
70-
notOnSingleReplicaTopologyFn func() bool,
70+
requireMultipleEtcdEndpointsFn func() bool,
7171
eventRecorder events.Recorder,
7272
) factory.Controller {
7373
c := &TargetConfigController{
74-
targetImagePullSpec: targetImagePullSpec,
75-
operatorImagePullSpec: operatorImagePullSpec,
76-
operatorImageVersion: operatorImageVersion,
77-
operatorClient: operatorClient,
78-
kubeClient: kubeClient,
79-
configMapLister: kubeInformersForNamespaces.ConfigMapLister(),
80-
isStartupMonitorEnabledFn: isStartupMonitorEnabledFn,
81-
notOnSingleReplicaTopologyFn: notOnSingleReplicaTopologyFn,
74+
targetImagePullSpec: targetImagePullSpec,
75+
operatorImagePullSpec: operatorImagePullSpec,
76+
operatorImageVersion: operatorImageVersion,
77+
operatorClient: operatorClient,
78+
kubeClient: kubeClient,
79+
configMapLister: kubeInformersForNamespaces.ConfigMapLister(),
80+
isStartupMonitorEnabledFn: isStartupMonitorEnabledFn,
81+
requireMultipleEtcdEndpointsFn: requireMultipleEtcdEndpointsFn,
8282
}
8383

8484
return factory.New().WithInformers(
@@ -112,8 +112,8 @@ func (c TargetConfigController) sync(ctx context.Context, syncContext factory.Sy
112112
}
113113

114114
// block until config is observed and specific paths are present
115-
isNotOnSingleReplicaTopology := c.notOnSingleReplicaTopologyFn()
116-
if err := c.isRequiredConfigPresent(operatorSpec.ObservedConfig.Raw, isNotOnSingleReplicaTopology); err != nil {
115+
requireMultipleEtcdEndpoints := c.requireMultipleEtcdEndpointsFn()
116+
if err := c.isRequiredConfigPresent(operatorSpec.ObservedConfig.Raw, requireMultipleEtcdEndpoints); err != nil {
117117
syncContext.Recorder().Warning("ConfigMissing", err.Error())
118118
return err
119119
}
@@ -129,7 +129,7 @@ func (c TargetConfigController) sync(ctx context.Context, syncContext factory.Sy
129129
return nil
130130
}
131131

132-
func (c *TargetConfigController) isRequiredConfigPresent(config []byte, isNotSingleNode bool) error {
132+
func (c *TargetConfigController) isRequiredConfigPresent(config []byte, requireMultipleEtcdEndpoints bool) error {
133133
if len(config) == 0 {
134134
return fmt.Errorf("no observedConfig")
135135
}
@@ -162,7 +162,7 @@ func (c *TargetConfigController) isRequiredConfigPresent(config []byte, isNotSin
162162
return fmt.Errorf("%v empty in config", strings.Join(requiredPath, "."))
163163
}
164164

165-
if len(requiredPath) == 2 && requiredPath[0] == "apiServerArguments" && requiredPath[1] == "etcd-servers" && isNotSingleNode {
165+
if len(requiredPath) == 2 && requiredPath[0] == "apiServerArguments" && requiredPath[1] == "etcd-servers" && requireMultipleEtcdEndpoints {
166166
configValSlice, ok := configVal.([]interface{})
167167
if !ok {
168168
return fmt.Errorf("%v is not a slice", strings.Join(requiredPath, "."))

0 commit comments

Comments
 (0)