From 9f325c1338fdfddd9a63135a3a22580d506b4570 Mon Sep 17 00:00:00 2001 From: Amanuel Engeda <74629455+engedaam@users.noreply.github.com> Date: Tue, 1 Aug 2023 06:10:45 -0700 Subject: [PATCH] chore: Add testing for NodeRequirement Drift (#3933) --- go.mod | 2 +- go.sum | 4 ++-- test/suites/drift/suite_test.go | 8 ++++++-- website/content/en/preview/concepts/deprovisioning.md | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 09ba6649a9a5..c1bf0d76954d 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ require ( github.com/PuerkitoBio/goquery v1.8.1 github.com/avast/retry-go v3.0.0+incompatible github.com/aws/aws-sdk-go v1.44.294 - github.com/aws/karpenter-core v0.29.2-0.20230725171823-d34a21d5648d + github.com/aws/karpenter-core v0.29.2-0.20230801010020-94053bac8d48 github.com/go-playground/validator/v10 v10.13.0 github.com/imdario/mergo v0.3.16 github.com/mitchellh/hashstructure/v2 v2.0.2 diff --git a/go.sum b/go.sum index 2595332a4e59..7e810f1da1b1 100644 --- a/go.sum +++ b/go.sum @@ -53,8 +53,8 @@ github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHS github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY= github.com/aws/aws-sdk-go v1.44.294 h1:3x7GaEth+pDU9HwFcAU0awZlEix5CEdyIZvV08SlHa8= github.com/aws/aws-sdk-go v1.44.294/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= -github.com/aws/karpenter-core v0.29.2-0.20230725171823-d34a21d5648d h1:NRv2tSoPVyyYnLWco4w+OSXiEo434QLxNCq7ecxb8Eo= -github.com/aws/karpenter-core v0.29.2-0.20230725171823-d34a21d5648d/go.mod h1:+C8X0N378fQ/+YmopvRHflj2JFrVP8sPs9xL7v4A6eM= +github.com/aws/karpenter-core v0.29.2-0.20230801010020-94053bac8d48 h1:efBudEW9YaaPqwXVa20z23bsLQ5qji23W0Qcd6Xd1rI= +github.com/aws/karpenter-core v0.29.2-0.20230801010020-94053bac8d48/go.mod h1:+C8X0N378fQ/+YmopvRHflj2JFrVP8sPs9xL7v4A6eM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= diff --git a/test/suites/drift/suite_test.go b/test/suites/drift/suite_test.go index 7c86d3adb1c5..0d63ca15da5a 100644 --- a/test/suites/drift/suite_test.go +++ b/test/suites/drift/suite_test.go @@ -279,7 +279,10 @@ var _ = Describe("Drift", Label("AWS"), func() { SecurityGroupSelector: map[string]string{"karpenter.sh/discovery": settings.FromContext(env.Context).ClusterName}, SubnetSelector: map[string]string{"karpenter.sh/discovery": settings.FromContext(env.Context).ClusterName}, }}) - provisioner = test.Provisioner(test.ProvisionerOptions{ProviderRef: &v1alpha5.MachineTemplateRef{Name: nodeTemplate.Name}}) + provisioner = test.Provisioner(test.ProvisionerOptions{ + Requirements: []v1.NodeSelectorRequirement{{Key: v1alpha5.LabelCapacityType, Operator: v1.NodeSelectorOpIn, Values: []string{v1alpha5.CapacityTypeOnDemand}}}, + ProviderRef: &v1alpha5.MachineTemplateRef{Name: nodeTemplate.Name}, + }) // Add a do-not-evict pod so that we can check node metadata before we deprovision pod = test.Pod(test.PodOptions{ ObjectMeta: metav1.ObjectMeta{ @@ -289,7 +292,7 @@ var _ = Describe("Drift", Label("AWS"), func() { }, }) }) - DescribeTable("provisioner static drift", func(fieldName string, provisionerOption test.ProvisionerOptions) { + DescribeTable("Provisioner Drift", func(fieldName string, provisionerOption test.ProvisionerOptions) { provisionerOption.ObjectMeta = provisioner.ObjectMeta updatedProvisioner := test.Provisioner( test.ProvisionerOptions{ProviderRef: &v1alpha5.MachineTemplateRef{Name: nodeTemplate.Name}}, @@ -334,6 +337,7 @@ var _ = Describe("Drift", Label("AWS"), func() { EvictionSoftGracePeriod: map[string]metav1.Duration{"memory.available": {Duration: time.Minute}}, }}), Entry("Start-up Taints Drift", "Start-up Taint", test.ProvisionerOptions{StartupTaints: []v1.Taint{{Key: "example.com/another-taint-2", Effect: v1.TaintEffectPreferNoSchedule}}}), + Entry("NodeRequirement Drift", "NodeRequirement", test.ProvisionerOptions{Requirements: []v1.NodeSelectorRequirement{{Key: v1alpha5.LabelCapacityType, Operator: v1.NodeSelectorOpIn, Values: []string{v1alpha5.CapacityTypeSpot}}}}), ) }) }) diff --git a/website/content/en/preview/concepts/deprovisioning.md b/website/content/en/preview/concepts/deprovisioning.md index 47a765a6e322..6510a2449c79 100644 --- a/website/content/en/preview/concepts/deprovisioning.md +++ b/website/content/en/preview/concepts/deprovisioning.md @@ -158,7 +158,7 @@ Read the [Drift Design](https://github.com/aws/karpenter-core/pull/366/files) fo | Taints | x | | | x | | Labels | x | | | x | | Annotations | x | | | x | -| Node Requirements | | x | | | +| Node Requirements | | x | | x | | Kubelet Configuration | x | | | x | | Weight | | | x | NA | | Limits | | | x | NA |