Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JobSpawner ¶
type JobSpawner interface {
// SpawnJob creates a K8s Job for the task and returns the job name.
// Returns the job name even when the job already exists (idempotent).
SpawnJob(ctx context.Context, task lib.Task, config pkg.AgentConfiguration) (string, error)
// IsJobActive returns true if an active (not completed/failed) K8s Job exists
// for the given task identifier. Uses the agent.benjamin-borbe.de/task-id
// label set by SpawnJob.
IsJobActive(ctx context.Context, taskIdentifier lib.TaskIdentifier) (bool, error)
// CountActiveJobs returns the number of non-terminal K8s Jobs currently
// running for the given assignee. Uses the agent.benjamin-borbe.de/assignee
// label set by SpawnJob. Jobs spawned before that label existed are not
// counted, so the cap under-counts during the rollout and never over-counts.
CountActiveJobs(ctx context.Context, assignee string) (int, error)
}
JobSpawner creates a K8s Job for a task.
func NewJobSpawner ¶
func NewJobSpawner( kubeClient kubernetes.Interface, namespace k8s.Namespace, kafkaBrokers string, branch string, topicPrefix string, currentDateTimeGetter libtime.CurrentDateTimeGetter, jobTTLSecondsAfterFinished int32, jobKafkaClientCertSecret string, jobKafkaCaCertSecret string, jobFsGroup int64, ) JobSpawner
NewJobSpawner creates a new JobSpawner backed by the K8s batch/v1 API. jobTTLSecondsAfterFinished controls how long completed Job pods survive before Kubernetes' TTL controller garbage-collects them. jobKafkaClientCertSecret and jobKafkaCaCertSecret are the names of K8s secrets to mount into spawned Jobs for Kafka mTLS; empty strings mean no cert mounting. jobFsGroup is the pod-level fsGroup stamped onto spawned Jobs when cert mounting is active (see applyKafkaCertVolumes); 0 disables it.
type ServiceReconcileLoop ¶ added in v0.18.0
type ServiceReconcileLoop interface {
// ReconcileOnce runs one full pass over the known Configs.
ReconcileOnce(ctx context.Context) error
// Run reconciles once immediately, then on every tick until ctx is cancelled.
Run(ctx context.Context) error
}
ServiceReconcileLoop ensures one StatefulSet exists per Config whose spec.type is service, and removes the StatefulSet when a Config stops being one.
It is deliberately a periodic pass rather than an informer hook: the Config informer already exists to populate the resolver's store, and a loop keeps the two concerns separate while giving the same convergence. A Config deleted entirely is collected by the ownerRef, so only the "stopped being a service" transition needs the explicit undeploy.
func NewServiceReconcileLoop ¶ added in v0.18.0
func NewServiceReconcileLoop( provider k8s.Provider[agentv1.Config], resolver pkg.ConfigResolver, reconciler ServiceReconciler, interval time.Duration, ) ServiceReconcileLoop
NewServiceReconcileLoop returns a loop that reconciles service Configs read from provider, resolving each one through resolver.
type ServiceReconciler ¶ added in v0.18.0
type ServiceReconciler interface {
// ReconcileService creates or updates the StatefulSet for a service Config.
// It is idempotent: an existing StatefulSet has only its mutable fields
// merged, so an image change rolls the pod and an unchanged Config is a no-op.
ReconcileService(
ctx context.Context,
config agentv1.Config,
resolved pkg.AgentConfiguration,
) error
// UndeployService removes the StatefulSet a Config owns, in the reconciler's
// own namespace — but only if the executor actually owns it.
//
// The ownership check is not defensive decoration. The loop calls this for
// every Config that is not a service, and a StatefulSet's name here is just
// the Config's name, which any other chart in the namespace may also use
// (recurring-task-creator is itself a StatefulSet). Deleting by name alone
// would therefore let a job Config tear down an unrelated workload.
//
// Idempotent and honest: a missing StatefulSet is not an error (the ownerRef
// may already have collected it), and a StatefulSet this executor does not
// own is left untouched and reported as such, never as a removal.
UndeployService(ctx context.Context, name string) error
}
ServiceReconciler reconciles one long-running StatefulSet per Config whose spec.type is service.
It is the identity-shape counterpart to JobSpawner. Where that creates a short-lived Job per task and phase, this creates a workload that outlives any single task and is addressed directly. Both read the same Config CR, and the discriminator between them is ConfigSpec.Type.
func NewServiceReconciler ¶ added in v0.18.0
func NewServiceReconciler( deployer k8s.StatefulSetDeployer, statefulSets k8s.StatefulSetInterface, namespace k8s.Namespace, storageClass string, ) ServiceReconciler
NewServiceReconciler returns a ServiceReconciler that deploys StatefulSets through the given deployer.