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

Adding a Runtime class resource #2080

Merged
merged 11 commits into from
May 5, 2023
Merged

Adding a Runtime class resource #2080

merged 11 commits into from
May 5, 2023

Conversation

sheneska
Copy link
Contributor

@sheneska sheneska commented Apr 17, 2023

Description

Added a runtime class resource (with handler attribute only for now) & wrote test file that asserts for only the creating a runtime class step

Acceptance tests

  • Have you added an acceptance test for the functionality being added?
  • Have you run the acceptance tests on this branch?

Output from acceptance testing:

$ make testacc TESTARGS="-count 1 -run ^TestAccKubernetesruntime_class_v1_basic"

TF_ACC=1 go test "/Users/sacha/Documents/code/hashicorp/terraform-provider-kubernetes/kubernetes" -v -count 1 -run ^TestAccKubernetesruntime_class_v1_basic -timeout 3h
=== RUN   TestAccKubernetesruntime_class_v1_basic
--- PASS: TestAccKubernetesruntime_class_v1_basic (5.24s)
PASS
ok  	github.com/hashicorp/terraform-provider-kubernetes/kubernetes	6.160s

Release Note

Release note for CHANGELOG:

`resource/kubernetes_runtime_class_v1`: Add a new resource `kubernetes_runtime_class_v1`.

References

Fix: #1114

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Copy link
Contributor

@arybolovlev arybolovlev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, @sheneska!

I have left a few comments regarding the acceptance tests. Once you address them, please make sure that they pass on your local cluster:

$ make testacc TESTARGS="-count 1 -run ^TestAccKubernetesruntime_class_v1_basic"

Please add the changelog file .changelog/2080.txt.

Let me know if you have any questions or need any assistance. Thanks!

@arybolovlev arybolovlev self-requested a review April 21, 2023 13:14
@sheneska sheneska requested a review from BBBmau April 24, 2023 17:27
@sheneska sheneska marked this pull request as ready for review April 25, 2023 16:32
@sheneska sheneska requested a review from a team as a code owner April 25, 2023 16:32
BBBmau
BBBmau previously requested changes Apr 25, 2023
Copy link
Contributor

@BBBmau BBBmau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good, just left some things to add such as Docs and adding pod tests

website/docs/r/runtime_class_v1.html.markdown Show resolved Hide resolved
metadata {
name = %q
}
handler = "myclass"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we use the runtime class resource with pods, we should have a pod using a runtimeclass resource as part of the tests.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to create a Pod to actually test that this resource works. A RuntimeClass can exist without any Pods using it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jrhouston wouldn't we want to have a test that checks that it works as expected with a Pod? I left this suggestion since not having a proper handler value would result in the Pod not being created. We could always have a message that informs the user what values to use to prevent this from happening.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The schema already has validation for the handler field so they will get an error message if the handler value is not in the proper format.

Other than that the API server doesn't produce any error if you supply a handler that doesn't exist on the node. So we don't really have a way of informing them that they've specified a bad handler value.

Copy link
Collaborator

@jrhouston jrhouston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering about overhead and scheduling being missing – otherwise this looks good 🚀


Schema: map[string]*schema.Schema{
"metadata": metadataSchema("runtimeclass", true),

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sacha had recommended that i focus on the handler at first and get it working perfectly, he also mentioned that since the handler is will be the most commonly used we should merge this first and then add overhead and scheduling afterwards

Type: schema.TypeString,
Description: "Specifies the underlying runtime and configuration that the CRI implementation will use to handle pods of this class",
Required: true,
ValidateFunc: validation.StringMatch(regexp.MustCompile(`^[a-z0-9]([-a-z0-9]*[a-z0-9])?`), ""),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kubernetes actually has a utility function to validate RFC 1123 DNS labels: https://pkg.go.dev/k8s.io/apimachinery/pkg/util/validation#IsDNS1123Label

So we don't need to roll our own regex here.

@jrhouston jrhouston removed the request for review from arybolovlev May 4, 2023 17:18
@jrhouston jrhouston dismissed stale reviews from BBBmau and arybolovlev May 4, 2023 17:18

Done

@sheneska sheneska merged commit 73e2558 into main May 5, 2023
@sheneska sheneska deleted the runtime-class branch May 5, 2023 13:43
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RuntimeClass Resource
4 participants