queue

package
v0.52.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugHandler added in v0.50.0

func DebugHandler() http.HandlerFunc

DebugHandler serves a read-only view of the queues as JSON. It mutates nothing and exposes only PipelineRun names, which the caller can already list from the cluster.

func FilterPipelineRunByState

func FilterPipelineRunByState(ctx context.Context, tekton versioned2.Interface, orderList []string, wantedStatus, wantedState string) ([]string, error)

FilterPipelineRunByInProgress filters the given list of PipelineRun names to only include those that are in a "queued" state and have a pending status. It retrieves the PipelineRun objects from the Tekton API and checks their annotations and status to determine if they should be included.

Returns A list of PipelineRun names that are in a "queued" state and have a pending status.

func Finishing added in v0.52.0

func Finishing(pr *tektonv1.PipelineRun) bool

Finishing reports whether a PipelineRun has finished or been asked to stop. Both graceful modes need their own check: they leave the run executing its finally tasks, so IsDone and IsCancelled stay false throughout.

func PrKey

func PrKey(run *tektonv1.PipelineRun) string

func RegisterForDebug added in v0.50.0

func RegisterForDebug(qm *Manager)

RegisterForDebug makes a Manager reachable from DebugHandler. The Manager is built long after the watcher's HTTP server is set up, so the handler has to find it later rather than be handed it up front.

func RepoKey

func RepoKey(repo *v1alpha1.Repository) string

func SplitPrKey added in v0.52.0

func SplitPrKey(key string) (namespace, name string, ok bool)

SplitPrKey parses a "namespace/name" queue key, the inverse of PrKey.

Keys can come straight from the user-editable execution-order annotation, so a malformed entry must be rejected rather than indexed: callers use the namespace and name to index a slice or make a Tekton client call, and a panic here has in the past taken the whole watcher down on every restart.

Both segments are checked against the client's own path-segment rules. A segment the client refuses to encode (".", ".." or one containing "%") fails locally, before any request, with a plain error that is not a NotFound, so callers would treat it as retryable and InitQueues would abort startup on every restart over a single bad annotation.

Types

type Admission added in v0.52.0

type Admission struct {
	Candidates []StartCandidate
	// contains filtered or unexported fields
}

Admission leases one owner's unfinished work to one worker. FinishAdmission must be called even on cancellation; it atomically records every batch result.

type AdmissionMode added in v0.52.0

type AdmissionMode int
const (
	AdmissionInitial AdmissionMode = iota
	AdmissionResume
	AdmissionPromotion
)

type Manager

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

func NewManager

func NewManager(logger *zap.SugaredLogger) *Manager

func (*Manager) AcquireAdmission added in v0.52.0

func (qm *Manager) AcquireAdmission(repo *v1alpha1.Repository, owner *tektonv1.PipelineRun, list []string, mode AdmissionMode) (*Admission, error)

func (*Manager) AddListToRunningQueue

func (qm *Manager) AddListToRunningQueue(repo *v1alpha1.Repository, list []string) ([]string, error)

AddListToRunningQueue adds the pipelineRun to the waiting queue of the repository and if it is at the top and ready to run which means currently running pipelineRun < limit then move it to running queue This adds the pipelineRuns in the same order as in the list.

func (*Manager) AddToPendingQueue

func (qm *Manager) AddToPendingQueue(repo *v1alpha1.Repository, list []string) error

func (*Manager) FinishAdmission added in v0.52.0

func (qm *Manager) FinishAdmission(work *Admission) error

func (*Manager) ForgetAdmission added in v0.52.0

func (qm *Manager) ForgetAdmission(repoKey string, owner *tektonv1.PipelineRun)

func (*Manager) InitQueues

func (qm *Manager) InitQueues(ctx context.Context, tekton versioned2.Interface, pac versioned.Interface) error

InitQueues rebuild all the queues for all repository if concurrency is defined before reconciler started reconciling them.

func (*Manager) QueuedPipelineRuns

func (qm *Manager) QueuedPipelineRuns(repo *v1alpha1.Repository) []string

func (*Manager) RemoveAndTakeItemFromQueue

func (qm *Manager) RemoveAndTakeItemFromQueue(repo *v1alpha1.Repository, run *tektonv1.PipelineRun) string

func (*Manager) RemoveFromQueue

func (qm *Manager) RemoveFromQueue(repoKey, prKey string) bool

func (*Manager) RemoveRepository

func (qm *Manager) RemoveRepository(repo *v1alpha1.Repository)

func (*Manager) RunningPipelineRuns

func (qm *Manager) RunningPipelineRuns(repo *v1alpha1.Repository) []string

func (*Manager) Snapshot added in v0.50.0

func (qm *Manager) Snapshot() (map[string]RepoQueue, bool)

Snapshot returns the state of every queue, keyed by "namespace/repository". The bool is false when the manager is busy, in which case there is no snapshot to report.

Every concurrency bug so far has been the in-memory queue drifting away from what is really in the cluster. Reading the queue directly turns "nothing is running and I do not know why" into a named PipelineRun.

This takes the same lock the reconciler needs to admit and release runs, so it only ever tries. A diagnostic that can stall the thing it is diagnosing is worse than one that occasionally says "ask again".

type ManagerInterface

type ManagerInterface interface {
	InitQueues(ctx context.Context, tekton tektonVersionedClient.Interface, pac versioned.Interface) error
	RemoveRepository(repo *v1alpha1.Repository)
	QueuedPipelineRuns(repo *v1alpha1.Repository) []string
	RunningPipelineRuns(repo *v1alpha1.Repository) []string
	AddListToRunningQueue(repo *v1alpha1.Repository, list []string) ([]string, error)
	AddToPendingQueue(repo *v1alpha1.Repository, list []string) error
	RemoveFromQueue(repoKey, prKey string) bool
	RemoveAndTakeItemFromQueue(repo *v1alpha1.Repository, run *tektonv1.PipelineRun) string
	AcquireAdmission(repo *v1alpha1.Repository, owner *tektonv1.PipelineRun, list []string, mode AdmissionMode) (*Admission, error)
	FinishAdmission(work *Admission) error
	ForgetAdmission(repoKey string, owner *tektonv1.PipelineRun)
}

type RepoQueue added in v0.50.0

type RepoQueue struct {
	Limit   int      `json:"limit"`
	Running []string `json:"running"`
	Pending []string `json:"pending"`
}

RepoQueue is what the manager currently believes about one repository.

type Semaphore

type Semaphore interface {
	// contains filtered or unexported methods
}

type StartCandidate added in v0.52.0

type StartCandidate struct {
	Key       string
	UID       types.UID
	Attempted bool
	Outcome   StartOutcome
	// contains filtered or unexported fields
}

StartCandidate is a worker's private copy. Attempted retries retain their reservation even when a read still says Pending: a lost write can commit later.

type StartOutcome added in v0.52.0

type StartOutcome int
const (
	StartRetry StartOutcome = iota
	StartSucceeded
	StartGone
)

Jump to

Keyboard shortcuts

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