@@ -132,8 +132,31 @@ func (fso *FileServiceOperator) UpdateOverview(
132132 },
133133 }
134134
135- backOffCtx , backoffCancel := context .WithTimeout (newCtx , fso .agentConfig .Client .Backoff .MaxElapsedTime )
136- defer backoffCancel ()
135+ backoffSettings := & config.BackOff {
136+ InitialInterval : fso .agentConfig .Client .Backoff .InitialInterval ,
137+ MaxInterval : fso .agentConfig .Client .Backoff .MaxInterval ,
138+ MaxElapsedTime : fso .agentConfig .Client .Backoff .MaxElapsedTime ,
139+ RandomizationFactor : fso .agentConfig .Client .Backoff .RandomizationFactor ,
140+ Multiplier : fso .agentConfig .Client .Backoff .Multiplier ,
141+ }
142+
143+ // If the create connection takes a long time that we wait indefinitely to do
144+ // the initial file overview update to ensure that the management plane has a file overview
145+ // on agent startup.
146+ if ! fso .isConnected .Load () {
147+ slog .DebugContext (
148+ newCtx ,
149+ "Not connected to management plane yet, " +
150+ "retrying indefinitely to update file overview until connection is created" ,
151+ )
152+ backoffSettings = & config.BackOff {
153+ InitialInterval : fso .agentConfig .Client .Backoff .InitialInterval ,
154+ MaxInterval : fso .agentConfig .Client .Backoff .MaxInterval ,
155+ MaxElapsedTime : 0 ,
156+ RandomizationFactor : fso .agentConfig .Client .Backoff .RandomizationFactor ,
157+ Multiplier : fso .agentConfig .Client .Backoff .Multiplier ,
158+ }
159+ }
137160
138161 sendUpdateOverview := func () (* mpi.UpdateOverviewResponse , error ) {
139162 if fso .fileServiceClient == nil {
@@ -162,10 +185,9 @@ func (fso *FileServiceOperator) UpdateOverview(
162185 return response , nil
163186 }
164187
165- backoffSettings := fso .agentConfig .Client .Backoff
166188 response , err := backoff .RetryWithData (
167189 sendUpdateOverview ,
168- backoffHelpers .Context (backOffCtx , backoffSettings ),
190+ backoffHelpers .Context (newCtx , backoffSettings ),
169191 )
170192 if err != nil {
171193 return err
@@ -174,11 +196,13 @@ func (fso *FileServiceOperator) UpdateOverview(
174196 slog .DebugContext (newCtx , "UpdateOverview response" , "response" , response )
175197
176198 if response .GetOverview () == nil {
177- slog .DebugContext (ctx , "UpdateOverview response is empty" )
199+ slog .DebugContext (newCtx , "UpdateOverview response is empty" )
178200 return nil
179201 }
180202 delta := files .ConvertToMapOfFiles (response .GetOverview ().GetFiles ())
181203
204+ // Make sure that the original context is used if a file upload is required so that original correlation ID
205+ // can be used again for update file overview request
182206 if len (delta ) != 0 {
183207 return fso .updateFiles (ctx , delta , instanceID , configPath , iteration )
184208 }
0 commit comments