Skip to content

[Feature] Support non-root Doris images, PVC upgrades and an optional privileged helper - #560

Open
Al-assad wants to merge 13 commits into
apache:masterfrom
Al-assad:fix/nonroot-privileged-helper
Open

Al-assad wants to merge 13 commits into
apache:masterfrom
Al-assad:fix/nonroot-privileged-helper

Conversation

@Al-assad

@Al-assad Al-assad commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

What problem does this PR solve?

Switching an existing root Doris image to a non-root image can leave the new process unable to read or write its existing PVC. Workload-group CPU control also currently relies on making the BE container itself privileged.

This PR supports image-defined runtime identities, staged Operator adoption, and PVC permission migration. It also adds optional CPU cgroup delegation for non-root workloads.

Related PRs: #568 (node initialization and Preflight baseline), apache/doris#70821 (non-root runtime images).

Implementation

  • Resolve UID and GID from explicit container and Pod security settings or from the image. When an existing StatefulSet keeps its image, identity, and runtime policy, reuse its runtime settings and avoid creating an image probe or an ownership-repair init.
  • Evaluate systemInitMode after resolving the component identity. Non-root workloads default to NodePrepared with BE startup checks enabled. The cluster-level spec.enablePrivilegedHelper defaults to false and controls CPU delegation independently. Root workloads retain their existing enableWorkloadGroup behavior.
  • Use volumePermissionMigration to select Auto or VerifyOnly. Automatic root-to-non-root repair is scoped to verified dedicated writable PVCs. VerifyOnly checks storage as the target user after external preparation and supports an explicit, verified reverse direction. Shared and external PVCs receive verification only.
  • Record migration progress by PVC UID, ordinal, and Pod revision. Verify retained or replaced claims, skip completed repairs, and allow cancellation when evidence shows that the old volumes have not changed.
  • Validate restartable init sidecar support and admission for the CPU helper. Keep the Doris process in its original memory domain, preserve the container limit files, and derive the default num_cores from affinity and the applicable CPU quotas. Keep explicit positive values.
  • Render Preflight from the final StatefulSet template, including init containers, runtime identity, migration progress, and helper admission. Include the matching CRDs, RBAC, Helm values, and standalone CLI packages.

Release note

Support staged migration to non-root Doris images. Upgrade the Operator, CRDs, and RBAC first, then switch images during a planned migration window. The Operator can repair eligible dedicated PVCs or verify externally prepared storage. The optional CPU helper requires restartable init sidecars, Linux cgroup v2, a supported systemd/containerd layout, and namespace admission that allows its privileges.

Validation at the current head

  • Full go test ./... passed on 51e7638 with Go 1.23.6 and Kubernetes 1.26.1 envtest assets. Local coverage includes migration cancellation and rollback, helper startup and restart logic, and final Preflight templates.
  • Verified the generated CRDs, raw and Helm ServiceAccount permissions through an isolated Kubernetes API, three Helm archives, and four standalone CLI archives. Verified interactive JSON, strict verification, timeout cleanup, and SIGINT cleanup.
  • Post-merge release qualification will exercise the final candidate against real 4.1.5 workloads, existing PVCs, and the supported helper environments. The earlier K3s runs below record results for the revisions tested at the time.

Check List (For Author)

  • Test
    • Regression test
    • Unit Test
    • Manual test (details below)
  • Behavior changed: Yes. See the release note and migration modes.
  • Does this need documentation? Yes. See docs/non-root-runtime.md and doc/non-root-k8s-preflight.md.

Earlier validation

  • Full go test ./... passed with Kubernetes 1.31.0 envtest assets; generated CRDs/deepcopy and git diff --check verified.
  • The migration-annotation regression fails with the previous annotation-clearing approach and passes with the explicit empty value.
  • End-to-end validation on a Linux amd64, single-node K3s 1.34.13 / containerd 2.2 / cgroup v2 / systemd environment:
Scenario Steps and observed result
Root to root Upgrade official 4.0.4 to 4.1.4; UID remains 0, no ownership repair, persisted data and subsequent writes succeed.
Root to non-root Create root-owned 0600 sentinel files and SQL data; update to UID/GID 10001 with helper disabled. Automatic repair succeeds, PVC UIDs are unchanged, files and SQL data remain accessible.
Fresh non-root Create a normal CR with the switch omitted. No privileged or root repair container; reads/writes succeed.
Non-root to non-root Upgrade images with the same UID/GID; no repeated repair init, PVCs and data retained. Also upgrade from a 4.1.4 engine to FE/BE built from PR #70821 head bb46752e8df051f7cfa7e6ba45166dd4945e322f.
Legacy Operator adoption Create a root cluster using Operator 26.0.1 without runtime-identity annotations, then upgrade Operator and images. Identity discovery, permission migration and data verification pass with helper disabled.
Helper enabled Non-root BE has zero effective capabilities and cannot write container cpu.max/memory.max. Actual concurrent queries with 20%/60% WG CPU quotas consume approximately 0.395/1.185 cores under a 2-core parent quota.
Memory accounting Compare the same unmodified current-source BE image at 8 GiB / 2 CPUs. The previous threaded layout reports host RAM (~62.63 GiB); the new layout reports 8 GiB with a 70% budget of 6,012,954,214 bytes. Also verified a 4.1.4 engine at 4 GiB.
Restarts and disabling Restart helper and BE independently; handshake, queries and memory accounting recover in the same Pod. Disable the switch: no privileged containers, host cgroup mounts or shared PID namespace remain; retained rows and new writes pass.

