Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug(nodeadm): run validation in config check #2138

Merged
merged 1 commit into from
Feb 5, 2025

Conversation

ndbaker1
Copy link
Member

@ndbaker1 ndbaker1 commented Feb 5, 2025

Issue #, if available:

mentioned in #2123

Description of changes:

The nodeadm config check command validates the document can be parsed, but if it is incorrectly formatted or missing data then fields are left empty and the command still reports the config is valid.

This PR adds the same validation call to the parsed NodeConfig in config check and in the init command.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Testing Done

cat << EOF > test.yaml
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="//"

--//
Content-Type: application/node.eks.aws

---
APIVersion: node.eks.aws/v1alpha1
Kind: NodeConfig

--//--
EOF

# before
> go run ./cmd/nodeadm/main.go config check -c file://../test.yaml
{"level":"info","ts":1738745826.997185,"caller":"config/check.go:27","msg":"Checking configuration","source":"file://../test.yaml"}
{"level":"info","ts":1738745826.9985948,"caller":"config/check.go:36","msg":"Configuration is valid"}

# after
> go run ./cmd/nodeadm/main.go config check -c file://../test.yaml
{"level":"info","ts":1738745868.4194193,"caller":"config/check.go:28","msg":"Checking configuration","source":"file://../test.yaml"}
{"level":"fatal","ts":1738745868.420988,"caller":"nodeadm/main.go:36","msg":"Command failed","error":"Name is missing in cluster configuration","stacktrace":"main.main\n\t/home/nbakerd/workspace/ami/nodeadm/cmd/nodeadm/main.go:36\nruntime.main\n\t/home/nbakerd/go/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:272"}

See this guide for recommended testing for PRs. Some tests may not apply. Completing tests and providing additional validation steps are not required, but it is recommended and may reduce review time and time to merge.

@cartermckinnon cartermckinnon merged commit cc55092 into awslabs:main Feb 5, 2025
11 checks passed
@cartermckinnon
Copy link
Member

Thanks @ndbaker1!

@ndbaker1 ndbaker1 deleted the check-fix branch February 5, 2025 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants