From 1bfd973c6ac424266d9ea9cd636fa19472f0d2b1 Mon Sep 17 00:00:00 2001 From: Jason Deal Date: Tue, 9 Apr 2024 20:15:39 -0700 Subject: [PATCH] test: fix expiration race --- go.mod | 2 ++ go.sum | 4 ++-- pkg/apis/crds/karpenter.sh_nodeclaims.yaml | 10 ++++++++-- pkg/apis/crds/karpenter.sh_nodepools.yaml | 12 +++++++++--- test/suites/expiration/suite_test.go | 2 ++ 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 8d4d7b805121..0aa9e0366ff4 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index 7d13c780cc6d..177e1f1c2922 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/pkg/apis/crds/karpenter.sh_nodeclaims.yaml b/pkg/apis/crds/karpenter.sh_nodeclaims.yaml index 37abdeca8e80..15b8e6d47e98 100644 --- a/pkg/apis/crds/karpenter.sh_nodeclaims.yaml +++ b/pkg/apis/crds/karpenter.sh_nodeclaims.yaml @@ -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: @@ -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: diff --git a/pkg/apis/crds/karpenter.sh_nodepools.yaml b/pkg/apis/crds/karpenter.sh_nodepools.yaml index 44a38267e3e9..72f5c5bd7830 100644 --- a/pkg/apis/crds/karpenter.sh_nodepools.yaml +++ b/pkg/apis/crds/karpenter.sh_nodepools.yaml @@ -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% @@ -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: @@ -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: diff --git a/test/suites/expiration/suite_test.go b/test/suites/expiration/suite_test.go index 168381716de6..759bf1b71d25 100644 --- a/test/suites/expiration/suite_test.go +++ b/test/suites/expiration/suite_test.go @@ -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) @@ -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)