reassert

package
v0.34.0 Latest Latest
Warning

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

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

Documentation

Overview

Package reassert restores weaver's nft tables and the $EGRESS HTB hierarchy after a third party removes them. See docs/commands/network/reassert.md.

Index

Constants

View Source
const (
	ArtifactHostFirewall   = "host-firewall"
	ArtifactWorkloadPolicy = "workload-policy"
	ArtifactEgressQdisc    = "egress-qdisc"
)

Artifact identifiers. Part of the JSON contract with the daemon.

View Source
const DefaultTimeout = 2 * time.Minute

DefaultTimeout bounds one Reassert run, which holds both apply locks throughout.

View Source
const ReportType = "reassert"

ReportType tags the JSON report so a consumer selects it by tag rather than by position (see privexec.ParseNetworkReassertReport).

Variables

This section is empty.

Functions

This section is empty.

Types

type ArtifactStatus

type ArtifactStatus struct {
	Artifact string `json:"artifact"`
	// Expected is true when the artifact is provisioned on this host.
	Expected bool `json:"expected"`
	// Present is true when the artifact is live in the kernel — after a repair
	// that is the re-probe's answer, not the state the run found.
	Present bool `json:"present"`
	// ProbeFailed means presence could not be determined: before a repair, so
	// nothing is repaired, or on the re-probe after one, so Recovered is unknown.
	ProbeFailed bool `json:"probe_failed,omitempty"`
	// Skipped means an operator apply held the lock, so this run left it alone.
	Skipped bool `json:"skipped,omitempty"`
	// Reasserted means a repair was attempted on this run.
	Reasserted bool `json:"reasserted,omitempty"`
	// Recovered means the re-probe after the repair found the artifact present.
	Recovered bool `json:"recovered,omitempty"`
	// Detail is the NIC, the probe error, or the skip reason.
	Detail string `json:"detail,omitempty"`
}

ArtifactStatus is one artifact's outcome for a single run.

type Config

type Config struct {
	HostNftPath   string
	PolicyNftPath string
	NftLockPath   string
	ShapeLockPath string
	// Timeout bounds one Reassert run; zero means DefaultTimeout.
	Timeout time.Duration
	// AcquireLock takes one plane's apply lock without blocking. Its release func
	// must be safe to call even when the lock was not taken.
	AcquireLock    func(path string) (release func(), acquired bool, err error)
	FileExists     func(path string) bool
	NftBinary      func() (string, bool)
	FirewallExists func(ctx context.Context) (bool, error)
	PolicyExists   func(ctx context.Context) (bool, error)
	EgressNIC      func() (string, bool, error)
	QdiscExists    func(ctx context.Context, nic string) (bool, error)
	RestartNft     func(ctx context.Context) error
	RestartShaper  func(ctx context.Context) error
}

Config customises a Reasserter. Unset fields take their production defaults.

type Reasserter

type Reasserter struct {
	// contains filtered or unexported fields
}

Reasserter probes the three artifacts and restores the ones that are definitely missing. Every dependency is a seam so tests need no kernel.

func New

func New() *Reasserter

New returns a Reasserter wired to the live kernel and production paths.

func NewWithConfig

func NewWithConfig(cfg Config) *Reasserter

NewWithConfig returns a Reasserter, filling unset Config fields with defaults.

func (*Reasserter) Check

func (r *Reasserter) Check(ctx context.Context) Report

Check probes all three artifacts without locking or changing anything.

func (*Reasserter) Reassert

func (r *Reasserter) Reassert(ctx context.Context) Report

Reassert probes all three artifacts, restarts each unit with a missing artifact once, then re-probes. Both plane locks are held for the whole run.

type Report

type Report struct {
	// Type is always ReportType.
	Type      string           `json:"type"`
	Artifacts []ArtifactStatus `json:"artifacts"`
}

Report is the result of one Check or Reassert. It always lists all three artifacts in a stable order.

func (Report) Missing

func (r Report) Missing() []ArtifactStatus

Missing returns the artifacts that are expected, absent, and not repaired. Always empty after Reassert.

func (Report) Reasserted

func (r Report) Reasserted() []ArtifactStatus

Reasserted returns the artifacts a repair was attempted for.

func (Report) Skipped

func (r Report) Skipped() []ArtifactStatus

Skipped returns the artifacts this run did not look at because a lock was held.

func (Report) Unhealthy

func (r Report) Unhealthy() []ArtifactStatus

Unhealthy returns the artifacts that could not be probed or did not recover.

Jump to

Keyboard shortcuts

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