@@ -54,7 +54,7 @@ type fleetCachedSecret struct {
5454
5555// NewFleetSecretsManager creates a new Fleet secrets manager
5656func NewFleetSecretsManager (logger * slog.Logger , cfg config.FleetSecretsManager ) * FleetSecretsManager {
57- timeout := 30 * time .Second
57+ timeout := 120 * time .Second
5858 if cfg .Timeout != nil && * cfg .Timeout > 0 {
5959 timeout = time .Duration (* cfg .Timeout ) * time .Second
6060 }
@@ -105,6 +105,9 @@ func (f *FleetSecretsManager) HandleMessage(topic string, payload []byte) error
105105 return f .handleResponse (payload )
106106 case f .updatedTopic :
107107 return f .handleUpdateNotification (payload )
108+ default :
109+ f .logger .Info ("received unknown message on topic" , "topic" , topic )
110+ return nil
108111 }
109112 return nil
110113}
@@ -115,6 +118,7 @@ func (f *FleetSecretsManager) handleResponse(payload []byte) error {
115118 f .logger .Error ("failed to unmarshal secret response" , "error" , err )
116119 return err
117120 }
121+ f .logger .Debug ("handling secret response" , "request_id" , response .RequestID , "status" , response .Status , "secrets" , len (response .Secrets ))
118122
119123 f .mu .Lock ()
120124 ch , exists := f .pendingReqs [response .RequestID ]
@@ -211,6 +215,7 @@ func (f *FleetSecretsManager) SolvePolicySecrets(payload config.PolicyPayload) (
211215 newPayload := payload
212216
213217 // Process the Data field
218+ // TODO: currently this will solve secrets sequentially - we should find all the secrets and then request them all at once
214219 processedData , err := f .processValue (payload .Data , payload .ID )
215220 if err != nil {
216221 return payload , err
@@ -304,6 +309,8 @@ func (f *FleetSecretsManager) processString(s string, id string) (string, error)
304309 return "" , fmt .Errorf ("failed to get secret %s: %w" , fleetPath , err )
305310 }
306311
312+ f .logger .Info ("got secret" , "secret_path" , fleetPath )
313+
307314 // Cache the secret
308315 f .mu .Lock ()
309316 f .usedVars [fleetPath ] = fleetCachedSecret {
@@ -344,6 +351,7 @@ func (f *FleetSecretsManager) processSlice(s []any, id string) ([]any, error) {
344351
345352// requestSecret requests a secret from the control plane via MQTT
346353func (f * FleetSecretsManager ) requestSecret (ctx context.Context , path string , policyIDs map [string ]bool ) (* messages.SecretValue , error ) {
354+ f .logger .Info ("requesting secret" , "path" , path , "policy_ids" , policyIDs )
347355 if f .publisher == nil {
348356 return nil , fmt .Errorf ("MQTT publisher not bound" )
349357 }
@@ -404,7 +412,7 @@ func (f *FleetSecretsManager) requestSecret(ctx context.Context, path string, po
404412 case <- ctx .Done ():
405413 return nil , fmt .Errorf ("context canceled while waiting for secret response" )
406414 case <- time .After (f .timeout ):
407- return nil , fmt .Errorf ("timeout waiting for secret response" )
415+ return nil , fmt .Errorf ("timeout waiting for secret response after %s" , f . timeout )
408416 }
409417}
410418
0 commit comments