queue

package
v0.50.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 20 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

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 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

Types

type Manager

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

func NewManager

func NewManager(logger *zap.SugaredLogger) *Manager

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) 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
}

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
}

Jump to

Keyboard shortcuts

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