Current-source FE/BE were built from the related PR without additional BE changes (ASAN build). Full cluster deployment tests cover DCR FE/BE; DDC/CN/Broker integration is covered by code and unit tests.

Root compatibility retest at de7349e (Linux amd64, single-node K3s, cgroup v2):

  • Repeated the four installation/upgrade scenarios and adoption from Operator 26.0.1. The official 4.0.4 → 4.1.4 root upgrade retained SQL data and accepted new writes. Root BE retained the default initializer and the existing explicit WG privilege setting. The legacy engine logged the same missing cgroup v2 WG file on this node with both Operator versions.
  • The root → non-root migration retained both PVC UIDs and the contents of root-owned mode-0600 sentinel files. UID 10001 could append after migration. The next same-identity image upgrade cleared both migration annotations and omitted the repair initializer.
  • The PR #70821 engine identified 8 GiB and a 70% budget of 6,012,954,214 bytes. Concurrent SQL under a 2-CPU limit used 0.395 and 1.189 cores for the 20% and 60% workload groups. After restarting the helper and BE separately in the same Pod, measured use was 0.395 and 1.192 cores. The 4.1.4 engine also passed at 4 GiB.
  • Disabling the helper removed the privileged containers, host cgroup mounts and shared PID namespace. Retained rows and new writes passed.

Check List (For Reviewerwho merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

Al-assad and others added 5 commits November 23, 2026 12:41
Resolve the effective image UID/GID before reconciling Doris workloads and
preserve root images. Migrate dedicated root-owned PVCs with a limited,
non-privileged root initializer before switching to non-root. Keep migration
state across retries and explicitly clear it through StatefulSet metadata
merges on a subsequent same-user image upgrade.

Add enablePrivilegedHelper, default false, to DCR and DDC. Delegate a BE-owned
threaded CPU cgroup through a privileged native sidecar without elevating the
Doris container or changing parent limits. Include process-generation checks,
restart handling, volume checks, CRD/RBAC updates, and operator documentation.

Validation: Go tests including envtest pass. On k3s, fresh non-root, root-to-root,
legacy Operator root-to-non-root adoption, and non-root image updates preserve
data. Real WG loads enforce 20/60 percent CPU quotas; helper and BE restarts and
helper removal pass. Threaded cgroups expose an existing Doris memory-detection
bug; enabling the helper requires the companion Doris fix.
Delegate the container domain through the Doris query path so existing BE images retain memory accounting while WG worker threads use CPU cgroups. Derive the default core count from container quota and affinity, preserve root system initialization behind the helper switch, and handle nodes with no active swap.

Validated with full Go tests and hs runs of unmodified PR 70821 FE/BE: memory limits, real WG CPU quotas, helper/main restarts, and non-root identity. Document storage migration and node prerequisites.
Share the system init policy between BE, CN, Compute and Preflight. Keep legacy startup behavior and allow supported identities to use prepared nodes without skipping startup checks.

Align the soft nofile check with the Doris 4.1.5 startup script and verify that selecting prepared nodes removes the old default init from the StatefulSet.
Integrate PR apache#568 with apache#560 while preserving legacy StatefulSet adoption and root workload groups. Resolve source and target identities independently and retain the verified migration image across retries.
@morningman

Copy link
Copy Markdown
Contributor

I pushed 6089eda to this branch with the node-initialization changes from #568 (b8b7710). Here is what changed in #560:

  • Node initialization and Workload Group. BE, CN, and Compute apply systemInitMode after resolving the main container's UID, including UIDs supplied by the image. Non-root workloads default to NodePrepared and keep BE startup checks enabled. The CPU helper operates independently of node initialization. Root workloads keep the legacy enableWorkloadGroup behavior, and non-root workloads that still set that legacy flag get a configuration error.
  • Operator-only upgrades. When an existing StatefulSet keeps its image, runtime identity, and startup settings, reconciliation reuses its runtime settings without creating an image probe or adding a PVC permission init. This covers old images that can no longer be pulled and preserves the existing default-init and root Workload Group behavior.
  • Image changes and migration retries. Container UID/GID overrides take precedence over Pod overrides, and image probes fill in missing values using the workload's image pull secrets. The controller resolves the previous identity separately, using the running Pods' image digest when it needs to probe the old image. When a root-to-non-root migration needs to probe the target image, the rollout and retries use the verified target digest. FE upgrade gating still waits for the backend Pods to reach that digest and StatefulSet revision.

go test -count=1 ./... passed with Go 1.23.6 and envtest 1.26.1. The Operator and dorisctl built successfully, CRD regeneration produced no diff, and all three Helm charts passed lint and rendering. A live Kubernetes rollout, including mixed-architecture scheduling, is still pending.

morningman added 7 commits December 4, 2026 20:28
Limit ownership repair to verified dedicated PVCs, persist per-ordinal progress, and support externally prepared migrations and rollback with VerifyOnly.
Check restartable init admission before rollout, preserve the container memory domain, and derive default core counts from affinity and inherited CPU quotas. Keep legacy root workloads on their existing startup path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants