-
Notifications
You must be signed in to change notification settings - Fork 7
fix: don't assume initial agent port 14100 #2799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3264,7 +3264,10 @@ async def configure_agent(agent_handle_drivers=False): | |||||||||||||||||||||||||
| {no_reserve_space_cmd} | ||||||||||||||||||||||||||
| sed -i 's/cgroups_mode=auto/cgroups_mode=none/g' /etc/wekaio/service.conf || true | ||||||||||||||||||||||||||
| sed -i 's/override_core_pattern=true/override_core_pattern=false/g' /etc/wekaio/service.conf || true | ||||||||||||||||||||||||||
| sed -i "s/port=14100/port={AGENT_PORT}/g" /etc/wekaio/service.conf || true | ||||||||||||||||||||||||||
| sed -i "/^\\[agent\\]/,/^\\[/ s/^port=.*/port={AGENT_PORT}/" /etc/wekaio/service.conf | ||||||||||||||||||||||||||
| # sed exits 0 on no-match, so assert the rewrite landed: an agent left on | ||||||||||||||||||||||||||
| # port=0 listens on no TCP port and the operator cannot read its identity. | ||||||||||||||||||||||||||
| sed -n "/^\\[agent\\]/,/^\\[/p" /etc/wekaio/service.conf | grep -qx "port={AGENT_PORT}" | ||||||||||||||||||||||||||
|
Comment on lines
+3267
to
+3270
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The section-scoped rewrite is the right fix, but the same function already solves this exact problem 30 lines up and the two blocks now disagree. grep -q "^\[mounts\]" /etc/wekaio/service.conf || printf '\n[mounts]\n' >> /etc/wekaio/service.conf
if grep -qE "^[[:space:]]*allocate_reserved_space[[:space:]]*=" /etc/wekaio/service.conf; then
sed -i -E "s/^[[:space:]]*allocate_reserved_space[[:space:]]*=.*/allocate_reserved_space=false/g" ...
else
sed -i "/^\[mounts\]/a allocate_reserved_space=false" ...
fi— create-section-if-missing, whitespace-tolerant match, insert-if-key-absent. The new Two concrete gaps: 1. The assertion is vacuous in exactly the case the comment names. If A Python-side guard catches the real failure mode, and if parse_port(AGENT_PORT) <= 0:
raise Exception(f"Refusing to configure agent with invalid AGENT_PORT={AGENT_PORT!r}")2. Make the shell match as tolerant as its neighbour. Suggested replacement for these four lines:
Suggested change
One thing I can't check from the repo: line 3272 writes the same port into |
||||||||||||||||||||||||||
| # sed -i "s/serve_static=false/serve_static=true/g" /etc/wekaio/service.conf || true | ||||||||||||||||||||||||||
| echo '{{"agent": {{"port": \'{AGENT_PORT}\'}}}}' > /etc/wekaio/service.json | ||||||||||||||||||||||||||
| """) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Scoping the rewrite to the
[agent]section is a real improvement over the old globals/port=14100/.../g(which could also clobberport=14100in other sections). Two issues with the assertion though.1. The assertion is vacuous in exactly the case the comment warns about.
The comment says an agent left on
port=0"listens on no TCP port and the operator cannot read its identity" — but ifAGENT_PORTis"0"the sed writesport=0andgrep -qx "port=0"passes happily.AGENT_PORTreachesconfigure_agent()as"0"whenever the pod env carriesGetAgentPort() == 0(pod.go:282) andwait_for_resources()(line 3941) returns early — it only resolves the port forclientmode or the['drive','s3','compute','nfs','smbw','envoy','client','telemetry','data-services']set, sodrivers-*,adhoc-op-with-container, etc. fall through with the env value untouched. Same forAGENT_PORT == "": sed writes a bareport=andgrep -qx "port="still matches.Asserting the value in Python before building the command would actually catch this:
2. The removal of
|| trueturns any format deviation into a container-start failure.run_commandprependsset -e(line 2337), so thegrep -qxfailure does propagate — good, the assertion is live. Buts/^port=.*/only matches a literalport=anchored at column 0. On any image where the[agent]section is missing, or writesport = 0/port=0, the sed no-ops, the grep fails, andconfigure_agent()raises → the pod never starts, where previously it degraded silently. That's arguably the point, but it's a hard fail across every supported weka image version, and the next line writes the port into/etc/wekaio/service.jsonanyway. Worth confirmingservice.jsondoesn't already take precedence overservice.conf— if it does, the strictservice.confassertion buys little and risks a lot. A tolerant^[[:space:]]*port[[:space:]]*=pattern would cover the formatting variants cheaply.