netpool

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package netpool hands out pre-created swarm overlays.

A swarm service cannot join a network without rolling its tasks, so traefik cannot follow environments that come and go: it would roll on every new env and every PR preview. Instead the networks exist up front, traefik joins all of them once, and an environment takes a free one and gives it back (docs/plans/30-docker-swarm.md, decision 2).

The consequence is that a network name means nothing on its own. The only mapping from network to owner is the DB column, environments.network for an env, tiles.shared_net for a shared managed instance. Nothing parses a name.

Index

Constants

View Source
const (
	// EnvPrefix names the environment pool, DBPrefix the pool a shared
	// managed db draws from so consumers in dev cannot see consumers in prod.
	EnvPrefix = "stkr-net-"
	DBPrefix  = "stkr-dbnet-"

	// Sizes pre-created at boot. Not a ceiling: a claim past the end creates
	// the next name, which is all growth means while traefik is still a
	// container that can hot-join. Once traefik is a service (step 4) growth
	// has to roll it, and that is where the warning on the plan page lands.
	EnvPoolSize = 32
	DBPoolSize  = 8
)

Variables

This section is empty.

Functions

func Backfill

func Backfill(ctx context.Context, store repo.Store, rt *runtime.Runtime)

Sweep clears out pooled networks that no row holds any more. Shaped like runtime.SweepForwardState: a crash between deleting the owner row and disconnecting its containers leaves a network that is free by the DB and occupied in reality, so the next environment to claim it starts with a neighbour it can reach. Best-effort, boot only. Backfill gives an overlay to every environment that has none.

Migration 009 added environments.network with an empty default and backfilled nothing, and the only thing that ever fills it is ClaimEnv, which runs at deploy. So on an upgraded install every environment that already existed sat on no overlay until somebody happened to redeploy it: port forward refused with "tile is not on a network yet", and the proxy left the whole environment out of its network-to-env map without saying anything.

Runs at boot next to Sweep. A pool with nothing left is logged and skipped rather than fatal, an install that cannot claim is still an install that should come up and say so.

func ClaimDB

func ClaimDB(ctx context.Context, store repo.Store, rt *runtime.Runtime, t *repo.Tile) (string, error)

ClaimDB is ClaimEnv for a shared managed instance's own network.

func ClaimEnv

func ClaimEnv(ctx context.Context, store repo.Store, rt *runtime.Runtime, envID string) (string, error)

ClaimEnv returns the environment's overlay, taking a free one from the pool the first time. Idempotent: an env that already holds one keeps it.

func Ensure

func Ensure(ctx context.Context, rt *runtime.Runtime) error

Ensure pre-creates both pools. Called at boot, before anything claims.

func ReleaseDB

func ReleaseDB(ctx context.Context, store repo.Store, rt *runtime.Runtime, t *repo.Tile) error

ReleaseDB is ReleaseEnv for a shared managed instance.

func ReleaseEnv

func ReleaseEnv(ctx context.Context, store repo.Store, rt *runtime.Runtime, env *repo.Environment) error

ReleaseEnv gives an environment's network back. The network object itself stays, it is pooled, not per-tenant, and traefik is on it.

func Sweep

func Sweep(ctx context.Context, store repo.Store, rt *runtime.Runtime)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL