fix(ws): handle empty pod metadata in controller (#193)

Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
This commit is contained in:
Mathew Wicks 2025-02-04 09:23:36 -08:00 committed by GitHub
parent 710cbd4753
commit e1da4cad78
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 19 additions and 2 deletions

View File

@ -584,8 +584,25 @@ func generateStatefulSet(workspace *kubefloworgv1beta1.Workspace, workspaceKind
}
// generate pod metadata
podAnnotations := labels.Merge(workspaceKind.Spec.PodTemplate.PodMetadata.Annotations, workspace.Spec.PodTemplate.PodMetadata.Annotations)
podLabels := labels.Merge(workspaceKind.Spec.PodTemplate.PodMetadata.Labels, workspace.Spec.PodTemplate.PodMetadata.Labels)
// NOTE: pod metadata from the Workspace takes precedence over the WorkspaceKind
podAnnotations := make(map[string]string)
podLabels := make(map[string]string)
if workspaceKind.Spec.PodTemplate.PodMetadata != nil {
for k, v := range workspaceKind.Spec.PodTemplate.PodMetadata.Annotations {
podAnnotations[k] = v
}
for k, v := range workspaceKind.Spec.PodTemplate.PodMetadata.Labels {
podLabels[k] = v
}
}
if workspace.Spec.PodTemplate.PodMetadata != nil {
for k, v := range workspace.Spec.PodTemplate.PodMetadata.Annotations {
podAnnotations[k] = v
}
for k, v := range workspace.Spec.PodTemplate.PodMetadata.Labels {
podLabels[k] = v
}
}
// generate container imagePullPolicy
imagePullPolicy := corev1.PullIfNotPresent