Skip to content

Commit e1da4ca

Browse files
fix(ws): handle empty pod metadata in controller (#193)
Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
1 parent 710cbd4 commit e1da4ca

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

workspaces/controller/internal/controller/workspace_controller.go

+19-2
Original file line numberDiff line numberDiff line change
@@ -584,8 +584,25 @@ func generateStatefulSet(workspace *kubefloworgv1beta1.Workspace, workspaceKind
584584
}
585585

586586
// generate pod metadata
587-
podAnnotations := labels.Merge(workspaceKind.Spec.PodTemplate.PodMetadata.Annotations, workspace.Spec.PodTemplate.PodMetadata.Annotations)
588-
podLabels := labels.Merge(workspaceKind.Spec.PodTemplate.PodMetadata.Labels, workspace.Spec.PodTemplate.PodMetadata.Labels)
587+
// NOTE: pod metadata from the Workspace takes precedence over the WorkspaceKind
588+
podAnnotations := make(map[string]string)
589+
podLabels := make(map[string]string)
590+
if workspaceKind.Spec.PodTemplate.PodMetadata != nil {
591+
for k, v := range workspaceKind.Spec.PodTemplate.PodMetadata.Annotations {
592+
podAnnotations[k] = v
593+
}
594+
for k, v := range workspaceKind.Spec.PodTemplate.PodMetadata.Labels {
595+
podLabels[k] = v
596+
}
597+
}
598+
if workspace.Spec.PodTemplate.PodMetadata != nil {
599+
for k, v := range workspace.Spec.PodTemplate.PodMetadata.Annotations {
600+
podAnnotations[k] = v
601+
}
602+
for k, v := range workspace.Spec.PodTemplate.PodMetadata.Labels {
603+
podLabels[k] = v
604+
}
605+
}
589606

590607
// generate container imagePullPolicy
591608
imagePullPolicy := corev1.PullIfNotPresent

0 commit comments

Comments
 (0)