crdcheck

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package crdcheck lets the agent and the operator refuse to start against CRDs that are older than they are. helm does not update the crds/ directory, so a release upgraded without `kubectl apply` leaves the API server pruning the new fields; for the enrollment epoch that means a token burnt for nothing. The check reads the published OpenAPI schema of the laboratory group (no extra permission: discovery is open to every authenticated client) and looks for the fields the binary needs.

Index

Constants

View Source
const BudgetRetry = 30 * time.Second

BudgetRetry is how long UsableBudget retries a read that fails for a passing reason.

Variables

View Source
var GangCommitFields = []string{"withdrawals", "retryAfter", "onBudget", "schedulerMessage"}

GangCommitFields are the scheduling fields the gang commit writes.

View Source
var Required = []struct{ Field, On string }{
	{"certificateEpoch", "Tenant.status"},
}

Required are the schema fields that came with this version (a JSON property name each, and the object it belongs to for the message).

Functions

func GangCommitFieldsMissing added in v1.5.0

func GangCommitFieldsMissing(ctx context.Context, get GetCRD) ([]string, error)

GangCommitFieldsMissing names the fields of the gang commit the served Device and LabGroup CRDs lack ("<crd>: <field>"); none: the CRDs are current. An error is the read's.

func UsableBudget added in v1.5.0

func UsableBudget(ctx context.Context, get GetCRD, m nodecap.Maximum, retry time.Duration) (_ nodecap.Maximum, why string, kept error)

UsableBudget is the capacity maximum to run with: m when it has no budget or the served CRDs know the fields of the gang commit; none (the maximum is the current capacity) when a CRD lacks them, is missing or may not be read, with why. A read that fails for another reason (the API server busy, a timeout) is retried with a growing pause for up to retry; if it still fails the budget is kept, since nothing says the CRDs are old, and kept is that last error for the caller to log.

func Verify

func Verify(ctx context.Context, fetch Fetch) error

Verify returns an error that names every missing field and says what to do.

func Wait

func Wait(ctx context.Context, fetch Fetch, timeout time.Duration, log func(error)) error

Wait retries Verify for up to timeout (the schema of a CRD applied a moment ago takes a few seconds to be published).

Types

type Fetch

type Fetch func(context.Context) ([]byte, error)

Fetch returns the OpenAPI v3 document of the laboratory group.

func FromDiscovery

func FromDiscovery(d discovery.DiscoveryInterface) Fetch

FromDiscovery reads the document through the discovery client.

type GetCRD added in v1.5.0

type GetCRD func(ctx context.Context, name string) (map[string]any, error)

GetCRD returns the CustomResourceDefinition of that name as a JSON object; a missing CRD or a refused read is the API's NotFound or Forbidden error.

Jump to

Keyboard shortcuts

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