Skip to content

deploy: chown release to root so files are not owned by the runner uid 1001 - #238

Open
chaoming0625 wants to merge 1 commit into
mainfrom
fix/deploy-file-owner
Open

chaoming0625 wants to merge 1 commit into
mainfrom
fix/deploy-file-owner

Conversation

@chaoming0625

@chaoming0625 chaoming0625 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Deploys leave files on the VPS owned by uid/gid 1001 (the GitHub runner's user). Finding from the remote.chaobrain.com hub, record 393 (prod uid 1001 / needrestart orphans).

Cause: appleboy/scp-action packs the files into a tarball on the runner and unpacks it on the server with plain tar -zxf. These deploys log in as root, and GNU tar running as root keeps the owner stored in the archive (--same-owner is the default for root). So every file in the release ends up owned by 1001:1001. The admin deploy also runs its own tar -xzf as root, with the same result.

On the VPS, uid 1001 no longer maps to any account since the cbl-release account was removed. gid 1001 is hubclient, a legacy hub group. Files owned by them are orphans, and they show up in the hub's audits.

Fix: make the files owned by the user that deploys (root).

  • scp-action uploads: chown -R root:root "$release" in the activate step, before the symlink swap. scp-action has no option to pass --no-same-owner to the remote tar, because its tar_exec input is also used as the local binary name.
  • the admin's own untar (chaobrain.com only): tar --no-same-owner -xzf.

Nothing else changes. Merging triggers a production deploy, so a human should merge this.

Summary by Sourcery

Ensure deployed documentation files are root-owned to prevent orphaned runner ownership on the VPS.

Bug Fixes:

  • Ensure deployed documentation releases are owned by root instead of retaining the GitHub runner's orphaned uid/gid 1001 ownership.

Deployment:

  • Normalize release ownership during deployment before switching the active release.

@sourcery-ai

sourcery-ai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The deployment workflow now normalizes ownership of scp-action releases to root:root before activation, preventing runner UID/GID 1001 from leaving orphaned files on the VPS.

Sequence diagram for root-owned release activation

sequenceDiagram
    participant Runner as GitHub Runner
    participant VPS as VPS
    participant Release as Release Directory

    Runner->>VPS: scp-action uploads and untars release
    VPS->>Release: chown -R root:root release
    VPS->>VPS: ln -sfn release current.next
    VPS->>VPS: mv -Tf current.next current
Loading

File-Level Changes

Change Details Files
Ensure uploaded release files are owned by root before activation.
  • Recursively chown the extracted release directory to root:root after validating the entrypoint file.
  • Perform the ownership correction before swapping the active-release symlink.
.github/workflows/deploy-docs.yml

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

1 participant