fix(install): recover Portainer Edge env vars stripped by sudo env_reset [KS-65]#161
Merged
Conversation
…set [KS-65] Some systems configure sudo with env_reset, which causes the -E flag to be silently ignored. This strips KUBESOLO_PORTAINER_* vars set before the sudo invocation, leaving the installer without edge credentials. Fix: after argument parsing, if we are running under sudo (SUDO_USER set) and PORTAINER_EDGE_KEY is empty, read the vars back from /proc/$PPID/environ — the sudo process's own environment still holds them even though it did not pass them through to the script. The guard on /proc/$PPID/environ being readable makes this a no-op on systems without procfs. Also fix PORTAINER_EDGE_ASYNC never being added to CMD_ARGS: the flag has been parsed since the first commit but was silently dropped before being passed to the kubesolo binary, causing async mode to never take effect when set via env var or --portainer-edge-async. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…[KS-65]
- Replace narrow 3-var recovery block with a generic loop that recovers
all KUBESOLO_* vars from /proc/$PPID/environ, covering all flags.go
Envar() declarations automatically
- Move recovery block before var-init so recovered vars are picked up
naturally by the existing ${KUBESOLO_X:-default} assignments
- Wire missing flags into var-init and CMD_ARGS: LOAD_BALANCER,
LOCAL_STORAGE_SHARED_PATH, FULL, DB_WAL_REPAIR, DISABLE_IPV6,
STARTUP_TIMEOUT
- Fix LOCAL_STORAGE default mismatch (false → true, aligning with
flags.go and expected behaviour)
- Flip LOCAL_STORAGE and LOAD_BALANCER CMD_ARGS guards to fire on false
(disable-only pattern, since binary defaults both to true)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
stevensbkang
approved these changes
Jun 17, 2026
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.
Ref: KS-65