Gorse runasnonroot failure

From divinevideo/divine-mobile · View interactive version

Gorse runasnonroot failure is an AI agent skill from the GitHub repository divinevideo/divine-mobile. Fix Gorse recommendation engine pods crashing with "user: unknown userid 65532" error. Use when: (1) Gorse master/server/worker pods show CrashLoopBackOff or Error status, (2) Logs show "failed to get user directory" with unknown userid, (3) Running gorse containers with runAsNonRoot security contex

How to use this skill

Skill file

Gorse runAsNonRoot Container Failure

Problem

Gorse recommendation engine containers (master, server, worker) crash immediately on

startup when running with Kubernetes runAsNonRoot: true and a custom UID like 65532.

Context / Trigger Conditions

```

{"level":"fatal","ts":...,"caller":"model/built_in.go:95","msg":"failed to get user directory","error":"user: unknown userid 65532"}

```

Root Cause

The gorse codebase calls Go's os.UserHomeDir() during initialization in model/built_in.go.

This function requires the running UID to have an entry in /etc/passwd. When running as

a non-root user that doesn't exist in the container's passwd file, the lookup fails.

Solution

Remove the runAsNonRoot and runAsUser constraints from the pod security context:

# Before (broken)
spec:
  template:
    spec:
      securityContext:
        runAsNonRoot: true
        runAsUser: 65532
        fsGroup: 65532

# After (working)
spec:
  template:
    spec:
      securityContext:
        fsGroup: 1000

Apply to all gorse deployments:

Verification

After updating the security context:

  1. Delete existing crashing pods: kubectl delete pods -l app.kubernetes.io/name=gorse -n gorse
  2. Wait for new pods to start
  3. Check logs: kubectl logs -l app=gorse-master -n gorse
  4. Verify master shows connection to data store and cache store

Notes

with proper /etc/passwd entries for the desired UID

Related Issues

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.