[PR #2180] [MERGED] feat(doctor): add user namespace detection and improved storage diagnostics #9821

Closed
opened 2026-04-23 09:13:59 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/2180
Author: @kolaente
Created: 1/30/2026
Status: Merged
Merged: 2/1/2026
Merged by: @kolaente

Base: mainHead: claude/rootless-docker-diagnostics-JflCq


📝 Commits (6)

  • c31e4dc feat(utils): add Linux user namespace detection
  • 8cfcd9f feat(files): add diagnostic context to storage validation errors
  • 8a80242 feat(doctor): add user namespace check to system diagnostics
  • 8720b9e feat(doctor): enhance ownership check with user namespace awareness
  • 054fc17 fix(utils): use int64 for UIDMapEntry fields to prevent 32-bit overflow
  • d71ada3 fix(files): prevent trailing blank line in storage errors and defend GetUIDMapping against caller mutation

📊 Changes

10 files changed (+506 additions, -9 deletions)

View changed files

📝 pkg/doctor/files_unix.go (+31 -6)
📝 pkg/doctor/system.go (+1 -0)
pkg/doctor/userns_linux.go (+40 -0)
pkg/doctor/userns_other.go (+27 -0)
pkg/files/diagnostics_unix.go (+69 -0)
pkg/files/diagnostics_windows.go (+23 -0)
📝 pkg/files/filehandling.go (+8 -3)
pkg/utils/userns_linux.go (+156 -0)
pkg/utils/userns_linux_test.go (+111 -0)
pkg/utils/userns_other.go (+40 -0)

📄 Description

Summary

This PR adds comprehensive support for detecting and handling Linux user namespaces (commonly used in rootless Docker containers) and improves error diagnostics when file storage validation fails.

Key Changes

  • User namespace detection utilities (pkg/utils/userns_linux.go):

    • Parse /proc/self/uid_map to detect active user namespaces
    • Map container UIDs to host UIDs for diagnostics
    • Generate human-readable UID mapping summaries
    • Includes comprehensive unit tests for parsing and mapping logic
  • Enhanced directory ownership checks (pkg/doctor/files_unix.go):

    • Detect when user namespaces are active
    • Display mapped host UID in error messages when applicable
    • Add informational warnings about user namespace implications
    • Help users understand UID mismatches in containerized environments
  • System diagnostics (pkg/doctor/system.go, pkg/doctor/userns_linux.go, pkg/doctor/userns_other.go):

    • New checkUserNamespace() function to report namespace status
    • Platform-specific implementations (Linux vs. other OS)
    • Integrated into system health checks
  • Storage validation improvements (pkg/files/filehandling.go, pkg/files/diagnostics_unix.go, pkg/files/diagnostics_windows.go):

    • New storageDiagnosticInfo() function that gathers:
      • Process UID/GID
      • Directory owner UID/GID
      • User namespace status and mappings
      • Mapped host UID when applicable
    • Append diagnostic info to storage validation error messages
    • Platform-specific implementations with helpful hints for rootless containers

Implementation Details

  • Uses build tags (//go:build linux, //go:build !linux) for platform-specific code
  • Lazy-loads and caches UID map parsing with sync.Once for efficiency
  • Detects "trivial" mappings (identity mapping) to distinguish between normal and containerized environments
  • Provides actionable hints in error messages (e.g., suggesting --user 0:0 flag)
  • All new code includes proper AGPL license headers

https://claude.ai/code/session_01YS8TxFvNwduFQuL1jkNt29

Docs PR: https://github.com/go-vikunja/website/pull/289


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-vikunja/vikunja/pull/2180 **Author:** [@kolaente](https://github.com/kolaente) **Created:** 1/30/2026 **Status:** ✅ Merged **Merged:** 2/1/2026 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `claude/rootless-docker-diagnostics-JflCq` --- ### 📝 Commits (6) - [`c31e4dc`](https://github.com/go-vikunja/vikunja/commit/c31e4dc63d86484eaa600cbe48d96576ea0967c3) feat(utils): add Linux user namespace detection - [`8cfcd9f`](https://github.com/go-vikunja/vikunja/commit/8cfcd9f39e63d4a4ed6dc2f3acca3c44f558a19e) feat(files): add diagnostic context to storage validation errors - [`8a80242`](https://github.com/go-vikunja/vikunja/commit/8a80242479b198edfc949c897a751ebbe721f922) feat(doctor): add user namespace check to system diagnostics - [`8720b9e`](https://github.com/go-vikunja/vikunja/commit/8720b9ecde326502348ffc01679d39c6e4c6fc81) feat(doctor): enhance ownership check with user namespace awareness - [`054fc17`](https://github.com/go-vikunja/vikunja/commit/054fc1749df41ee18a83981cbe8814601d62afad) fix(utils): use int64 for UIDMapEntry fields to prevent 32-bit overflow - [`d71ada3`](https://github.com/go-vikunja/vikunja/commit/d71ada31eacd854311b4240a39e97c6cbfa7d2f6) fix(files): prevent trailing blank line in storage errors and defend GetUIDMapping against caller mutation ### 📊 Changes **10 files changed** (+506 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `pkg/doctor/files_unix.go` (+31 -6) 📝 `pkg/doctor/system.go` (+1 -0) ➕ `pkg/doctor/userns_linux.go` (+40 -0) ➕ `pkg/doctor/userns_other.go` (+27 -0) ➕ `pkg/files/diagnostics_unix.go` (+69 -0) ➕ `pkg/files/diagnostics_windows.go` (+23 -0) 📝 `pkg/files/filehandling.go` (+8 -3) ➕ `pkg/utils/userns_linux.go` (+156 -0) ➕ `pkg/utils/userns_linux_test.go` (+111 -0) ➕ `pkg/utils/userns_other.go` (+40 -0) </details> ### 📄 Description ## Summary This PR adds comprehensive support for detecting and handling Linux user namespaces (commonly used in rootless Docker containers) and improves error diagnostics when file storage validation fails. ## Key Changes - **User namespace detection utilities** (`pkg/utils/userns_linux.go`): - Parse `/proc/self/uid_map` to detect active user namespaces - Map container UIDs to host UIDs for diagnostics - Generate human-readable UID mapping summaries - Includes comprehensive unit tests for parsing and mapping logic - **Enhanced directory ownership checks** (`pkg/doctor/files_unix.go`): - Detect when user namespaces are active - Display mapped host UID in error messages when applicable - Add informational warnings about user namespace implications - Help users understand UID mismatches in containerized environments - **System diagnostics** (`pkg/doctor/system.go`, `pkg/doctor/userns_linux.go`, `pkg/doctor/userns_other.go`): - New `checkUserNamespace()` function to report namespace status - Platform-specific implementations (Linux vs. other OS) - Integrated into system health checks - **Storage validation improvements** (`pkg/files/filehandling.go`, `pkg/files/diagnostics_unix.go`, `pkg/files/diagnostics_windows.go`): - New `storageDiagnosticInfo()` function that gathers: - Process UID/GID - Directory owner UID/GID - User namespace status and mappings - Mapped host UID when applicable - Append diagnostic info to storage validation error messages - Platform-specific implementations with helpful hints for rootless containers ## Implementation Details - Uses build tags (`//go:build linux`, `//go:build !linux`) for platform-specific code - Lazy-loads and caches UID map parsing with `sync.Once` for efficiency - Detects "trivial" mappings (identity mapping) to distinguish between normal and containerized environments - Provides actionable hints in error messages (e.g., suggesting `--user 0:0` flag) - All new code includes proper AGPL license headers https://claude.ai/code/session_01YS8TxFvNwduFQuL1jkNt29 Docs PR: https://github.com/go-vikunja/website/pull/289 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-23 09:13:59 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#9821