mirror of
https://github.com/lukaszraczylo/jobs-manager-operator.git
synced 2026-06-05 22:33:44 +00:00
2b36071647
* Multiple fixes - add goreleaser to the build / release process - add kubectl plugin for job graphs visualization - add installation scripts - update dependencies * Update the release & CRD content. * Next set of improvements. Code Quality - Label constants: Added LabelWorkflowName, LabelGroupName, LabelJobName, LabelJobID in controllers/definitions.go - Removed commented debug code: Cleaned up dead code from multiple files - Removed unused dependencyTree field: Cleaned connPackage struct - Fixed snake_case variables: Changed to camelCase (runGroup, groupDep, runJob, jobDep, k8sJob) Kubernetes Best Practices - Finalizers: Implemented handleDeletion() and deleteChildJobs() for proper cleanup - Status enum validation: Added +kubebuilder:validation:Enum=pending;running;succeeded;failed;aborted - ImagePullPolicy default: Created getImagePullPolicy() helper that defaults to IfNotPresent - Resource limits support: Added Resources *corev1.ResourceRequirements to ManagedJobParameters Observability - Prometheus metrics: Created controllers/metrics.go with counters (jobs created/succeeded/failed), histogram (reconciliation duration), and gauge (active jobs) - Structured logging: Added logger field to connPackage, used context-based logging throughout Configuration - Leader election ID: Made configurable via --leader-election-id flag - Development mode: Made configurable via --dev-mode flag and LOG_LEVEL env var Performance - Dependency lookup optimization: Changed from O(n*m) to O(1) using lookup maps (jobDepMap, groupDepMap) - Reconciliation backoff: Added RequeueAfter: 30*time.Second when workflow is running Documentation & Testing - Godoc documentation: Added comprehensive comments to API types and controller - Unit tests: Added helpers_test.go with tests for all helper functions - Integration tests: Added managedjob_controller_test.go with Ginkgo/Gomega tests * Add the helm chart release. * Add reasonable test coverage.
49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package controllers
|
|
|
|
// +kubebuilder:validation:Enum=Allow;Forbid;Replace
|
|
const (
|
|
ExecutionStatusPending string = "pending"
|
|
ExecutionStatusRunning string = "running"
|
|
ExecutionStatusSucceeded string = "succeeded"
|
|
ExecutionStatusFailed string = "failed"
|
|
ExecutionStatusAborted string = "aborted"
|
|
ExecutionStatusUnknown string = "unknown"
|
|
)
|
|
|
|
// Label keys used for job tracking and identification
|
|
const (
|
|
LabelWorkflowName = "jobmanager.raczylo.com/workflow-name"
|
|
LabelGroupName = "jobmanager.raczylo.com/group-name"
|
|
LabelJobName = "jobmanager.raczylo.com/job-name"
|
|
LabelJobID = "jobmanager.raczylo.com/job-id"
|
|
)
|
|
|
|
// FinalizerName is the finalizer used to ensure cleanup of child resources
|
|
const FinalizerName = "jobmanager.raczylo.com/finalizer"
|
|
|
|
type (
|
|
ExecutionStatus string
|
|
|
|
tree struct {
|
|
text string
|
|
items []Tree
|
|
}
|
|
|
|
// Tree is tree interface
|
|
Tree interface {
|
|
Add(text string) Tree
|
|
AddTree(tree Tree)
|
|
Items() []Tree
|
|
Text() string
|
|
Print() string
|
|
}
|
|
|
|
printer struct {
|
|
}
|
|
|
|
// Printer is printer interface
|
|
Printer interface {
|
|
Print(Tree) string
|
|
}
|
|
)
|