@@ -132,8 +132,31 @@ func (fso *FileServiceOperator) UpdateOverview(
132
132
},
133
133
}
134
134
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
+ }
137
160
138
161
sendUpdateOverview := func () (* mpi.UpdateOverviewResponse , error ) {
139
162
if fso .fileServiceClient == nil {
@@ -162,10 +185,9 @@ func (fso *FileServiceOperator) UpdateOverview(
162
185
return response , nil
163
186
}
164
187
165
- backoffSettings := fso .agentConfig .Client .Backoff
166
188
response , err := backoff .RetryWithData (
167
189
sendUpdateOverview ,
168
- backoffHelpers .Context (backOffCtx , backoffSettings ),
190
+ backoffHelpers .Context (newCtx , backoffSettings ),
169
191
)
170
192
if err != nil {
171
193
return err
@@ -174,11 +196,13 @@ func (fso *FileServiceOperator) UpdateOverview(
174
196
slog .DebugContext (newCtx , "UpdateOverview response" , "response" , response )
175
197
176
198
if response .GetOverview () == nil {
177
- slog .DebugContext (ctx , "UpdateOverview response is empty" )
199
+ slog .DebugContext (newCtx , "UpdateOverview response is empty" )
178
200
return nil
179
201
}
180
202
delta := files .ConvertToMapOfFiles (response .GetOverview ().GetFiles ())
181
203
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
182
206
if len (delta ) != 0 {
183
207
return fso .updateFiles (ctx , delta , instanceID , configPath , iteration )
184
208
}
0 commit comments