@@ -57,6 +57,39 @@ import (
57
57
"sigs.k8s.io/controller-runtime/pkg/client"
58
58
)
59
59
60
+ // addPodsReconciler is the reconciler for addPods.
61
+ var addPodsReconciler = addPods {}
62
+
63
+ // subReconcilers has the ordered list of all reconcilers that should be used by the cluster controller.
64
+ var subReconcilers = []clusterSubReconciler {
65
+ updateStatus {},
66
+ updateLockConfiguration {},
67
+ updateConfigMap {},
68
+ checkClientCompatibility {},
69
+ deletePodsForBuggification {},
70
+ replaceMisconfiguredProcessGroups {},
71
+ replaceFailedProcessGroups {},
72
+ addProcessGroups {},
73
+ addServices {},
74
+ addPVCs {},
75
+ addPodsReconciler ,
76
+ generateInitialClusterFile {},
77
+ removeIncompatibleProcesses {},
78
+ updateSidecarVersions {},
79
+ updatePodConfig {},
80
+ updateMetadata {},
81
+ updateDatabaseConfiguration {},
82
+ chooseRemovals {},
83
+ excludeProcesses {},
84
+ changeCoordinators {},
85
+ bounceProcesses {},
86
+ maintenanceModeChecker {},
87
+ updatePods {},
88
+ removeProcessGroups {},
89
+ removeServices {},
90
+ updateStatus {},
91
+ }
92
+
60
93
// FoundationDBClusterReconciler reconciles a FoundationDBCluster object
61
94
type FoundationDBClusterReconciler struct {
62
95
client.Client
@@ -148,20 +181,19 @@ func (r *FoundationDBClusterReconciler) Reconcile(ctx context.Context, request c
148
181
return ctrl.Result {}, err
149
182
}
150
183
184
+ err = cluster .Validate ()
185
+ if err != nil {
186
+ r .Recorder .Event (cluster , corev1 .EventTypeWarning , "ClusterSpec not valid" , err .Error ())
187
+ return ctrl.Result {}, fmt .Errorf ("ClusterSpec is not valid: %w" , err )
188
+ }
189
+
151
190
adminClient , err := r .getAdminClient (clusterLog , cluster )
152
191
if err != nil {
153
192
return ctrl.Result {}, err
154
193
}
155
194
defer func () {
156
195
_ = adminClient .Close ()
157
196
}()
158
-
159
- err = cluster .Validate ()
160
- if err != nil {
161
- r .Recorder .Event (cluster , corev1 .EventTypeWarning , "ClusterSpec not valid" , err .Error ())
162
- return ctrl.Result {}, fmt .Errorf ("ClusterSpec is not valid: %w" , err )
163
- }
164
-
165
197
supportedVersion , err := adminClient .VersionSupported (cluster .Spec .Version )
166
198
if err != nil {
167
199
return ctrl.Result {}, err
@@ -170,6 +202,17 @@ func (r *FoundationDBClusterReconciler) Reconcile(ctx context.Context, request c
170
202
return ctrl.Result {}, fmt .Errorf ("version %s is not supported" , cluster .Spec .Version )
171
203
}
172
204
205
+ // When using DNS entries in the cluster file, we want to make sure to create pods if required before doing any
206
+ // interaction with the FDB cluster. If none of the coordinator pods is running, this will cause a crash in the FDB
207
+ // go bindings (or rather the C client). To prevent those case we run the addPods reconciler before interacting with
208
+ // the FoundationDB cluster.
209
+ if cluster .UseDNSInClusterFile () {
210
+ req := runClusterSubReconciler (ctx , clusterLog , addPodsReconciler , r , cluster , nil )
211
+ if req != nil && ! req .delayedRequeue {
212
+ return processRequeue (req , addPodsReconciler , cluster , r .Recorder , clusterLog )
213
+ }
214
+ }
215
+
173
216
var status * fdbv1beta2.FoundationDBStatus
174
217
if cacheStatus {
175
218
clusterLog .Info ("Fetch machine-readable status for reconcilitation loop" , "cacheStatus" , cacheStatus )
@@ -179,35 +222,6 @@ func (r *FoundationDBClusterReconciler) Reconcile(ctx context.Context, request c
179
222
}
180
223
}
181
224
182
- subReconcilers := []clusterSubReconciler {
183
- updateStatus {},
184
- updateLockConfiguration {},
185
- updateConfigMap {},
186
- checkClientCompatibility {},
187
- deletePodsForBuggification {},
188
- replaceMisconfiguredProcessGroups {},
189
- replaceFailedProcessGroups {},
190
- addProcessGroups {},
191
- addServices {},
192
- addPVCs {},
193
- addPods {},
194
- generateInitialClusterFile {},
195
- removeIncompatibleProcesses {},
196
- updateSidecarVersions {},
197
- updatePodConfig {},
198
- updateMetadata {},
199
- updateDatabaseConfiguration {},
200
- chooseRemovals {},
201
- excludeProcesses {},
202
- changeCoordinators {},
203
- bounceProcesses {},
204
- maintenanceModeChecker {},
205
- updatePods {},
206
- removeProcessGroups {},
207
- removeServices {},
208
- updateStatus {},
209
- }
210
-
211
225
originalGeneration := cluster .ObjectMeta .Generation
212
226
normalizedSpec := cluster .Spec .DeepCopy ()
213
227
var delayedRequeueDuration time.Duration
0 commit comments