Skip to content

Commit

Permalink
test: fix expiration race
Browse files Browse the repository at this point in the history
  • Loading branch information
jmdeal committed Apr 10, 2024
1 parent af43cf8 commit 1bfd973
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 7 deletions.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,5 @@ require (
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace sigs.k8s.io/karpenter => github.com/jmdeal/karpenter v0.0.0-20240410181508-223cbfdf808c
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ github.com/imdario/mergo v0.3.16 h1:wwQJbIsHYGMUyLSPrEq1CT16AhnhNJQ51+4fdHUnCl4=
github.com/imdario/mergo v0.3.16/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/jmdeal/karpenter v0.0.0-20240410181508-223cbfdf808c h1:2qxcgK+ZItCc5fCiRXLEtBuv1akysuOidXNTqNREg8I=
github.com/jmdeal/karpenter v0.0.0-20240410181508-223cbfdf808c/go.mod h1:fieFojxOec/l0tDmFT7R+g/Y+SGQbL9VlcYO8xb3sLo=
github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
Expand Down Expand Up @@ -759,8 +761,6 @@ sigs.k8s.io/controller-runtime v0.17.2 h1:FwHwD1CTUemg0pW2otk7/U5/i5m2ymzvOXdbeG
sigs.k8s.io/controller-runtime v0.17.2/go.mod h1:+MngTvIQQQhfXtwfdGw/UOQ/aIaqsYywfCINOtwMO/s=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
sigs.k8s.io/karpenter v0.35.1-0.20240404200702-545d88a836d4 h1:eb3ubw9tFiV62Gq1Ci5r5BCJ8OlKu2Mqf7h3tJIRe0U=
sigs.k8s.io/karpenter v0.35.1-0.20240404200702-545d88a836d4/go.mod h1:fieFojxOec/l0tDmFT7R+g/Y+SGQbL9VlcYO8xb3sLo=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
Expand Down
10 changes: 8 additions & 2 deletions pkg/apis/crds/karpenter.sh_nodeclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ spec:
type: integer
kubeReserved:
additionalProperties:
type: string
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: KubeReserved contains resources reserved for Kubernetes system components.
type: object
x-kubernetes-validations:
Expand All @@ -166,8 +169,11 @@ spec:
type: integer
systemReserved:
additionalProperties:
type: string
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: SystemReserved contains resources reserved for OS system daemons and kernel memory.
type: object
x-kubernetes-validations:
Expand Down
12 changes: 9 additions & 3 deletions pkg/apis/crds/karpenter.sh_nodepools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ spec:
This is required if Schedule is set.
This regex has an optional 0s at the end since the duration.String() always adds
a 0s at the end.
pattern: ^((([0-9]+(h|m))|([0-9]+h[0-9]+m))(0s)?)$
pattern: ^([0-9]+(m|h)+(0s)?)$
type: string
nodes:
default: 10%
Expand Down Expand Up @@ -266,8 +266,11 @@ spec:
type: integer
kubeReserved:
additionalProperties:
type: string
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: KubeReserved contains resources reserved for Kubernetes system components.
type: object
x-kubernetes-validations:
Expand All @@ -292,8 +295,11 @@ spec:
type: integer
systemReserved:
additionalProperties:
type: string
anyOf:
- type: integer
- type: string
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
description: SystemReserved contains resources reserved for OS system daemons and kernel memory.
type: object
x-kubernetes-validations:
Expand Down
2 changes: 2 additions & 0 deletions test/suites/expiration/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ var _ = Describe("Expiration", func() {
// Set the expireAfter to "Never" to make sure new node isn't deleted
// This is CRITICAL since it prevents nodes that are immediately spun up from immediately being expired and
// racing at the end of the E2E test, leaking node resources into subsequent tests
env.EventuallyExpectNodeClaimCount("==", 2)
nodePool.Spec.Disruption.ExpireAfter.Duration = nil
env.ExpectUpdated(nodePool)

Expand Down Expand Up @@ -561,6 +562,7 @@ var _ = Describe("Expiration", func() {
// Set the expireAfter to "Never" to make sure new node isn't deleted
// This is CRITICAL since it prevents nodes that are immediately spun up from immediately being expired and
// racing at the end of the E2E test, leaking node resources into subsequent tests
env.EventuallyExpectNodeClaimCount("==", 2)
nodePool.Spec.Disruption.ExpireAfter.Duration = nil
env.ExpectUpdated(nodePool)

Expand Down

0 comments on commit 1bfd973

Please sign in to comment.