Repository navigation
[Sprint] sprint-loop-4 - #6
Merged
Merged
Conversation
…820) ks and kss assigned local container=$1 (the pod) instead of $2, so 'ks pod container' executed 'kubectl exec -it pod -c pod -- bash'. The dispatch array was also unscoped and named 'command', shadowing the shell builtin. Use local -a cmd and read the container from $2. Also remove the duplicate 'alias kl=' line; the second definition silently shadowed the first.
…_btp_branch tail (SUR-1837) - get_latest_btp_branch piped to bare 'tail' (default -n 10) so it checked out 10 branches sequentially; restrict to tail -n 1. - update_helm replaced 'curl ... | bash' against helm/master with a pinned tarball download (currently v3.16.4) to /tmp + extract + install. Bump the version manually after release-note review. - update_eksctl previously hardcoded amd64 in the URL; derive arch from uname -m and reject unknown values explicitly so arm64 hosts no longer install a broken binary.
…SUR-1832)
start() echoed @startuml "$ns", but $ns is never in scope here -
it's a loop variable in callers. The intent (matching the cluster()
function that calls it) is @startuml "$cluster". Use ${1:?} to
fail fast on a missing arg.
Replace bare 'kubectl describe' / 'kubectl get ns' calls with
k8s::ctl so logging and SIMULATE work consistently with the rest of
the file.
Inside namespace() the loop variable 'item' shadowed the item()
function, so each iteration tried to invoke the loop string instead
of the formatter. Rename to 'entry'.
…p trap (SUR-1825) - The first call site invoked 'openssl::cmd', a function that is never defined; the only openssl wrapper in the file is '::openssl'. Use the existing wrapper so cert fetch actually runs. - CERT_GROUP was guarded by '[ -z "$DOMAIN" ]', which assigned the empty DOMAIN whenever the FQDN was bare. Flip to '[ -n "$DOMAIN" ]' so the local default is preserved when no domain is parsed. - Replace deprecated uppercase INFO calls in add-certs-ubuntu with log::info to match the rest of the script. - Install a trap to remove the mktemp -d directory on EXIT/INT/TERM so failed runs don't leak working dirs.
…mes (SUR-1829)
The -c option was declared mandatory yet the body had a fully-formed
'else' branch for the empty case, which produced 'pod-abc..out'
filenames (and a misleading log line) and broke downstream globbing.
Drop the -m on -c so the empty case is reachable, and use a
suffix=${container:-all} fallback so output filenames are
'$pod.$suffix.out' with no double dots.
The -n NAMESPACE flag mentioned in the issue is deferred to a
follow-up; this change keeps the diff narrow.
…823)
The -P option help text contained a botched sed substitution
('fo::add_ingress_providerr'); restore the intended description.
::use_dind defined DOCKER_PORT from $DIND_PORT but the
::is_dind_running branch hardcoded tcp://localhost:2375 and the else
branch unconditionally re-exported DOCKER_PORT=2375, silently
overriding the user's -P. Use $DOCKER_PORT in both branches and
quote the -p mapping.
Replace 'sleep 30' with a bounded poll (DIND_READY_TIMEOUT, default
60s) on 'docker -H tcp://localhost:$DOCKER_PORT info' so startup
is gated on actual readiness instead of a fixed wait.
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.
Sprint Plan — 2026-04-28 (loop 4)
Sprint goal
Land a focused, low-risk bug-fix sprint that hardens six
bash/command scripts against well-understood, narrowly-scoped defects: undefined-variable references, inverted conditionals, mis-assigned function arguments, garbled help text, hardcoded ports, and a small supply-chain hygiene fix. Each issue is small enough to ship as an independent commit on the sprint branch, all changes pass shellcheck/shfmt cleanly, and none introduce new abstractions or library APIs. The sprint deliberately avoids the larger structural cleanups (test infrastructure, namespace audits, Jenkins → GHA) so we can keep cycle time short and merge confidence high.Selected issues
1. SUR-1820 — Bug: aliases — duplicate
klalias andks/kssassigncontainer=$1(pod) by mistakeklalias and ks/kss assign container=$1 (pod) by mistakebash/aliasesdefinesalias kl=...twice (lines 7 and 15), the second silently shadowing the first. Worse,ks/ksscapturepod=$1, then in the[ -n "$2" ]branch setlocal container=$1beforeshift, socontainerends up equal to the pod.ks mypod mycontaineralways runskubectl exec -it mypod -c mypod -- bash, which fails. Thecommand=(...)array is also not declaredlocal, leaking into the caller's environment.ks <pod> <container>is part of the day-to-day interactive workflow; the multi-container form is unusable today. The fix is mechanical (use$2, declarelocal -a cmd) and well-scoped to a few lines.alias kl=line is removed (or converted to a distinct alias such asklfif a clear intent is recovered from git blame).ksandksscorrectly use$2for the container argument.local -ainside both functions.pre-commit run --all-filespasses (shellcheck, shfmt, etc.).bash/aliasesand runningtype ks/type kssshows the corrected body.bash/aliases; sequencing them avoids unnecessary merge resolution.2. SUR-1837 — Bug: aliases —
get_latest_btp_branchusestail(last 10) instead oftail -n 1;curl|bashfor helm; eksctl hardcoded amd64tail(last 10) instead oftail -n 1; curl|bash for helmbash/aliases: (1)get_latest_btp_branchpipes to baretail, which defaults to-n 10, so the loop checks out 10 branches sequentially and lands on a non-deterministic one; (2)update_helmdoescurl … | bashagainstmasterwith no checksum — supply-chain risk; (3)update_eksctlhardcodes_amd64in the download URL, producing broken installs on Apple Silicon / arm64.get_latest_btp_branchusestail -n 1(or, equivalently,head -n 1of a reverse sort) and is documented with a one-line comment explaining the intent.update_helmpins a tagged helm version and downloads the official tarball (or, at minimum, drops| bashin favor ofcurl -fsSL -o /tmp/helm.tgz+tar xzflow). Document the chosen version in a comment so future bumps are obvious.update_eksctlderives the architecture fromuname -m(mappingx86_64→amd64,aarch64|arm64→arm64, with a clear error for unknown values).bash/aliases.3. SUR-1832 — Bug: plantuml-from-k8s
start()references undefined$ns; uses raw kubectl instead ofk8s::start()references undefined $ns; uses raw kubectl instead of k8s::start()inbash/plantuml-from-k8sechoes@startuml "$ns", but$nsis never in scope insidestart()— it is a loop variable in callers. The intent (per the rest of the file) is@startuml "$cluster". The same script also calls barekubectlon lines 91 and 115 instead ofk8s::ctl, bypassing the lib's logging/SIMULATEsupport, and shadows theitemfunction with a loop variable of the same name.start()echoes@startuml "$cluster"and useslocal cluster=${1:?}to fail fast on a missing arg.kubectlcalls in the file are replaced withk8s::ctl.namespace()is renamed (e.g.for entry in …) so it no longer shadows theitemfunction; alternativelyitem()addslocal itemat its top.pre-commit run --all-filespasses.bash/plantuml-from-k8s some-cluster(withSIMULATE=true) prints@startuml some-clusteras the first non-blank line.4. SUR-1825 — Bug: trust-server references undefined
openssl::cmd; CERT_GROUP logic invertedbash/trust-serverdefines::opensslbut then invokesopenssl::cmd(never defined), so the script aborts on first cert fetch.CERT_GROUPis initialized to"local", then overwritten to the empty$DOMAINunder an inverted[ -z "$DOMAIN" ]test. The Ubuntu branch also calls deprecated uppercaseINFO, andmktemp -dis leaked with no cleanup trap.openssl::cmd→::openssl) plus a one-character condition flip (-z→-n), so review burden is minimal.openssl::cmdinvocation is replaced with::openssl(or, alternatively,::opensslis renamed toopenssl::cmdto match the namespacing convention from AGENTS.md — pick whichever is consistent with neighbours).CERT_GROUPlogic uses[ -n "$DOMAIN" ]and only assigns$DOMAINwhen non-empty.INFOcalls withlog::info.trap 'rm -rf "$TMPDIR"' EXIT INT TERMis added aftermktemp -d.bash/trust-server -hshows help;bash -n bash/trust-serverparses cleanly; shellcheck passes.5. SUR-1829 — Bug: fetch-all-pod-logs writes
$pod..outwhen -c is empty; -c is mandatory yet handled as optionalbash/fetch-all-pod-logsdeclares-cmandatory (via-m) but still has anelsebranch for the empty case, which produces output filenames containing a literal..(e.g.pod-abc..out) and breaks downstream globbing. The script also lacks a-n NAMESPACEflag and only works in the kubectl current-context default namespace.-mor remove the dead branch. The issue description recommends the former (the--all-containersbranch suggests it was meant to be optional), so we'll treat-cas optional and use a sensible filename suffix.options::addfor-cdrops-mand the description is updated to "container whose logs to dump (defaults to all)".elsebranch uses asuffix=${container:-all}so output filenames are$pod.$suffix.out(no double-dots).-n NAMESPACEflag piped through tok8s::ctl. If skipped, called out explicitly in the commit body as deferred.bash/fetch-all-pod-logs -hshows correct help; running withSIMULATE=trueagainst a fake selector produces the expected log lines.6. SUR-1823 — Bug: kind-test-environment — garbled -P description and DOCKER_HOST hardcoded ignoring DIND_PORT
-Poption help text inbash/kind-test-environmentcontains a botched sed replacement (fo::add_ingress_providerr). More importantly,::use_dindinitially honors$DIND_PORTviaDOCKER_PORT=${DIND_PORT:-2375}but theif ::is_dind_runningbranch hardcodestcp://localhost:2375, and theelsebranch unconditionally re-exportsDOCKER_PORT=2375— silently overriding the user's-Pchoice. There is also asleep 30masking startup races.-Pflag are visibly broken. The fix uses$DOCKER_PORTconsistently and (optionally) replaces the sleep with a short readiness poll.-Pdescription reads "Use the specified port for the DinD daemon" (no garbled substring).::use_dindusetcp://localhost:$DOCKER_PORTand never re-assignDOCKER_PORT=2375.sleep 30is replaced by a bounded poll ondocker -H tcp://localhost:$DOCKER_PORT info, with a clear timeout (e.g. 60s) and an error exit on timeout. If poll-replacement is deferred, the commit body must say so explicitly.Risks + mitigations
bash/aliases). Concurrent or out-of-order commits cause merge churn.Mitigation: Sequence them on the same sprint branch (1820 first, then 1837). The implementation plan enforces ordering.
bash -n, shellcheck, shfmt, and manual smoke.Mitigation: Each Definition of Done lists explicit smoke commands. Where the bug is visible from
-houtput (SUR-1823 garbled help, SUR-1825 typo), invoke-hpost-fix to confirm. For SUR-1832, run withSIMULATE=trueso no real cluster is needed.sleep 30with a poll in SUR-1823 may regress on hosts where docker takes longer to come up.Mitigation: Make the poll bounded (default 60s timeout) and document the override env var. If unable to test against a real DinD on the developer's machine, leave the sleep in place and explicitly defer that bullet — call it out in the commit body and reopen as a follow-up.
update_helmandupdate_eksctlbehavior, which a user may have memorized.Mitigation: Preserve the public function names and observable behavior (
update_helm,update_eksctlstill install the named tool); only the internal install mechanism changes. Add a one-line comment explaining the version pin so future maintainers don't roll back tocurl | bash.bash/aliasesis sourced into interactive shells; a syntax error in the file breaks every new shell of users who source it.Mitigation: Run
bash -n bash/aliasesas part of the verification plan and confirm shellcheck has zero new findings before opening the PR.pre-commit'sno-commit-to-branchhook only allowsfeature/,fix/,refactor/branch names. The sprint branchsprint/2026-04-28-sprint-loop-4does not match.Mitigation: Create per-issue feature branches (
feature/sur-1820, etc.) for actual commits, and use the sprint name only as an umbrella tracking concept (not a real git branch). The IMPLEMENTATION_PLAN documents both the umbrella name and the per-issue feature-branch names that comply with the hook.k8s::ctl(SUR-1832) currently works; switching to it requires the file to@include k8s(it already does, per the issue). If the include guard is missed the script will fail at runtime.Mitigation: Verify
@include k8sis present at the top of the file before changing call sites; runbash -nafter the edit.trust-serverandkind-test-environmentinteract with real network/docker resources; verifying the fix end-to-end requires environment access we may not have.Mitigation: Use static checks (
bash -n, shellcheck) and-houtput for surface validation; document any deferred end-to-end verification as a follow-up note in the commit body.Out of scope
daml-exporthygiene refactor (SUR-1854) and PagerDuty improvements (SUR-1838, SUR-1821) — deferred.Linear Evidence
Surinis(idce9ebfde-ff2b-4f54-90f1-c388591ca110).shell-scripts(ida43901a0-b02b-4009-aae1-a6e8903d127d, urlhttps://linear.app/surinis/project/shell-scripts-957861610a69).mcp__linear__list_issueswithproject="shell-scripts",team="Surinis",state="Backlog",includeArchived=false,limit=100.manuallabel; observed labels wereBug,Improvement,documentation,testing,3 - medium).Sub-issue Status
All six selected issues were checked for child issues via
mcp__linear__list_issues parentId=<key>. None of them have any sub-issues, so the parent-vs-sub-issue dependency rule is automatically satisfied.No parents were skipped because of incomplete sub-issues.
Linear State Transitions