Best Effort Handling of NO_PROXY #235
Closed
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.
Issue: rancher/rancher#50041
Passing a
NO_PROXYvalue which includes spaces has the potential to break the upgrade script. This is due torun.shiterating across previously set environment variables using white space as a delimiter, instead of new lines, and due to howinstall.shparses the setNO_PROXYenvironment variable when crafting curl requests.From what I can determine, including whitespace in
NO_PROXYis a misconfiguration of the variable. Unfortunately, documentation doesn't explicitly state the expected format ofNO_PROXY. However, all examples ofNO_PROXYin Rancher strictly follow the expected Go format (comma-delimited entries). I have an associated docs PR up to clarify the expected value.At the moment, In the event that
NO_PROXYis not already exported, and needs to be reapplied using the value inrancher-system-agent.env, only the contents before the first whitespace character will be properly set toNO_PROXY. The remainder of the values will be exported individually, with no effect, polluting the SUC job logs.This change updates
run.shto add best effort handling of this case, and to print a useful warning message when a malformed value is provided. It also updates the loop to break on newlines, and not whitespace.Testing
After making these changes I built a new system-agent SUC image and tested it against a local custom cluster. I was able to confirm that no change in behavior occurs when properly setting
NO_PROXY, and that an upgrade to a system-agent with this change does not result in a restart of rke2.When
NO_PROXYincluded one or more spaces, I confirmed that the expected warning message was printed to the job logs and that the errant spaces were removed before exportingNO_PROXYand invokinginstall.sh.