Replace secrets helper with secret-generic-connector in /readsecret.sh #3685
All Vouch review confidence checks passed
Residual risk 0.45 = Change Risk (0.82) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.82 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.344
Sensitive Paths
sensitive_paths
0.082
Real PR Conversation Timeline
1 comments
"Review active on #3685"
general
weight: 0.35
levan-m
What does this PR do?
CONTP-2242
/readsecret.shnow reads secrets with the secret-generic-connector (SGC) that already ships in the operator image, instead of the/helpersbinary./helpersis removed from the image.Nothing changes for users. They keep the same configuration:
secretBackend.command=/readsecret.shsecretBackend.arguments=<directory>ENC[<key>]referencesHow it works. SGC doesn't take the directory as a command-line argument. It reads its backend settings from the JSON the operator writes to stdin. The script adds the
k8s.filebackend and the directory to that JSON, then runs SGC.The script also keeps the old helper's rules:
argumentsstill worksMotivation
One binary for secret resolution in the operator image instead of two.
Additional Notes
Compatibility. The documented setup works the same as before. I compared this branch with the current image on:
..datasymlink layoutitems/pathremapping and projected volumes.,-and uppercase lettersapiKey/appKey: ENC[...]spec.global.credentialsENC[...]secretBackend.refreshIntervalBreaking changes. Both affect undocumented behaviour:
ENC[../x], a reference that leaves the configured directory, is now rejected. The old helper allowed it, which was a path-traversal hole.docs/secret_management.mdnow says references must stay inside the directory./helpersbinary and its source (cmd/helpers/) are removed, so anyone calling it directly (instead of/readsecret.sh) breaks.Security note. SGC follows a symlink inside the directory that points outside it; the old helper refused. Kubernetes Secret volumes never create such links. The proper fix belongs in SGC.
Not tested: arm64 at runtime (the SGC image is published for arm64), OpenShift with random UIDs,
readOnlyRootFilesystem.Minimum Agent Versions
N/A (operator-only change).
Describe your test plan
This procedure was run verbatim on a fresh kind cluster against this branch before it was posted. Every step has a command and its expected output, so a human or an agent can follow it as written.
Goal. Check that the documented usage of the operator's secret helper (
secretBackend.command=/readsecret.sh,secretBackend.arguments=<dir>, a mounted Secret,ENC[<key>]) works exactly as before, now that the script calls SGC instead of the/helpersbinary.Runs on Linux or macOS with
docker,kind(v0.20+),kubectlandhelm(v3). It takes about 20 minutes. Every step lists the command and the expected result; a step fails if its output doesn't match.The API and app keys are fake. 403 responses from Datadog in the operator logs are expected: they prove a resolved key was sent.
0. Setup
1. Unit tests, build the image, check its contents
Expected:
--- PASS: TestReadSecretScript_payloadand--- PASS: TestReadSecretScript_rejectsInvalidInput, with every subtest passing.Expected:
PASS: /helpers removedsecret-generic-connector <SGC_VERSION>(7.85.4 at the time of writing)InvalidDefaultArgInFromfor the SGC base image is expected and harmless:SGC_VERSIONis passed explicitly/readsecret.shwith mode-r-xr-x---PASS: script calls SGC2. Cluster, Secret, operator
2a. Operator is configured and running
Expected:
-secretBackendCommand=/readsecret.sh,-secretBackendArgs=/etc/secret-volumeand-secretRefreshInterval=20s1/1 Runningwith 0 restartsUnable to get credentialscount is0, meaning the operator resolvedENC[api_key]/ENC[app_key]through/readsecret.shat startupStarting secret refresh routineline with"interval":203. Operator credentials (end to end)
3a. Negative control: an unknown handle is reported
Expected:
an error occurred while decrypting 'does_not_exist': failed to stat secret file 'does_not_exist': stat /etc/secret-volume/does_not_exist: no such file or directory. Thefailed to stat secret filepart is SGC's own wording, which shows SGC handled the request.3b. Restore
4. Script behaviour inside the operator pod
Each check sends the same payload the operator sends.
r <dir> '<json secrets list>' [extra args...]prints the script's stdout and exit code. The image has nogrep/sed, so output is filtered on the host.Expected:
| ID | Expected output | Meaning |
|---|---|---|
| T1 | listing includes
..data -> ..<timestamp>andapi_key -> ..data/api_key| real kubelet atomic layout || T2 |
{"api_key":{"value":"fake-api-key-v1","error":null},"app_key":{"value":"fake-app-key-v1","error":null}} [rc=0]| documented usage || T3 |
api_key→fake-api-key-v1,[rc=0]| a trailing space inargumentskeeps working || T4 |
api_key→fake-api-key-v1,[rc=0]| || T5 |
app.key-Mixed_1→dotted-value,[rc=0]| || T6 |
exact8192→<8192 a>,"error":null,[rc=0]| at the size limit || T7 |
"value":null,"error":"secret file 'over8192' exceeds maximum size limit of 8192 bytes ...",[rc=0]| 8 KiB limit kept || T8 |
"value":null,"error":"failed to stat secret file 'nope': ...",[rc=0]| per-secret error, as before || T9 |
"value":null,"error":"path outside allowed directory",[rc=0]| intentional change: the old helper returned the content of/etc/hostname|| T10 |
Error: expected exactly 1 argument (secrets directory), got 0,[rc=1]| || T11 |
Error: expected exactly 1 argument (secrets directory), got 2,[rc=1]| || T12 |
Error: incompatible protocol version,[rc=1]| || T13 |
Error: no secrets listed in input,[rc=1]| || T14 |
Error: failed to unmarshal json input,[rc=1]| || T15 |
api_key→fake-api-key-v1,[rc=0]| valid JSON with leading whitespace is accepted, as before |5. Secret rotation with
refreshIntervalExpected:
"msg":"Credentials have changed, cache updated"within 3 minutes (kubelet sync plus a 20s refresh).5b. Negative: the key is removed from the Secret
Expected:
an error occurred while decrypting 'api_key': failed to stat secret file 'api_key': .... The operator staysRunning.6. Other documented Secret mount layouts
Expected:
dd/api→val-aandapp_key→val-dot, both"error":null,[rc=0]api_key→val-aandother→val-b,[rc=0]7. DatadogAgent
ENC[...]credentials (operator without its own keys)When the operator has no
apiKey/appKey, it resolvesspec.global.credentialsfrom the DatadogAgent through the same secret backend.Expected:
decryptingcount is0received error status code 403from ametadata.*logger, meaning the key resolved from the DatadogAgent was sent7b. Negative
Expected:
an error occurred while decrypting 'nope': failed to stat secret file 'nope': ...8. Optional: compare with the released operator
To confirm parity, rerun step 4 against the last release, which still uses
/helpers:Deploy it the same way, with
image.repository=registry.datadoghq.com/operator,image.tag=1.31.2andpullPolicy=IfNotPresent, then run step 4. Expected differences:"error":null.secret exceeds max allowed size,secret does not exist).1. The old error message is followed by cobra's usage text.9. Cleanup
Pass criteria
All of steps 1–7 match their expected output. The intended behaviour changes are:
../handles are rejected/helpersis gone from the imageAnything else that differs is a failure.
Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel[1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
🤖 Generated with Claude Code