Skip to content

Commit

Permalink
Use mergePodAdditions
Browse files Browse the repository at this point in the history
Signed-off-by: David Kwon <[email protected]>
  • Loading branch information
dkwon17 committed Jun 7, 2024
1 parent c1d42aa commit 4cdf560
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions controllers/workspace/devworkspace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,9 @@ func (r *DevWorkspaceReconciler) Reconcile(ctx context.Context, req ctrl.Request
allPodAdditions = append(allPodAdditions, *routingPodAdditions)
}

annotationAdditions := controllerv1alpha1.PodAdditions{Annotations: workspace.Config.Workspace.PodAnnotations}
allPodAdditions = append(allPodAdditions, annotationAdditions)

// Step five: Prepare workspace ServiceAccount
var serviceAcctName string
if *workspace.Config.Workspace.ServiceAccount.DisableCreation {
Expand Down
3 changes: 3 additions & 0 deletions pkg/config/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,9 @@ func GetCurrentConfigString(currConfig *controller.OperatorConfiguration) string
if !reflect.DeepEqual(workspace.DefaultContainerResources, defaultConfig.Workspace.DefaultContainerResources) {
config = append(config, "workspace.defaultContainerResources is set")
}
if !reflect.DeepEqual(workspace.PodAnnotations, defaultConfig.Workspace.PodAnnotations) {
config = append(config, "workspace.podAnnotations is set")
}
}
if currConfig.EnableExperimentalFeatures != nil && *currConfig.EnableExperimentalFeatures {
config = append(config, "enableExperimentalFeatures=true")
Expand Down
4 changes: 3 additions & 1 deletion pkg/provision/workspace/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func getSpecDeployment(
constants.DevWorkspaceIDLabel: workspace.Status.DevWorkspaceId,
constants.DevWorkspaceNameLabel: workspace.Name,
},
Annotations: workspace.Config.Workspace.PodAnnotations,
Annotations: podAdditions.Annotations,
},
Spec: corev1.PodSpec{
InitContainers: podAdditions.InitContainers,
Expand Down Expand Up @@ -292,6 +292,8 @@ func getProgressDeadlineSeconds(config *v1alpha1.OperatorConfiguration) (int32,

func mergePodAdditions(toMerge []v1alpha1.PodAdditions) (*v1alpha1.PodAdditions, error) {
podAdditions := &v1alpha1.PodAdditions{}
podAdditions.Annotations = make(map[string]string)
podAdditions.Labels = make(map[string]string)

// "Set"s to store k8s object names and detect duplicates
containerNames := map[string]bool{}
Expand Down

0 comments on commit 4cdf560

Please sign in to comment.