Skip to content

fix: Skip proxy vars in SUC env resurrection so deletion propagates - #393

Open
pratikjagrut wants to merge 1 commit into
rancher:mainfrom
pratikjagrut:SURE-6828
Open

pratikjagrut wants to merge 1 commit into
rancher:mainfrom
pratikjagrut:SURE-6828

Conversation

@pratikjagrut

Copy link
Copy Markdown
Contributor

Problem

Deleting an agent env var (HTTP_PROXY/HTTPS_PROXY/NO_PROXY) on a downstream cluster doesn't propagate — the old value persists in /etc/systemd/system/rancher-system-agent.env.

Fixes SURE-6828 / rancher/rancher#45210

Cause

package/suc/run.sh re-exports vars from the existing env file before running install.sh. On delete, the plan correctly omits the var, but the loop resurrects the stale value from the old file and create_env_file writes it back.

Fix

Skip proxy vars in the loop so the SUC plan env is the source of truth (present → written, absent → cleared). PATH and
other vars still preserved. Also fix ${line##*=}${line#*=} for values containing =.

Testing

Set → update → delete NO_PROXY on a downstream cluster with the patched -suc image: value now clears on delete. No regression for set/update/no-proxy cases.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes SUC (system-upgrade-controller) “env resurrection” behavior so deleting proxy-related env vars on downstream clusters actually clears them from /etc/systemd/system/rancher-system-agent.env.

Changes:

  • Preserve = characters in parsed env-file values by switching ${line##*=} to ${line#*=}.
  • Prevent stale proxy values from being re-exported by skipping HTTP_PROXY/HTTPS_PROXY/NO_PROXY (and lowercase variants) when rehydrating env from the existing systemd env file.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package/suc/run.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread package/suc/run.sh Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Comment thread package/suc/run.sh Outdated
@@ -45,14 +45,26 @@ export CATTLE_AGENT_UNINSTALL_LOCAL=true
export CATTLE_AGENT_BINARY_LOCAL_LOCATION=${TMPDIR}/rancher-system-agent
export CATTLE_AGENT_UNINSTALL_LOCAL_LOCATION=${TMPDIR}/rancher-system-agent-uninstall.sh
if [ -s /host/etc/systemd/system/rancher-system-agent.env ]; then

@pedromfcarvalho pedromfcarvalho Aug 27, 2026

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.

It will be simpler to remove this whole if block entirely.

The only variables that install.sh writes to the env file are the proxy variables anyways, and potentially the adjusted PATH like you mentioned, but this is unlikely to be ever empty here so it won't be exported, and it will be re-adjusted by install.sh anyways.

@pedromfcarvalho
pedromfcarvalho requested a review from a team September 1, 2026 21:34
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.

3 participants