Skip to content

Conversation

@ryanzhang-oss
Copy link
Contributor

Description of your changes

Skip the serviceExport check if the neworking is not enabled.

Fixes: When trhe networking is not enabled. The list serviceExport call fails

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

Signed-off-by: Ryan Zhang <yangzhangrice@hotmail.com>
@ryanzhang-oss ryanzhang-oss requested review from Copilot and zhiying-lin and removed request for Copilot December 2, 2025 22:32
@ryanzhang-oss ryanzhang-oss changed the title fix the validation webhook fix: fix the validation webhook Dec 2, 2025
Copy link
Collaborator

@zhiying-lin zhiying-lin left a comment

Choose a reason for hiding this comment

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

Need to update our e2e join & leave tests

"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
)

func TestHandleDeleteServiceExportValidation(t *testing.T) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
func TestHandleDeleteServiceExportValidation(t *testing.T) {
func TestHandle_Delete(t *testing.T) {

nit

Comment on lines +29 to +32
networkingEnabled bool
expectAllowed bool
expectedMessageSubstr string
validationMode clusterv1beta1.DeleteValidationMode
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
networkingEnabled bool
expectAllowed bool
expectedMessageSubstr string
validationMode clusterv1beta1.DeleteValidationMode
networkingEnabled bool
validationMode clusterv1beta1.DeleteValidationMode
wantAllowed bool
wantMessageSubstr string

prefer "want" instead of expected

Where you would write “actual” and “expected”, prefer using the words “got” and “want”, respectively.

https://google.github.io/styleguide/go/decisions#got-before-want


resp := validator.Handle(context.Background(), req)
if resp.Allowed != tc.expectAllowed {
t.Fatalf("expected allowed=%t but got response: %+v", tc.expectAllowed, resp)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
t.Fatalf("expected allowed=%t but got response: %+v", tc.expectAllowed, resp)
t.Fatalf("Handle() got response: %+v, want allowed %t", resp, tc.expectAllowed)

Test outputs should output the actual value that the function returned before printing the value that was expected. A usual format for printing test outputs is “YourFunc(%v) = %v, want %v”.

https://go.dev/wiki/TestComments#got-before-want

}
if tc.expectedMessageSubstr != "" {
if resp.Result == nil || !strings.Contains(resp.Result.Message, tc.expectedMessageSubstr) {
t.Fatalf("expected message to contain %q but got: %v", tc.expectedMessageSubstr, resp.Result)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
t.Fatalf("expected message to contain %q but got: %v", tc.expectedMessageSubstr, resp.Result)
t.Fatalf("Handle() got response result: %v, want contain: %q", resp.Result, tc.expectedMessageSubstr)

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