Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions api/v1/prefectworkpool_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,17 @@ type PrefectWorkPoolSpec struct {

// DeploymentLabels defines additional labels to add to the Prefect Server Deployment
DeploymentLabels map[string]string `json:"deploymentLabels,omitempty"`

// Base job template for flow runs on this Work Pool
BaseJobTemplate *RawValueSource `json:"baseJobTemplate,omitempty"`
}

// PrefectWorkPoolStatus defines the observed state of PrefectWorkPool
type PrefectWorkPoolStatus struct {
// Id is the workPool ID from Prefect
// +optional
Id *string `json:"id,omitempty"`
Copy link
Collaborator

@chrisguidry chrisguidry Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 How were we getting away without the Id before? I guess the API mostly deals in work pool names rather than IDs, but this is a good addition for sure.


// Version is the version of the Prefect Worker that is currently running
Version string `json:"version"`

Expand All @@ -65,6 +72,21 @@ type PrefectWorkPoolStatus struct {
// Ready is true if the work pool is ready to accept work
Ready bool `json:"ready"`

// SpecHash tracks changes to the spec to minimize API calls
SpecHash string `json:"specHash,omitempty"`

// LastSyncTime is the last time the workPool was synced with Prefect
// +optional
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`

// ObservedGeneration tracks the last processed generation
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// BaseJobTemplateVersion tracks the version of BaseJobTemplate ConfigMap, if any is defined
// +optional
BaseJobTemplateVersion string `json:"baseJobTemplateVersion,omitempty"`

// Conditions store the status conditions of the PrefectWorkPool instances
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
}
Expand Down
31 changes: 31 additions & 0 deletions api/v1/raw_value_source.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package v1

import (
"fmt"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
)

type RawValueSource struct {
Value *runtime.RawExtension `json:"value,omitempty"`
ConfigMap *corev1.ConfigMapKeySelector `json:"configMap,omitempty"`
Patches []JsonPatch `json:"patches,omitempty"`
}

type JsonPatch struct {
Operation string `json:"op"`
Path string `json:"path"`

// +kubebuilder:pruning:PreserveUnknownFields
// +kubebuilder:validation:Schemaless
Value *runtime.RawExtension `json:"value,omitempty"`
}

// TODO - no admission webhook yet
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great call, we've been needing this for a while, I made an issue for it: #195

func (spec *RawValueSource) Validate() error {
if spec.Value != nil && spec.ConfigMap != nil {
return fmt.Errorf("value and configMap are mutually exclusive")
}
return nil
}
66 changes: 66 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,50 @@ spec:
spec:
description: PrefectWorkPoolSpec defines the desired state of PrefectWorkPool
properties:
baseJobTemplate:
description: Base job template for flow runs on this Work Pool
properties:
configMap:
description: Selects a key from a ConfigMap.
properties:
key:
description: The key to select.
type: string
name:
default: ""
description: |-
Name of the referent.
This field is effectively required, but due to backwards compatibility is
allowed to be empty. Instances of this type with an empty value here are
almost certainly wrong.
More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
type: string
optional:
description: Specify whether the ConfigMap or its key must
be defined
type: boolean
required:
- key
type: object
x-kubernetes-map-type: atomic
patches:
items:
properties:
op:
type: string
path:
type: string
value:
x-kubernetes-preserve-unknown-fields: true
required:
- op
- path
type: object
type: array
value:
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
deploymentLabels:
additionalProperties:
type: string
Expand Down Expand Up @@ -1991,6 +2035,10 @@ spec:
status:
description: PrefectWorkPoolStatus defines the observed state of PrefectWorkPool
properties:
baseJobTemplateVersion:
description: BaseJobTemplateVersion tracks the version of BaseJobTemplate
ConfigMap, if any is defined
type: string
conditions:
description: Conditions store the status conditions of the PrefectWorkPool
instances
Expand Down Expand Up @@ -2049,6 +2097,18 @@ spec:
- type
type: object
type: array
id:
description: Id is the workPool ID from Prefect
type: string
lastSyncTime:
description: LastSyncTime is the last time the workPool was synced
with Prefect
format: date-time
type: string
observedGeneration:
description: ObservedGeneration tracks the last processed generation
format: int64
type: integer
ready:
description: Ready is true if the work pool is ready to accept work
type: boolean
Expand All @@ -2057,6 +2117,9 @@ spec:
ready
format: int32
type: integer
specHash:
description: SpecHash tracks changes to the spec to minimize API calls
type: string
version:
description: Version is the version of the Prefect Worker that is
currently running
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.24.2

require (
dario.cat/mergo v1.0.2
github.com/evanphx/json-patch v0.5.2
github.com/go-logr/logr v1.4.3
github.com/google/uuid v1.6.0
github.com/onsi/ginkgo/v2 v2.25.2
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
Expand Down
Loading
Loading