Skip to content

Commit 55a9d3a

Browse files
committed
fixup
Signed-off-by: Anatolii Bazko <[email protected]>
1 parent bf8aa66 commit 55a9d3a

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

pkg/library/container/container.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
"github.com/devfile/devworkspace-operator/pkg/library/flatten"
3333
"github.com/devfile/devworkspace-operator/pkg/library/lifecycle"
3434
"github.com/devfile/devworkspace-operator/pkg/library/overrides"
35+
dwResources "github.com/devfile/devworkspace-operator/pkg/library/resources"
3536
corev1 "k8s.io/api/core/v1"
3637
)
3738

@@ -68,7 +69,7 @@ func GetKubeContainersFromDevfile(
6869
if component.Container == nil {
6970
continue
7071
}
71-
k8sContainer, err := convertContainerToK8s(component, securityContext, pullPolicy, defaultResources, resourceCaps)
72+
k8sContainer, err := convertContainerToK8s(component, securityContext, pullPolicy, defaultResources)
7273
if err != nil {
7374
return nil, err
7475
}
@@ -82,6 +83,11 @@ func GetKubeContainersFromDevfile(
8283
}
8384
k8sContainer = patchedContainer
8485
}
86+
87+
// applying caps only after overrides
88+
resources := dwResources.ApplyCaps(&k8sContainer.Resources, resourceCaps)
89+
k8sContainer.Resources = *resources
90+
8591
podAdditions.Containers = append(podAdditions.Containers, *k8sContainer)
8692
}
8793

@@ -94,7 +100,7 @@ func GetKubeContainersFromDevfile(
94100
}
95101

96102
for _, initComponent := range initComponents {
97-
k8sContainer, err := convertContainerToK8s(initComponent, securityContext, pullPolicy, defaultResources, nil)
103+
k8sContainer, err := convertContainerToK8s(initComponent, securityContext, pullPolicy, defaultResources)
98104
if err != nil {
99105
return nil, err
100106
}

pkg/library/container/conversion.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func convertContainerToK8s(
3030
securityContext *corev1.SecurityContext,
3131
pullPolicy string,
3232
defaultResources *corev1.ResourceRequirements,
33-
resourceCaps *corev1.ResourceRequirements,
3433
) (*corev1.Container, error) {
3534
if devfileComponent.Container == nil {
3635
return nil, fmt.Errorf("cannot get k8s container from non-container component")
@@ -42,7 +41,6 @@ func convertContainerToK8s(
4241
return nil, fmt.Errorf("failed to get resources for container %s: %s", devfileComponent.Name, err)
4342
}
4443
containerResources = dwResources.ApplyDefaults(containerResources, defaultResources)
45-
containerResources = dwResources.ApplyCaps(containerResources, resourceCaps)
4644
if err := dwResources.ValidateResources(containerResources); err != nil {
4745
return nil, fmt.Errorf("container resources are invalid for component %s: %w", devfileComponent.Name, err)
4846
}

pkg/library/flatten/merge.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,6 @@ func mergeContributionsInto(
312312
return nil, err
313313
}
314314
totalResources = dwResources.AddResourceRequirements(totalResources, componentResources)
315-
totalResources = dwResources.ApplyCaps(totalResources, resourceCaps)
316315

317316
component.Container.MemoryLimit = ""
318317
component.Container.MemoryRequest = ""

0 commit comments

Comments
 (0)