@@ -132,23 +132,35 @@ func (ci *clusterScalingIntegration) inspectCluster(ctx context.Context, expectS
132
132
ci .lastNumberOfServers .mutex .Lock ()
133
133
defer ci .lastNumberOfServers .mutex .Unlock ()
134
134
desired := ci .lastNumberOfServers .NumberOfServers
135
- if req .Coordinators != nil && req .GetCoordinators () != desired .GetCoordinators () {
135
+ if req .Coordinators != nil && desired . Coordinators != nil && req .GetCoordinators () != desired .GetCoordinators () {
136
136
// #Coordinator has changed
137
137
coordinatorsChanged = true
138
138
}
139
- if req .DBServers != nil && req .GetDBServers () != desired .GetDBServers () {
139
+ if req .DBServers != nil && desired . DBServers != nil && req .GetDBServers () != desired .GetDBServers () {
140
140
// #DBServers has changed
141
141
dbserversChanged = true
142
142
}
143
143
if ! coordinatorsChanged && ! dbserversChanged {
144
+ // if there is nothing to change, check if we never have asked the cluster before
145
+ // if so, fill in the values for the first time.
146
+ // This happens, when the operator is redeployed and there has not been any
147
+ // update events yet.
148
+ if desired .Coordinators == nil || desired .DBServers == nil {
149
+ if req .Coordinators != nil {
150
+ ci .lastNumberOfServers .NumberOfServers .Coordinators = req .Coordinators
151
+ }
152
+ if req .DBServers != nil {
153
+ ci .lastNumberOfServers .NumberOfServers .DBServers = req .DBServers
154
+ }
155
+ }
156
+
144
157
// Nothing has changed
145
158
return nil
146
159
}
147
160
// Let's update the spec
148
161
apiObject := ci .depl .apiObject
149
162
current , err := ci .depl .deps .DatabaseCRCli .DatabaseV1alpha ().ArangoDeployments (apiObject .Namespace ).Get (apiObject .Name , metav1.GetOptions {})
150
163
if err != nil {
151
- log .Debug ().Err (err ).Msg ("Failed to get current deployment" )
152
164
return maskAny (err )
153
165
}
154
166
newSpec := current .Spec .DeepCopy ()
@@ -198,7 +210,7 @@ func (ci *clusterScalingIntegration) updateClusterServerCount(ctx context.Contex
198
210
ci .lastNumberOfServers .mutex .Unlock ()
199
211
200
212
// This is to prevent unneseccary updates that may override some values written by the WebUI (in the case of a update loop)
201
- if coordinatorCount != lastNumberOfServers .GetCoordinators () && dbserverCount != lastNumberOfServers .GetDBServers () {
213
+ if coordinatorCount != lastNumberOfServers .GetCoordinators () || dbserverCount != lastNumberOfServers .GetDBServers () {
202
214
if err := arangod .SetNumberOfServers (ctx , c .Connection (), coordinatorCount , dbserverCount ); err != nil {
203
215
if expectSuccess {
204
216
log .Debug ().Err (err ).Msg ("Failed to set number of servers" )
0 commit comments