Skip to content

Commit 19b77e1

Browse files
committed
fix: how we compare interrupt pods
1 parent 19799b0 commit 19b77e1

File tree

5 files changed

+25
-17
lines changed

5 files changed

+25
-17
lines changed

chart/templates/limitrange.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: v1
33
kind: LimitRange
44
metadata:
5-
name: {{ include "skyhook.fullname" . }}-default-limits
5+
name: {{ include "chart.fullname" . }}-default-limits
66
namespace: {{ .Release.Namespace }}
77
spec:
88
limits:

k8s-tests/chainsaw/skyhook/simple-skyhook/assert.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ metadata:
175175
name: simple-skyhook
176176
status:
177177
status: complete
178-
observedGeneration: 2
178+
(to_number(observedGeneration) == `2` || to_number(observedGeneration) == `3`): true
179179
nodeState:
180180
(values(@)):
181181
- dexter|1.2.3:

k8s-tests/chainsaw/skyhook/simple-skyhook/chainsaw-test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ spec:
3333
content: |
3434
## remove annotation from last run
3535
../rest_test.sh simple-skyhook
36-
- create: ## set a limit range in the namespace
36+
- apply: ## set a limit range in the namespace
3737
file: limitrange.yaml
38-
- create:
38+
- apply:
3939
file: skyhook.yaml
4040
- assert:
4141
file: assert.yaml

k8s-tests/chainsaw/skyhook/simple-update-skyhook/assert-update.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ metadata:
104104
name: simple-update-skyhook
105105
status:
106106
status: complete
107-
observedGeneration: 3
107+
(to_number(observedGeneration) == `2` || to_number(observedGeneration) == `3`): true
108108
nodeState:
109109
(values(@)):
110110
- baxter|2.3.1-test:

operator/internal/controller/skyhook_controller.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,8 +1756,12 @@ func podMatchesPackage(opts SkyhookOperatorOptions, _package *v1alpha1.Package,
17561756

17571757
// need to differentiate whether the pod is for an interrupt or not so we know
17581758
// what to expect and how to compare them
1759+
isInterrupt := false
1760+
_, limitRange := pod.Annotations["kubernetes.io/limit-ranger"]
1761+
17591762
if pod.Labels[fmt.Sprintf("%s/interrupt", v1alpha1.METADATA_PREFIX)] == "True" {
17601763
expectedPod = createInterruptPodForPackage(opts, &v1alpha1.Interrupt{}, "", _package, skyhook, "")
1764+
isInterrupt = true
17611765
} else {
17621766
expectedPod = createPodFromPackage(opts, _package, skyhook, "", stage)
17631767
}
@@ -1793,18 +1797,22 @@ func podMatchesPackage(opts SkyhookOperatorOptions, _package *v1alpha1.Package,
17931797
return false
17941798
}
17951799

1796-
// compare resource requests and limits (CPU, memory, etc.)
1797-
expectedResources := expectedContainer.Resources
1798-
actualResources := actualContainer.Resources
1799-
if skyhook.Spec.Packages[_package.Name].Resources != nil {
1800-
// If CR has resources specified, they should match exactly
1801-
if !reflect.DeepEqual(expectedResources, actualResources) {
1802-
return false
1803-
}
1804-
} else {
1805-
// If CR has no resources specified, ensure pod has no resource overrides
1806-
if actualResources.Requests != nil || actualResources.Limits != nil {
1807-
return false
1800+
if !isInterrupt { // dont compare these since they are not configured on interrupt
1801+
// compare resource requests and limits (CPU, memory, etc.)
1802+
expectedResources := expectedContainer.Resources
1803+
actualResources := actualContainer.Resources
1804+
if skyhook.Spec.Packages[_package.Name].Resources != nil {
1805+
// If CR has resources specified, they should match exactly
1806+
if !reflect.DeepEqual(expectedResources, actualResources) {
1807+
return false
1808+
}
1809+
} else {
1810+
// If CR has no resources specified, ensure pod has no resource overrides
1811+
if !limitRange {
1812+
if actualResources.Requests != nil || actualResources.Limits != nil {
1813+
return false
1814+
}
1815+
}
18081816
}
18091817
}
18101818
}

0 commit comments

Comments
 (0)