Documentation
¶
Index ¶
- Constants
- func ApplyControllerPodSpecModifications(podSpec *corev1.PodSpec, connection temporaliov1alpha1.ConnectionSpec, ...)
- func CleanStringForDNS(s string) string
- func ComputeBuildID(w *temporaliov1alpha1.WorkerDeployment) string
- func ComputeConnectionSpecHash(connection temporaliov1alpha1.ConnectionSpec) string
- func ComputePodTemplateSpecHash(template corev1.PodTemplateSpec) string
- func ComputeRenderedObjectHash(resource *unstructured.Unstructured) string
- func ComputeSelectorLabels(twdName, buildID string) map[string]string
- func ComputeVersionedDeploymentName(baseName, buildID string) string
- func ComputeWorkerDeploymentName(w *temporaliov1alpha1.WorkerDeployment) string
- func ComputeWorkerResourceTemplateName(twdName, wrtName, buildID string) string
- func HashString(s string) string
- func IsDeploymentHealthy(deployment *appsv1.Deployment) (bool, *metav1.Time)
- func NewDeploymentWithControllerRef(w *temporaliov1alpha1.WorkerDeployment, buildID string, ...) (*appsv1.Deployment, error)
- func NewDeploymentWithOwnerRef(typeMeta *metav1.TypeMeta, objectMeta *metav1.ObjectMeta, ...) *appsv1.Deployment
- func NewObjectRef(obj client.Object) *corev1.ObjectReference
- func RenderWorkerResourceTemplate(wrt *temporaliov1alpha1.WorkerResourceTemplate, deployment *appsv1.Deployment, ...) (*unstructured.Unstructured, error)
- func TruncateString(s string, n int) string
- func WorkerResourceTemplateVersionStatusForBuildID(buildID, resourceName string, generation int64, hash, applyError string) temporaliov1alpha1.WorkerResourceTemplateVersionStatus
- type DeploymentState
Constants ¶
const ( DeployOwnerKey = ".metadata.controller" // BuildIDLabel is the label that identifies the build ID for a deployment BuildIDLabel = "temporal.io/build-id" WorkerDeploymentNameSeparator = "/" ResourceNameSeparator = "-" MaxBuildIDLen = 63 MaxDeploymentNameLen = 47 ConnectionSpecHashAnnotation = "temporal.io/connection-spec-hash" PodTemplateSpecHashAnnotation = "temporal.io/pod-template-spec-hash" )
const FieldManager = "temporal-worker-controller"
FieldManager is the SSA field manager name used when applying WorkerResourceTemplate-rendered resources. A single constant per controller is the standard Kubernetes pattern (see e.g. the ResourceClaim controller). TODO: Use this when we apply SSA to all resources.
const RenderedHashLen = 16
RenderedHashLen is the number of hex characters used for rendered-object hashes stored in WorkerResourceTemplateVersionStatus.LastAppliedHash. 16 hex chars = 8 bytes = 64 bits, giving negligible collision probability across thousands of (WRT × BuildID) pairs.
Variables ¶
This section is empty.
Functions ¶
func ApplyControllerPodSpecModifications ¶ added in v1.2.0
func ApplyControllerPodSpecModifications( podSpec *corev1.PodSpec, connection temporaliov1alpha1.ConnectionSpec, temporalNamespace string, workerDeploymentName string, buildID string, )
ApplyControllerPodSpecModifications applies controller-managed environment variables and volume mounts to a pod spec. This is used both when creating new deployments and when updating existing deployments for drift detection.
func CleanStringForDNS ¶ added in v1.0.0
func ComputeBuildID ¶
func ComputeBuildID(w *temporaliov1alpha1.WorkerDeployment) string
func ComputeConnectionSpecHash ¶ added in v0.1.5
func ComputeConnectionSpecHash(connection temporaliov1alpha1.ConnectionSpec) string
TODO (Shivam): Change hash when secret name is updated as well.
func ComputePodTemplateSpecHash ¶ added in v1.2.0
func ComputePodTemplateSpecHash(template corev1.PodTemplateSpec) string
ComputePodTemplateSpecHash computes a SHA256 hash of the user-provided pod template spec. This hash is used to detect drift when the build ID is stable but the pod spec has changed. JSON marshaling is used so that new zero-value fields added in future k8s API versions (which carry omitempty) are excluded, keeping hashes stable across k8s upgrades.
func ComputeRenderedObjectHash ¶ added in v1.5.0
func ComputeRenderedObjectHash(resource *unstructured.Unstructured) string
ComputeRenderedObjectHash returns a stable, deterministic hash of a rendered Unstructured object. The hash is computed from the JSON representation of the object; encoding/json serialises map keys in sorted order, so the result is deterministic regardless of map iteration order. Returns an empty string (not an error) if marshalling fails — callers treat an empty hash as "always apply". When the returned hash is empty, the stored LastAppliedHash remains "" in status after a successful apply, so the "always apply" behaviour persists across reconcile cycles until marshalling succeeds.
func ComputeSelectorLabels ¶ added in v1.5.0
ComputeSelectorLabels returns the selector labels used by a versioned Deployment. These are the same labels set on the Deployment.Spec.Selector.MatchLabels.
func ComputeVersionedDeploymentName ¶
ComputeVersionedDeploymentName generates a name for a versioned deployment Name will be <=47 characters and unique for that Worker Deployment Version within the namespace.
func ComputeWorkerDeploymentName ¶
func ComputeWorkerDeploymentName(w *temporaliov1alpha1.WorkerDeployment) string
ComputeWorkerDeploymentName generates the base worker deployment name
func ComputeWorkerResourceTemplateName ¶ added in v1.5.0
ComputeWorkerResourceTemplateName generates a deterministic, DNS-safe name for the worker resource template instance corresponding to a given (twdName, wrtName, buildID) triple.
The name has the form:
{human-readable-prefix}-{8-char-hash}
The 8-character hash is computed from the full untruncated triple BEFORE any length capping occurs. This guarantees that two different triples — including triples that differ only in the buildID — always produce different names, even if the human-readable prefix is truncated. The buildID is therefore always uniquely represented via the hash, regardless of how long twdName or wrtName are.
func HashString ¶ added in v1.3.0
func IsDeploymentHealthy ¶
func IsDeploymentHealthy(deployment *appsv1.Deployment) (bool, *metav1.Time)
IsDeploymentHealthy checks if a deployment is in the "Available" state
func NewDeploymentWithControllerRef ¶
func NewDeploymentWithControllerRef( w *temporaliov1alpha1.WorkerDeployment, buildID string, connection temporaliov1alpha1.ConnectionSpec, reconcilerScheme *runtime.Scheme, ) (*appsv1.Deployment, error)
func NewDeploymentWithOwnerRef ¶
func NewDeploymentWithOwnerRef( typeMeta *metav1.TypeMeta, objectMeta *metav1.ObjectMeta, spec *temporaliov1alpha1.WorkerDeploymentSpec, workerDeploymentName string, buildID string, connection temporaliov1alpha1.ConnectionSpec, ) *appsv1.Deployment
NewDeploymentWithOwnerRef creates a new deployment resource, including owner references
func NewObjectRef ¶
func NewObjectRef(obj client.Object) *corev1.ObjectReference
NewObjectRef creates a reference to a Kubernetes object
func RenderWorkerResourceTemplate ¶ added in v1.5.0
func RenderWorkerResourceTemplate( wrt *temporaliov1alpha1.WorkerResourceTemplate, deployment *appsv1.Deployment, buildID string, temporalNamespace string, ) (*unstructured.Unstructured, error)
RenderWorkerResourceTemplate produces the Unstructured object to apply via SSA for a given WorkerResourceTemplate and versioned Deployment.
Processing order:
- Unmarshal spec.template into an Unstructured
- Auto-inject scaleTargetRef and matchLabels (Layer 1)
- Set metadata (name, namespace, labels, owner reference)
func TruncateString ¶ added in v1.0.0
TruncateString truncates string to the first n characters. Pass n = -1 to skip truncation.
func WorkerResourceTemplateVersionStatusForBuildID ¶ added in v1.5.0
func WorkerResourceTemplateVersionStatusForBuildID(buildID, resourceName string, generation int64, hash, applyError string) temporaliov1alpha1.WorkerResourceTemplateVersionStatus
WorkerResourceTemplateVersionStatusForBuildID builds a per-Build-ID status entry. generation is the WRT metadata.generation at the time of the apply; pass 0 on error to preserve the last-known-good generation. hash is the controller-internal rendered-object hash used for the SSA skip optimisation (pass "" on error).
Types ¶
type DeploymentState ¶
type DeploymentState struct {
// Map of buildID to deployment
Deployments map[string]*appsv1.Deployment
// Sorted deployments by creation time
DeploymentsByTime []*appsv1.Deployment
// Map of buildID to deployment references
DeploymentRefs map[string]*corev1.ObjectReference
}
DeploymentState represents the Kubernetes state of all deployments for a temporal worker deployment