worker

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDNSDir is the directory where DNS config files are stored
	DefaultDNSDir = "/var/lib/warren/dns"

	// DefaultResolvConf is the default resolv.conf template filename
	DefaultResolvConf = "resolv.conf"
)
View Source
const (
	// SecretsBasePath is the base directory for secret tmpfs mounts
	SecretsBasePath = "/run/secrets"
)

Variables

This section is empty.

Functions

func EnsureSecretsBaseDir

func EnsureSecretsBaseDir() error

EnsureSecretsBaseDir ensures the base secrets directory exists This should be called during worker initialization

func ExtractManagerIP

func ExtractManagerIP(managerAddr string) string

ExtractManagerIP extracts the IP address from manager address Examples:

"192.168.1.100:8080" -> "192.168.1.100"
"localhost:8080" -> "127.0.0.1"
"manager-1:8080" -> "manager-1" (hostname, DNS will resolve)

Types

type Config

type Config struct {
	NodeID           string
	ManagerAddr      string
	DataDir          string
	Resources        *types.NodeResources
	EncryptionKey    []byte // Cluster-wide encryption key for secrets
	ContainerdSocket string // Containerd socket path (empty = auto-detect)
	JoinToken        string // Join token for initial authentication
}

Config holds worker configuration

type DNSHandler

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

DNSHandler manages DNS configuration for containers

func NewDNSHandler

func NewDNSHandler(w *Worker, managerAddr string) (*DNSHandler, error)

NewDNSHandler creates a new DNS handler

func (*DNSHandler) Cleanup

func (h *DNSHandler) Cleanup() error

Cleanup removes the DNS configuration directory

func (*DNSHandler) GenerateResolvConf

func (h *DNSHandler) GenerateResolvConf() (string, error)

GenerateResolvConf generates a resolv.conf file for containers This configures containers to use Warren DNS server on the manager

Format:

nameserver <manager-ip>    # Warren DNS server
nameserver 8.8.8.8          # Google DNS fallback
nameserver 1.1.1.1          # Cloudflare DNS fallback
search warren               # Allow "nginx" instead of "nginx.warren"
options ndots:0             # Try search domains immediately

func (*DNSHandler) GetResolvConfPath

func (h *DNSHandler) GetResolvConfPath() (string, error)

GetResolvConfPath returns the path to the generated resolv.conf file If the file doesn't exist, it generates it first

type HealthMonitor

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

HealthMonitor manages health checks for tasks

func NewHealthMonitor

func NewHealthMonitor(w *Worker) *HealthMonitor

NewHealthMonitor creates a new health monitor

func (*HealthMonitor) Start

func (hm *HealthMonitor) Start()

Start starts the health monitor

func (*HealthMonitor) Stop

func (hm *HealthMonitor) Stop()

Stop stops the health monitor

type SecretsHandler

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

SecretsHandler manages secret mounting for tasks

func NewSecretsHandler

func NewSecretsHandler(worker *Worker, encryptionKey []byte) (*SecretsHandler, error)

NewSecretsHandler creates a new secrets handler

func (*SecretsHandler) CleanupSecretsForTask

func (sh *SecretsHandler) CleanupSecretsForTask(taskID string) error

CleanupSecretsForTask removes all secrets for a task from tmpfs

func (*SecretsHandler) GetSecretPath

func (sh *SecretsHandler) GetSecretPath(taskID, secretName string) string

GetSecretPath returns the path to a specific secret for a task

func (*SecretsHandler) MountSecretsForTask

func (sh *SecretsHandler) MountSecretsForTask(task *types.Task) (string, error)

MountSecretsForTask fetches secrets from manager and mounts them to tmpfs Returns the tmpfs mount path for the container

type VolumesHandler

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

VolumesHandler manages volume mounting for tasks

func NewVolumesHandler

func NewVolumesHandler(worker *Worker) (*VolumesHandler, error)

NewVolumesHandler creates a new volumes handler

func (*VolumesHandler) CleanupVolumesForTask

func (vh *VolumesHandler) CleanupVolumesForTask(task *types.Task) error

CleanupVolumesForTask unmounts volumes for a task (no-op for local driver)

func (*VolumesHandler) PrepareVolumesForTask

func (vh *VolumesHandler) PrepareVolumesForTask(task *types.Task) ([]specs.Mount, error)

PrepareVolumesForTask prepares all volumes for a task and returns mount specs

type Worker

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

Worker represents a Warren worker node

func NewWorker

func NewWorker(cfg *Config) (*Worker, error)

NewWorker creates a new worker instance

func (*Worker) Start

func (w *Worker) Start(resources *types.NodeResources, joinToken string) error

Start starts the worker and connects to manager

func (*Worker) Stop

func (w *Worker) Stop() error

Stop stops the worker

Jump to

Keyboard shortcuts

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