Skip to content

Record the node a container is running on, not the container id - #322

Open
adrpo wants to merge 1 commit into
OpenModelica:masterfrom
adrpo:record-node-not-container
Open

Record the node a container is running on, not the container id#322
adrpo wants to merge 1 commit into
OpenModelica:masterfrom
adrpo:record-node-not-container

Conversation

@adrpo

@adrpo adrpo commented Aug 21, 2026

Copy link
Copy Markdown
Member

Follow-up to #320, which is merged.

#320 records socket.gethostname() as the machine that produced a library's results. That
is the machine right up until the run is inside a container, where it is the container id.
The database already shows the problem:

     host      | claims |            newest
---------------+--------+-------------------------------
 ryzen-9950x   |    724 | 2026-08-21 05:16:09+00
 ryzen-5950x-2 |    220 | 2026-08-21 11:38:04+00
 e9725d308091  |     96 | 2026-08-21 11:53:48+00     <- wasm-jit, in a container
 ryzen-5950x-1 |     28 | 2026-08-21 11:17:19+00

e9725d308091 identifies no machine, and is gone with the container. Since #295 wants
every job running from a Docker image, that would become the answer everywhere and leave
the new libversion.host column as useless as having no column at all.

Jenkins knows the machine — it names its agents — and propagates NODE_NAME into a
container it starts, which is something socket.gethostname() inside that container
cannot see. So:

def hostname():
  explicit = os.environ.get("LIBTEST_HOST")
  if explicit:
    return explicit
  # Docker leaves /.dockerenv behind, podman /run/.containerenv.
  if os.path.exists("/.dockerenv") or os.path.exists("/run/.containerenv"):
    return os.environ.get("NODE_NAME") or socket.gethostname()
  return socket.gethostname()

NODE_NAME is consulted only inside a container. Outside one the kernel's answer is
the right one and a NODE_NAME left over in the environment must not override it — which
is also what makes this a no-op for the machines running the testing today. LIBTEST_HOST
overrides both, for the same reason LIBTEST_DB exists, and is the escape hatch if some
job turns out not to have NODE_NAME.

It lives in resultsdb as one helper used by both callers, so the host in job_claim and
the host stored with the results cannot disagree about which machine this is. That also
fixes the wasm-jit claims above, not just the new columns.

Checked all four paths — plain host; NODE_NAME set but no container (unchanged, the real
hostname wins); LIBTEST_HOST set; and inside a container with and without NODE_NAME.
The container paths were exercised by faking the marker file rather than in a real
container, since Docker was not available where this was written; worth a real check on a
node before #295 leans on it.

Part of #301, and needed before #295's Docker task means anything for attribution.


generated by Claude Code

OpenModelica#320 stores socket.gethostname() as the machine that produced a library's
results. That is right until the run is inside a container, where it is the
container id: job_claim currently says the wasm-jit libraries were tested by
"e9725d308091", which identifies no machine and is gone with the container.
OpenModelica#295 wants every job in a Docker image, which would make that the answer
everywhere and leave the new libversion.host column as useless as no column.

Ask Jenkins instead. It names its agents and propagates NODE_NAME into a
container it starts, so that is the machine name when there is a container in
the way. LIBTEST_HOST overrides it, for the same reason LIBTEST_DB exists.

NODE_NAME is only consulted inside a container - detected by /.dockerenv, or
/run/.containerenv under podman. Outside one the kernel's answer is the right
one and a NODE_NAME left in the environment must not override it, which is also
what keeps this a no-op for the machines running the testing today.

One helper in resultsdb, so the claim in job_claim and the host recorded with
the results cannot disagree about which machine this is.

Checked all four paths: plain host, NODE_NAME set but no container (unchanged,
the real hostname wins), LIBTEST_HOST set, and inside a container with and
without NODE_NAME. The container paths were exercised by faking the marker file
rather than in a real container - Docker is not available where this was
written.

Follow-up to OpenModelica#320, part of OpenModelica#301, and needed before OpenModelica#295.
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.

1 participant