You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement IsValueFromSecret and split Refresh into Refresh and RefreshNow (#46931)
### What does this PR do?
Implements `IsValueFromSecret` and `resolvedValues` map that keeps track of secrets and allows a caller to find out if a value came from an `ENC[]` field. This will allow callers to intelligently call `Refresh` instead of wasting Re-tries.
Refactors the `Refresh` function that had the `updateNow` argument, to become two functions: `Refresh` and `RefreshNow`
as a QOL, `Refresh` also checks if `apiKeyFailureRefreshInterval` and `r.backendCommand` is configured and returns a bool that denotes whether an invalid payload should be retried or not
### Motivation
### Describe how you validated your changes
CI
### Additional Notes
#46704 (comment)
Co-authored-by: saad.naji <saad.naji@datadoghq.com>
// SubscribeToChanges registers a callback to be invoked whenever secrets are resolved or refreshed
41
41
SubscribeToChanges(callbackSecretChangeCallback)
42
-
// Refresh will resolve secret handles again, notifying any subscribers of changed values.
43
-
// If updateNow is true, the function performs the refresh immediately and blocks, returning an informative message suitable for user display.
44
-
// If updateNow is false, the function will asynchronously perform a refresh, and may fail to refresh due to throttling. No message is returned, just an empty string.
45
-
Refresh(updateNowbool) (string, error)
42
+
// Refresh schedules a throttled asynchronous secret refresh. Returns true if the
43
+
// secret refresh mechanism is enabled (backend configured and refresh interval set).
44
+
Refresh() bool
45
+
// RefreshNow performs an immediate blocking secret refresh, returning an informative message suitable for user display.
46
+
RefreshNow() (string, error)
47
+
// IsValueFromSecret returns true if the given value was ever resolved from a secret handle.
48
+
IsValueFromSecret(valuestring) bool
46
49
// RemoveOrigin removes a origin from the internal cache of the secret component. This does not remove secrets
47
50
// from the cache but the reference where those secrets are used.
tlmSecretBackendElapsed: telemetry.NewGauge("secret_backend", "elapsed_ms", []string{"command", "exit_code"}, "Elapsed time of secret backend invocation"),
143
148
tlmSecretUnmarshalError: telemetry.NewCounter("secret_backend", "unmarshal_errors_count", []string{}, "Count of errors when unmarshalling the output of the secret binary"),
144
149
tlmSecretResolveError: telemetry.NewCounter("secret_backend", "resolve_errors_count", []string{"error_kind", "handle"}, "Count of errors when resolving a secret"),
// Refresh will resolve secret handles again, notifying any subscribers of changed values.
678
-
// If updateNow is true, the function performs the refresh immediately and blocks, returning an informative message suitable for user display.
679
-
// If updateNow is false, the function will asynchronously perform a refresh, and may fail to refresh due to throttling. No message is returned, just an empty string.
0 commit comments