Repository navigation
deploy: chown release to root so files are not owned by the runner uid 1001 - #143
Open
chaoming0625 wants to merge 1 commit into
Open
chaoming0625 wants to merge 1 commit into
chaoming0625 wants to merge 1 commit into
Conversation
Contributor
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe deployment workflow now corrects ownership on each scp-action-uploaded release before the symlink swap, preventing runner uid/gid 1001 from leaving orphaned files on the VPS; the described admin untar change is not present in the provided diff. Sequence diagram for root-owning uploaded releasessequenceDiagram
participant Runner as GitHub Runner
participant SCP as scp-action
participant VPS as VPS
participant Deploy as Deploy Workflow
Runner->>SCP: Upload release archive
SCP->>VPS: tar -zxf release archive
VPS-->>VPS: Release files owned by uid/gid 1001
Deploy->>VPS: chown -R root:root release
Deploy->>VPS: ln -sfn release current.next
Deploy->>VPS: mv -Tf current.next current
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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-actionpacks the files into a tarball on the runner and unpacks it on the server with plaintar -zxf. These deploys log in as root, and GNU tar running as root keeps the owner stored in the archive (--same-owneris the default for root). So every file in the release ends up owned by 1001:1001. The admin deploy also runs its owntar -xzfas 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).
chown -R root:root "$release"in the activate step, before the symlink swap. scp-action has no option to pass--no-same-ownerto the remote tar, because itstar_execinput is also used as the local binary name.tar --no-same-owner -xzf.Nothing else changes. Merging triggers a production deploy, so a human should merge this.
Summary by Sourcery
Ensure documentation deployments leave release files owned by root to prevent orphaned runner ownership on the VPS.
Bug Fixes:
Deployment: