stacklok / stacklok/toolhive

Persist explicit network-isolation intent so restart can fail-fast

Open
#5,792 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
2.2k
Forks
300
Avg merge
1d 15h
Merged PRs (30d)
184

Description

Context

Follow-up from the fix for #5775. When a user explicitly passes
--isolate-network=true together with --network host (or another non-bridge
mode), thv run fails fast with an explanatory error. That fail-fast path only
fires at run time, because "was --isolate-network explicit?" lives in the
Cobra command and is not persisted into the RunConfig.

On restart/upgrade the config is loaded straight from disk (bypassing the
builder — see loadRunnerFromState in pkg/workloads/manager.go), so a
persisted config with isolate_network: true + network.mode: host is
degraded-with-warning by degradeNetworkIsolation (pkg/runner/config.go)
rather than erroring.

Why this is deferred (working as intended today)

A fresh explicit conflict errors before anything is persisted, so the only
way such a config reaches disk is hand-editing or a legacy pre-fix config. For
that state, non-breaking degrade-and-warn is the desirable behaviour — you do
not want thv restart/thv upgrade to hard-fail every legacy host-network
workload.

Possible enhancement (low priority)

Persist an "isolation explicitly requested" bit in the RunConfig so that a
hand-edited/legacy explicit-conflict config can surface a hard error on
restart instead of a recurring log warning. Weigh against the added persisted
surface and the risk of hard-failing existing workloads on upgrade.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with loadRunnerFromState in pkg/workloads/manager.go and the RunConfig handling in pkg/runner/config.go. Read how degradeNetworkIsolation processes persisted network settings, then trace the run-time explicitness check. Done means the enhancement's persisted-state behavior and its upgrade impact are clearly evaluated without unexpectedly breaking existing workloads.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.