fix: writable emptyDir for gmail oauth token refresh #151
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/basketball-api!151
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "136-fix-gmail-oauth-readonly-mount"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
OSError: Read-only file systembecause the gmail_sdk writes refreshed tokens to a k8s secret volume mounted read-onlyChanges
k8s/deployment.yaml: addedcopy-gmail-oauthinit container (busybox:1.36) that copies secret data from read-only mount to writable emptyDir. Changed app container volumeMount from read-onlygmail-oauthto writablegmail-oauth-writable. Addedgmail-oauth-writableemptyDir volume.Test Plan
POST /api/password-reset/request)Review Checklist
Related
Review: PASS -- no issues found.
Reviewed the diff (+13/-2, single file):
copy-gmail-oauth, busybox:1.36) correctly copies from read-only secret mount to writable emptyDirgmail-oauth(readOnly) togmail-oauth-writable(writable)BASKETBALL_GMAIL_SECRETS_DIRenv var unchanged -- path consistency maintained at/secrets/google-oauthThis is the in-repo k8s manifest. Companion PR pal-e-deployments#43 carries the production kustomize overlay fix.
PR #151 Review
DOMAIN REVIEW
Tech stack: Kubernetes deployment YAML (kustomize base manifest). No application code changed.
Pattern assessment: The init container + emptyDir pattern is a well-established Kubernetes idiom for making secret-mounted files writable. The design is correct:
copy-gmail-oauth) mounts thegmail-oauthsecret volume read-only at/secrets-ro/google-oauth, copies all files to emptyDir at/secrets/google-oauth./secrets/google-oauth-- same path the app expects viaBASKETBALL_GMAIL_SECRETS_DIR=/secrets/google-oauth.gmail-oauth(secret) andgmail-oauth-writable(emptyDir) are declared in the volumes section. The secret volume is still needed for the init container source.Verified: The
BASKETBALL_GMAIL_SECRETS_DIRenv var (line 58 in deployment.yaml) points to/secrets/google-oauth, which matches the emptyDir mountPath on the app container. Path alignment is correct.Verified: The
gmail_sdk.GmailClientinsrc/basketball_api/services/email.pyusessettings.gmail_secrets_dirfor token read/write. The writable emptyDir mount at that path resolves theOSError: Read-only file systemcrash.BLOCKERS
None.
This is a pure infrastructure fix -- a single k8s manifest change with no application code modifications. The BLOCKER criteria do not apply:
pytest,ruff check,ruff format) validates application code, not k8s manifests. The Test Plan appropriately describes manual validation steps (deploy, wait for token expiry, trigger email endpoint, verify).gmail-oauth-token) is a k8s secret name, not a credential.NITS
busybox image tag:
busybox:1.36is a minor-version tag that will float across patch releases. For reproducibility, consider pinning to a digest or patch version (e.g.,busybox:1.36.1). Low risk given the trivialcpcommand, but worth noting for supply-chain hygiene.Glob safety on cp command: The command
cp /secrets-ro/google-oauth/* /secrets/google-oauth/relies on shell globbing. If the secret has no keys (empty secret), the glob will fail with "No match" on busybox sh. This is an unlikely edge case (the secret must have keys to function), but a defensive alternative would be:cp -r /secrets-ro/google-oauth/. /secrets/google-oauth/which avoids glob expansion entirely.No resource limits on init container: The init container has no
resourcesblock. For acpof a few small OAuth token files this is fine in practice, but adding minimal limits (e.g.,cpu: 10m,memory: 16Mi) would be consistent with the app container's resource discipline.SOP COMPLIANCE
136-fix-gmail-oauth-readonly-mountreferences #136)plan-wkq. It referencesCloses #136and companion PR but no plan slug.fix: writable emptyDir for gmail oauth token refresh)PROCESS OBSERVATIONS
pal-e-deploymentsfor the production kustomize overlay. Reviewers should verify the companion PR carries the same emptyDir + init container pattern before merging either PR.VERDICT: APPROVED