@@ -132,23 +132,35 @@ func (ci *clusterScalingIntegration) inspectCluster(ctx context.Context, expectS
132132 ci .lastNumberOfServers .mutex .Lock ()
133133 defer ci .lastNumberOfServers .mutex .Unlock ()
134134 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 () {
136136 // #Coordinator has changed
137137 coordinatorsChanged = true
138138 }
139- if req .DBServers != nil && req .GetDBServers () != desired .GetDBServers () {
139+ if req .DBServers != nil && desired . DBServers != nil && req .GetDBServers () != desired .GetDBServers () {
140140 // #DBServers has changed
141141 dbserversChanged = true
142142 }
143143 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+
144157 // Nothing has changed
145158 return nil
146159 }
147160 // Let's update the spec
148161 apiObject := ci .depl .apiObject
149162 current , err := ci .depl .deps .DatabaseCRCli .DatabaseV1alpha ().ArangoDeployments (apiObject .Namespace ).Get (apiObject .Name , metav1.GetOptions {})
150163 if err != nil {
151- log .Debug ().Err (err ).Msg ("Failed to get current deployment" )
152164 return maskAny (err )
153165 }
154166 newSpec := current .Spec .DeepCopy ()
@@ -198,7 +210,7 @@ func (ci *clusterScalingIntegration) updateClusterServerCount(ctx context.Contex
198210 ci .lastNumberOfServers .mutex .Unlock ()
199211
200212 // 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 () {
202214 if err := arangod .SetNumberOfServers (ctx , c .Connection (), coordinatorCount , dbserverCount ); err != nil {
203215 if expectSuccess {
204216 log .Debug ().Err (err ).Msg ("Failed to set number of servers" )
0 commit comments