Skip to content

Footer: show host system info via a new Rust API /api/v1/header endpoint #145

Description

@2ndtlmining

Summary

Add a GET /api/v1/header endpoint to the Rust API that reports the host the FluxNode
instance is running on, and render it on the right-hand side of the site footer — mirroring
the system-info line in the Fluxtracker header.

This was scoped out of the footer rework (v1.1.1) because the client is a static bundle and
has no way to learn anything about the machine serving it. Everything else in that rework
shipped; this is the remaining piece.

Motivation

Fluxtracker's header carries a line like:

Hosted in Melbourne, Australia | Running on linux | cpus 8 | mem 12.4/32.0 GB (39%)

It is genuinely useful — it makes it obvious the site is itself running on Flux, and which
node is serving you. FluxNode currently cannot show this: the browser has no access to the
serving node's identity or specs, and the site is served by nginx from a static build.

Three options were considered:

Option Verdict
Flux network-wide totals from gstore Free, but it is network capacity, not this host — different meaning
Viewer's own device via navigator.* Describes the visitor, not the site; deviceMemory is Chrome-only
Rust API endpoint Correct data, needs the API deployed ← this issue

Proposed endpoint

GET /api/v1/header

{
  "host": {
    "platform": "linux",              // std::env::consts::OS
    "arch": "x86_64",                 // std::env::consts::ARCH
    "cpuCores": 8,
    "totalMemMB": 32768,
    "usedMemMB": 12698,
    "memPercent": 39,
    "uptimeSeconds": 864321,
    "location": {                     // null when lookup fails — treat as optional
      "city": "Helsinki",
      "country": "Finland",
      "countryCode": "FI"
    }
  },
  "app": {
    "version": "1.1.1",               // env!("CARGO_PKG_VERSION")
    "fluxOsVersion": "5.2.1",         // optional, if resolvable
    "arcaneCodename": "..."           // optional
  },
  "generatedAt": 1756180000000
}

Implementation notes

  • Crate: add sysinfo for cores / memory / uptime.
    It is cross-platform and needs no privileged access.
  • Router: register in api_v1::make_router() in api/src/main.rs, alongside the existing
    /nodes, /node-single/:addr, /demo and /bench-version routes.
  • Location: resolve the container's public IP once at startup and geolocate it, then
    cache for the process lifetime — do not look it up per request. Fall back to null and
    let the UI omit the segment. Flux apps relocate between nodes, so it must be re-resolved
    on boot rather than baked into the image.
  • Caching: memoise the whole payload for ~30s. The footer polls, and sysinfo refreshes
    are not free.
  • CORS: the existing mirror_request() handling already covers this.
  • Cost: the response must stay small — this is on every page load.

Client work

  • Render as a right-aligned block in client/src/components/Footer/index.jsx, matching the
    existing footer theme (not Fluxtracker's terminal green).
  • Poll on the same cadence as the rest of the dashboard (30s), and degrade silently: if
    the endpoint 404s or the API is not deployed, render nothing. Production currently runs
    with REACT_APP_FLUXNODE_INFO_API_MODE=debug and talks to the official APIs directly, so
    the endpoint being absent is the normal case until this is deployed.
  • Hide the whole block under ~768px, as Fluxtracker does with its .host-line.

Acceptance criteria

  • GET /api/v1/header returns the shape above, in under 50 ms warm
  • Endpoint works with the API absent — client renders no footer block, logs no error
  • Memory / CPU figures are the container's, not the host node's, when cgroup-limited
  • Footer block is hidden on mobile and does not shift layout when it loads
  • Location degrades to null without breaking the response

References

  • Fluxtracker header: src/lib/components/Header.svelte — see .host-line and its @media (max-width: 768px) rule
  • Fluxtracker API shape: GET /api/headerdata.host.{platform,location,cpuCores,totalMemMB,usedMemMB,memPercent}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions