Skip to content

Legion 0.1.11

Choose a tag to compare

@grepjava grepjava released this 05 Nov 16:49
· 959 commits to main since this release

Fixes from several rounds of code review since 0.1.7, many of them for security. Upgrading is recommended. (0.1.8, 0.1.9 and 0.1.10 were tagged but not released; their fixes are here.)

Before you upgrade

  • Permissions: the data directory is now 0700 and container records 0600, however the daemon was started. Anything outside Legion that reads them as another user will lose access.
  • Network policy: pods now wait until net.link.bridge.pfil_member and net.link.bridge.pfil_local_phys are set, instead of starting with a warning. If those can't be set, pods don't start, and their tasks report why.
  • Tightened namespaces: a Namespace's current security now applies to anything new made from specs admitted earlier. Tasks refused this way wait pending with the reason, tasks not yet started are stopped, and CronJob runs are skipped. Tasks already running keep what they started with.
  • Shared storage: a second Volume naming storage that one node at a time may use (the same iSCSI LUN, or the same plugin volume) is refused.
  • Exec output: an exec, and so an exec probe, keeps the first 1 MiB of each of stdout and stderr. The rest is read and dropped.

New since 0.1.9

Security:

  • Secrets on disk: container records hold environments, Secrets among them, and a daemon started by hand under a umask of 022 left them readable by other users on the host.
  • Revoked permissions: tightening a Namespace didn't reach tasks made from specs admitted earlier, so CronJob runs could keep permissions it no longer allowed.
  • Network policy that didn't hold: if bridge filtering couldn't be enabled, the failure was only logged, and pods started with traffic bypassing their rules.
  • Exec probes: a noisy probe could use up the agent's memory, outside its jail's limits.
  • One storage, two Volumes: two Volumes naming one iSCSI LUN could be mounted on two nodes at once, across namespaces. Storage is now held by what it is, not by the Volume naming it.
  • Watches and sessions: a follower authorized these on its own copy of the cluster, which may lag. It now catches up with the leader first.
  • Removed nodes: registrations and renewals recheck removal against what they read, and a joined name is reserved by revoking its earlier certificate.
  • Deleting: a Volume in use, or held by a live node, is not deleted, and deleting a running task stops it first.

Fixes:

  • Loosened containers: pods whose containers used rawSockets, chflags or enforceStatfs: 1 could not start, as FreeBSD refuses a child jail more than its parent has. The infra jail now allows what its containers ask for, and each container keeps its own profile.
  • Volume sizes: changing a ZFS Volume's size didn't reach a running task's dataset until the pod restarted. It now follows within the agent's resync period (30 seconds by default), growing or shrinking.
  • Agent restarts: a stale status could have a healthy, running pod removed when the agent adopted it. Per-container restart state now survives a restart too.
  • Limits: rctl limits are installed before any process starts.
  • Failed containers: containers stopped as unhealthy or for memory count as failed, and failed stops are retried.
  • Rollouts and updates: fixes to rollbacks, overtaken updates, stateful rollouts past an unready ordinal, and services or jobs recreated under one name.
  • Volume moves and draining: fixes to migrations that were called off, drains of local and held volumes, and stateful data moving only to nodes its task may run on.
  • CronJobs and global jobs: fixes to runs due as the last one finishes, runs after a lost status write, and global jobs on closed or draining nodes.
  • ACME: a certificate is written only over the Secret version that was checked, and only while the routes still ask for it.
  • CARP: addresses move between virtual hosts, and other addresses on a virtual host are removed. Checked against real CARP on epairs.
  • Exec: a dropped exec takes what it started with it, also on the caller's terminal, and job control is unchanged.
  • legion join waits out a cluster between leaders, for up to 15 seconds.
  • Images and jails: fixes to pruning, whiteouts, layers under flagged directories, and starts that fail or are dropped.
  • Compose and CLI: fixes to x-legion, bare ports beside published ones, and legion top.

From 0.1.8 and 0.1.9

Security:

  • Users' rights through a follower: a follower manager checked a user's rights on its own copy of the cluster, which may lag, then forwarded the request to the leader with a manager's rights. Now only the manager that serves a request checks the user's rights, so a RoleBinding just made on the leader is honoured at once.

  • Removing a worker: deleting a Node didn't keep the worker out; its agent registered again. Now its certificates issued before the removal are refused, renewals included, until it joins again with a token. Its open streams (assignments, endpoints, peers, policies, routes, sessions) end within 5 seconds. A Node delete refused for a stale version no longer records the node as removed.

  • Storage quotas: growing a stateful service's volume claim wasn't counted against its namespace's storage quota.

  • Links and special files: a build step could have the cleanup of its resolv.conf follow a link onto the host. Reading an image's /etc/passwd could block on a FIFO or read /dev/zero without end. legion image load followed links inside an OCI layout. All three now refuse links and special files.

  • Descriptor leak: every container inherited an open /dev/null descriptor from the shim.

  • ACME and registry clients: the ACME client no longer follows an authority to plain HTTP, and caps its answers at 1 MiB. The registry client sends logins only to HTTPS token servers, caps manifests at 4 MiB, cuts off a blob past its declared size, and times out stalled reads.

  • Key files: node.key and node.crt were written through one temporary file, so a key could be left world-readable.

  • Certificate lifetimes: a huge days value crashed the request handler; lifetimes are now at most the CA's 10 years.

  • Limits: objects are capped at 1 MiB, ingress TLS handshakes at 10 seconds, and usage reports at 4096 tasks per heartbeat. A node can't overwrite another node's task usage.

  • Autolock reseal: a reseal cut short could leave keys sealed under two unlock keys, or a key in the clear. Each key's new form is now written aside first, then committed with a marker that a restart or the next check carries through.

Fixes:

  • Mixed amd64/arm64 clusters: an image for another platform (including a single-platform image of another architecture, not checked before) is reported as such. The agent rejects the task, and the scheduler keeps the service's tasks off nodes of that platform as it was when they were rejected (a node given --linux since may try again).

  • Jobs and network policy: a Job's tasks could not reach their namespace's services under network policy. They now count as their namespace's, without DNS names or load balancing.

  • Volume moves: when the last part of a Volume's migration was sent again (after a failed mount or commit), the new node could never apply it. It now rolls back to the full copy and applies.

  • Image layers: a directory-mode layer cut short (by a crash or a full disk) was taken as complete. Layers are now made aside and renamed when whole.

  • Build steps: a working directory through a link (such as FreeBSD's /home) was refused; it now resolves inside the image's root, as the jail does.

  • Request metrics leaked memory for each answered call.

  • Updates across a leader change: a new leader took the failures already recorded for a running update as new ones, and could pause or roll back an update that was going well.

  • apply on the leader reads the latest state before it compares specs and checks quotas.

  • Secrets and Configs on a lagging follower: a worker asking a follower for a task's data that the follower hadn't applied yet got an error; the follower now asks the leader.

  • logs -f no longer loses lines across a log rotation, nor a line written just as it starts.

  • Volume plugins get a volume's options on unmount, as on mount.

  • IPv6: an IPv6 address advertised by a worker is kept whole: a bare one lost its last group, as if it were a port.

  • Long service names: task names cut to 63 bytes could clash, and in global mode could be invalid; long names now end in a hash.

  • The rc.d script quotes its directories.

Install

On FreeBSD 15 for amd64, as root:

tar -xf legion-0.1.11-freebsd15-amd64.tar.xz --strip-components 1 -C /usr/local

then follow Install in the README. To upgrade: service legion stop, unpack as above, service legion start; running containers are adopted.

Check the download with sha256 -c $(cat legion-0.1.11-freebsd15-amd64.tar.xz.sha256 | cut -d ' ' -f 1) legion-0.1.11-freebsd15-amd64.tar.xz.