Skip to content

Commit

Permalink
fix: karpenter-convert panic error when converting provisioners (#4988)
Browse files Browse the repository at this point in the history
Co-authored-by: Giacomo Tomolillo <[email protected]>
Co-authored-by: Jonathan Innis <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2023
1 parent 15d61cb commit 3ab813b
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 24 deletions.
22 changes: 10 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ help: ## Display help

presubmit: verify test ## Run all steps in the developer loop

ci-test: battletest coverage ## Runs tests and submits coverage
ci-test: test coverage ## Runs tests and submits coverage

ci-non-test: verify licenses vulncheck ## Runs checks other than tests

Expand All @@ -66,17 +66,15 @@ clean-run: ## Clean resources deployed by the run target
kubectl delete configmap -n ${SYSTEM_NAMESPACE} karpenter-global-settings --ignore-not-found

test: ## Run tests
go test -v ./pkg/$(shell echo $(TEST_SUITE) | tr A-Z a-z)/... --ginkgo.focus="${FOCUS}" --ginkgo.vv
cd tools/karpenter-convert && go test -v ./pkg/... --ginkgo.focus="${FOCUS}" --ginkgo.vv

battletest: ## Run randomized, racing, code-covered tests
go test -v ./pkg/... \
-race \
-cover -coverprofile=coverage.out -outputdir=. -coverpkg=./pkg/... \
go test -v ./pkg/$(shell echo $(TEST_SUITE) | tr A-Z a-z)/... \
-cover -coverprofile=coverage.out -outputdir=. -coverpkg=./... \
--ginkgo.focus="${FOCUS}" \
--ginkgo.randomize-all \
--ginkgo.vv \
-tags random_test_delay
--ginkgo.vv
cd tools/karpenter-convert && go test -v ./pkg/... \
--ginkgo.focus="${FOCUS}" \
--ginkgo.randomize-all \
--ginkgo.vv

e2etests: ## Run the e2e suite against your local cluster
cd test && CLUSTER_ENDPOINT=${CLUSTER_ENDPOINT} \
Expand Down Expand Up @@ -106,7 +104,7 @@ benchmark:
go test -tags=test_performance -run=NoTests -bench=. ./...

deflake: ## Run randomized, racing, code-covered tests to deflake failures
for i in $(shell seq 1 5); do make battletest || exit 1; done
for i in $(shell seq 1 5); do make test || exit 1; done

deflake-until-it-fails: ## Run randomized, racing tests until the test fails to catch flakes
ginkgo \
Expand Down Expand Up @@ -209,7 +207,7 @@ update-core: ## Update karpenter-core to latest
go get -u github.com/aws/karpenter-core@HEAD
go mod tidy

.PHONY: help dev ci release test battletest e2etests verify tidy download docgen codegen apply delete toolchain licenses vulncheck issues website nightly snapshot
.PHONY: help dev ci release test e2etests verify tidy download docgen codegen apply delete toolchain licenses vulncheck issues website nightly snapshot

define newline

Expand Down
9 changes: 5 additions & 4 deletions tools/karpenter-convert/pkg/convert/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,18 +167,19 @@ func convert(resource runtime.Object, o *Context) ([]runtime.Object, error) {
case "Provisioner":
provisioner := resource.(*corev1alpha5.Provisioner)

var providerObj *v1beta1.EC2NodeClass
var err error
if provider := provisioner.Spec.Provider; provider != nil {
providerObj, err = convertProvider(provider.Raw, provisioner.Name)
providerObj, err := convertProvider(provider.Raw, provisioner.Name)
if err != nil {
return nil, fmt.Errorf("converting spec.provider for Provisioner, %w", err)
}
provisioner.Spec.ProviderRef = &corev1alpha5.MachineTemplateRef{
Name: providerObj.Name,
}

return []runtime.Object{convertProvisioner(provisioner, o), providerObj}, nil
}
return lo.WithoutEmpty([]runtime.Object{convertProvisioner(provisioner, o), providerObj}), nil

return []runtime.Object{convertProvisioner(provisioner, o)}, nil
case "AWSNodeTemplate":
nodeTemplate := resource.(*v1alpha1.AWSNodeTemplate)
nodeClass, err := convertNodeTemplate(nodeTemplate)
Expand Down
2 changes: 1 addition & 1 deletion tools/karpenter-convert/pkg/convert/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ var _ = Describe("Convert", func() {
context.FilenameOptions.Filenames = []string{"./testdata/nodetemplate_launch_template_name.yaml"}
err := context.RunConvert()
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal(`cannot convert AWSNodeTemplate with "spec.launchTemplate"`))
Expect(err.Error()).To(Equal(`converting AWSNodeTemplate, cannot convert with "spec.launchTemplate"`))
})
It("should ignore errors when converting an unknown kind alongside a valid kind", func() {
context.FilenameOptions.Filenames = []string{"./testdata/unknown_kind.yaml", "./testdata/provisioner.yaml"}
Expand Down
1 change: 0 additions & 1 deletion website/content/en/docs/contributing/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ make image # build and push the karpenter images

```bash
make test # E2E correctness tests
make battletest # More rigorous tests run in CI environment
```

### Change Log Level
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ make image # build and push the karpenter images

```bash
make test # E2E correctness tests
make battletest # More rigorous tests run in CI environment
```

### Change Log Level
Expand Down
1 change: 0 additions & 1 deletion website/content/en/v0.28/contributing/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ make build # build and push the karpenter images

```bash
make test # E2E correctness tests
make battletest # More rigorous tests run in CI environment
```

### Change Log Level
Expand Down
1 change: 0 additions & 1 deletion website/content/en/v0.29/contributing/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ make image # build and push the karpenter images

```bash
make test # E2E correctness tests
make battletest # More rigorous tests run in CI environment
```

### Change Log Level
Expand Down
1 change: 0 additions & 1 deletion website/content/en/v0.30/contributing/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ make image # build and push the karpenter images

```bash
make test # E2E correctness tests
make battletest # More rigorous tests run in CI environment
```

### Change Log Level
Expand Down
1 change: 0 additions & 1 deletion website/content/en/v0.31/contributing/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ make image # build and push the karpenter images

```bash
make test # E2E correctness tests
make battletest # More rigorous tests run in CI environment
```

### Change Log Level
Expand Down
1 change: 0 additions & 1 deletion website/content/en/v0.32/contributing/development-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ make image # build and push the karpenter images

```bash
make test # E2E correctness tests
make battletest # More rigorous tests run in CI environment
```

### Change Log Level
Expand Down

0 comments on commit 3ab813b

Please sign in to comment.