yurthub

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 39 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package yurthub installs, routes and manages OpenYurt YurtHub in a Flex worker.

Index

Constants

This section is empty.

Variables

View Source
var ErrPackageDownload = errors.New("could not download a valid hub package")

ErrPackageDownload means no valid pinned Hub package could be downloaded, for example because packages.microsoft.com is unreachable or a proxy altered it.

View Source
var ErrUnsupportedWorker = errors.New("hub is not available for this worker")

ErrUnsupportedWorker means no pinned Hub package matches the worker image's OS or architecture. Callers log it and keep the node on the direct API path; it is not retried as a failure.

Functions

func ResetHost

func ResetHost(ctx context.Context, worker Worker) error

ResetHost removes none-mode Hub state before worker identity replacement or host teardown. It must not be called for a soft restart.

func ResetHostTask

func ResetHostTask(log *slog.Logger) phases.Task

ResetHostTask clears native-host Hub state without requiring an applied worker configuration.

Types

type Config

type Config struct {
	Log       *slog.Logger
	Worker    Worker
	NodeName  string
	NodePool  string // Flex agent pool name, used as the apps.openyurt.io/nodepool label
	ServerURL string // direct HTTPS API server URL
	Nodes     typedcorev1.NodeInterface
}

Config identifies the worker and node a set of Hub operations acts on.

type Operations

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

Operations implements Hub transition steps for one worker. Each step is idempotent because the engine can repeat a step after a crash.

func NewOperations

func NewOperations(cfg Config) (*Operations, error)

NewOperations validates inputs once so no step can render unsafe arguments.

func (*Operations) Cleanup

func (o *Operations) Cleanup(context.Context) error

Cleanup has nothing to undo: with filters off, Hub never changed what pods see.

func (*Operations) Converge

func (o *Operations) Converge(ctx context.Context) error

Converge brings an enabled Hub's binary, arguments and unit up to this agent and restarts Hub only if they differ from what it was last started with; otherwise it checks readiness. It never touches kubelet or Node metadata.

func (*Operations) Prepare

func (o *Operations) Prepare(ctx context.Context) error

Prepare checks local prerequisites, renders configuration and starts Hub without touching kubelet routing. If Hub is already running (for example a retry while its serving CSR is pending), it is restarted only when the files it would load differ from what the agent last started it with.

func (*Operations) Restore

func (o *Operations) Restore(ctx context.Context) error

Restore returns kubelet to the direct API server and proves the live process uses it before anything stops Hub.

func (*Operations) Route

func (o *Operations) Route(ctx context.Context) error

Route switches kubelet to Hub. The direct kubeconfig stays in place. It first converges Hub's files and checks Hub is ready and forwards a kubelet request: a crash, retry or agent upgrade can resume at Route long after Prepare ran.

func (*Operations) Stop

func (o *Operations) Stop(ctx context.Context) error

Stop disables Hub, deletes its cache and removes a dummy interface left by an older agent. A missing unit (enable failed before staging) counts as stopped if systemd agrees. The interface is removed only if this agent configured Hub.

func (*Operations) Verify

func (o *Operations) Verify(ctx context.Context) error

Verify checks live routing and upstream access through Hub, then initializes Node metadata once. It is a connected check, not an initial-sync Ready gate.

type Reconciler

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

Reconciler runs the active worker's transition engine on every Machine read; RP changes DT intent without changing the Machine ETag. After a failure it waits (1 minute, doubling to 15) so Node events don't repeat 2-minute readiness waits on the shared queue; a changed intent or worker runs immediately. Only the serialized daemon queue calls it, so retry state needs no lock.

func NewReconciler

func NewReconciler(log *slog.Logger, nodeName, nodePool, serverURL string, nodes typedcorev1.NodeInterface, heartbeat time.Duration) *Reconciler

NewReconciler builds a DT reconciler using the node client. Calls must be serialized with other worker lifecycle operations.

func (*Reconciler) Reconcile

func (a *Reconciler) Reconcile(ctx context.Context, intent *bool, worker Worker, node *corev1.Node) error

Reconcile applies authoritative intent to the current worker and live Node. A zero Worker means no active worker; nil intent leaves state untouched.

type Worker

type Worker struct {
	Scope       string
	Root        isolation.NodeRoot
	Exec        func(context.Context, ...string) (string, error)
	KubeletUnit string
	Mode        isolation.Mode
}

Worker identifies the active worker and its execution environment. Scope is the stable identifier stored in the transition journal.

Jump to

Keyboard shortcuts

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