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

fix(gwctl): prevent panic when describing gatewayclasses with no description #2894

Conversation

pmalek
Copy link
Contributor

@pmalek pmalek commented Mar 22, 2024

What type of PR is this?

/kind bug
/area gwctl

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #2849

Does this PR introduce a user-facing change?:

fix(gwctl): prevent panic when describing gatewayclasses with no description

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 22, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @pmalek. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@gauravkghildiyal
Copy link
Member

/assign

Copy link
Member

@gauravkghildiyal gauravkghildiyal left a comment

Choose a reason for hiding this comment

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

Thanks for the fix @pmalek. Just one minor thought :) (Open for discussion)

}

if gatewayClassNode.GatewayClass.Spec.Description != nil {
views = append(views, gatewayClassDescribeView{
ControllerName: string(gatewayClassNode.GatewayClass.Spec.ControllerName),
Description: *gatewayClassNode.GatewayClass.Spec.Description,
Copy link
Member

Choose a reason for hiding this comment

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

nit: Is it more neat if we simply convert Description to a *string and just directly assign:

Description: gatewayClassNode.GatewayClass.Spec.Description

Alternatively, if we really don't want a pointer, maybe the following is still slightly neater (since it keeps ControllerName out of the conditional)?

		views := []gatewayClassDescribeView{
			{
				Name: gatewayClassNode.GatewayClass.GetName(),
			},
			{
				ControllerName: string(gatewayClassNode.GatewayClass.Spec.ControllerName),
			},
		}

		if desc := gatewayClassNode.GatewayClass.Spec.Description; desc != nil {
			views = append(views, gatewayClassDescribeView{Description: *desc})
		}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to change the type but sure, why not. 9cd09fb

@pmalek pmalek force-pushed the gwctl-prevent-panic-for-gatewayclass-with-no-description branch from abb17bb to 9cd09fb Compare March 28, 2024 11:08
@gauravkghildiyal
Copy link
Member

Thank you for accommodating!

@gauravkghildiyal
Copy link
Member

/ok-to-test
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 29, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gauravkghildiyal, pmalek

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 29, 2024
@gauravkghildiyal
Copy link
Member

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 29, 2024
@gauravkghildiyal
Copy link
Member

/label tide/merge-method-squash

@k8s-ci-robot k8s-ci-robot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Mar 29, 2024
@gauravkghildiyal
Copy link
Member

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 29, 2024
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 29, 2024
@pmalek
Copy link
Contributor Author

pmalek commented Mar 29, 2024

@gauravkghildiyal I've fixed the test that was failing. PTAL

@gauravkghildiyal
Copy link
Member

Thank you!

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 30, 2024
@k8s-ci-robot k8s-ci-robot merged commit 6164ea2 into kubernetes-sigs:main Mar 30, 2024
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/gwctl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Description of GatewayClass is nil gives error in gwctl describe
3 participants