Repository navigation
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…tice out of command logs (#897) - --command: the #707 errexit notice no longer opens every /var/log/spawn-command.log. The root-side outcome block appends it only when the command exits non-zero (with the exit code), and the bootstrap notes it once in cloud-init-output.log. The command still runs under set -e. - Bootstrap sets the OS hostname from the Name tag (sanitized to an RFC 1123 label, index appended when an --instance-names template collides), maps it to the private IP in /etc/hosts, and sets preserve_hostname for cloud-init. Nothing set it before, for single instances or array/MPI members, despite --name's help. MPI hostfiles still use peer IPs. - Job-array/MPI summary prints one 'spawn connect <pattern>' hint instead of a raw ssh -i line per member. Fixes #897
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.
Three output problems from #897, each with its own root cause.
1. errexit preamble in every command log
Root cause: #707 (PR #721) added two
printflines at the top of the generated/tmp/spawn-command.sh. That warning exists because--commandruns underset -e,set -uo pipefaildoes not clear it, and a script killed by errexit dies before the line that would say why. Because the lines were at the top of the script, they landed in every/var/log/spawn-command.logon every member, including when the command succeeded.Fix (the safety intent stays): the command script no longer prints anything itself, and the command still runs under
set -e. The root-side outcome block (the subshell that recordsCMD_RC) now appends the notice to the command log only when the command exits non-zero. It goes after the command's output, names the exit code, and keeps the #707 wording ("errexit is ON", "set -uo pipefail does NOT clear it", "set +e") plus the two common causes (SIGPIPE 141 andwait $pid). Root writes it, so the su/tee hazard thatTestCommandAnnouncementDoesNotTeeguards against does not apply. A one-line note also goes to cloud-init-output.log at boot. That log is not the command log. spored.log was not an option because spored is not running yet at that point in the bootstrap.2. Hostname stays the EC2 default
Root cause: nothing in the repo ever set the hostname. There is no
hostnamectlor/etc/hostnameanywhere. So single instances were affected too, not only array and MPI members, even though--name's help says "sets Name tag, DNS, and hostname".Fix: the Linux bootstrap reads the
Nametag and sets the hostname. This happens after the job-array env is read and before--commandstarts.[a-z0-9-], at most 63 characters. A name that sanitizes to nothing leaves the default.--instance-namestemplate without{index}, which would otherwise give every member the same hostname, and Open MPI tells nodes apart by hostname.hostnamectl, falling back tohostname, and/etc/hostnameset the name./etc/cloud/cloud.cfg.d/99-spawn-hostname.cfgsetspreserve_hostname: true, so cloud-init does not reset the name on stop/start./etc/hostsmaps the name to the private IP, read from IMDS, so it resolves locally.|| true), because the bootstrap runs underset -e./tmp/mpi-hostfileis built from peer private IPs (pkg/userdata/mpi.go), not hostnames. mpirun already worked with hostnames (ip-172-...) that did not match the hostfile entries.3. One raw ssh line per member
Fix:
renderJobArrayResult, which plain arrays and--mpishare, now prints one line under Management:• Connect: spawn connect arr-<index> (e.g. spawn connect arr-0). The pattern comes from the same Name template thatformatInstanceNameuses, so it follows--instance-names.spawn connectresolves members by Name tag (resolveInstance, case-insensitive). If the template has no{index}, every member has the same name, so the hint falls back tospawn connect <instance-id>. The single-instance summary already printedspawn connect <name>, so the two summaries now match.Tests
Each new gate was run against a revert that compiles and failed:
TestSuccessfulCommandLogHasNoShellOptionPreambleruns the generated command script. A successful command's log must be exactly its own output. It fails if theprintfpreamble is restored.TestFailedCommandLogNamesErrexitruns the real outcome block with the log redirected. With rc=141 the log must carry the spawn launch --command runs under bash -e, invisibly: 'set -uo pipefail' does not clear it, and the script dies before it can report why #707 wording. With rc=0 the log must stay empty. It fails if the notice is dropped or moved outside the failure branch.TestCommandStillRunsUnderErrexitkeeps the spawn launch --command runs under bash -e, invisibly: 'set -uo pipefail' does not clear it, and the script dies before it can report why #707 measurement: errexit survivesset -uo pipefail.TestBootstrapSetsHostnameFromName/TestBootstrapHostnameIsAValidLabelrun the real hostname block underset -e, withaws,hostnamectlandcurlstubbed and/etcredirected. Cases: arr-3, sim-0, a single instance, an invalid label, an index-less template, an index already present, no Name tag, and a long name. They fail ifhostnamectlis removed or the distinct-hostname rule is disabled.TestBootstrapSetsHostnameBeforeCommandStartschecks ordering: the hostname is set afterJOB_ARRAY_INDEXis read and before--commandruns.TestJobArraySummaryPrintsOneConnectHint/TestJobArrayConnectHintFollowsTemplate. Both fail when the per-member ssh lines or the same-name hint come back.make checkpasses exceptpkg/taskprotoTestGenerateWrapper_ChownFixesCrossUIDStickyUnlink_Docker, which needs a Docker daemon. It fails the same way on unmodified main. Nested modules pass. No public-surface change:BuildLinuxBootstrap's signature is unchanged.Needs a real launch to confirm (no instances were launched):
hostnamectlon AL2023/Ubuntu,preserve_hostnameacross stop/start, andmpirun hostnameprinting member names.Fixes #897