Skip to content

Conversation

@Qqkyu
Copy link
Contributor

@Qqkyu Qqkyu commented Oct 21, 2025

Added logic similar to the kubetest(1) --gke-create-nat flag (crucial for tests running in private clusters).

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 21, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @Qqkyu. Thanks for your PR.

I'm waiting for a github.com 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 21, 2025
@Qqkyu
Copy link
Contributor Author

Qqkyu commented Oct 21, 2025

cc: @BenTheElder @aojea

@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Oct 21, 2025
Comment on lines 62 to 70
if errNat != nil {
return errNat
}
if err := d.DeleteSubnets(d.retryCount); err != nil {
return err
if errNetwork != nil {
return errNetwork
}
if errSubnets != nil {
return errSubnets
}
Copy link
Contributor

Choose a reason for hiding this comment

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

you can now aggregate in the std library
errs := errors.Join(errNat, errNetwork, errSubnets)
if errs != nil {
return errs
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, done

@aojea
Copy link
Contributor

aojea commented Oct 22, 2025

/ok-to-test

@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. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 22, 2025
}
region := regionFromLocation(d.Regions, d.Zones, d.retryCount)
nat := d.getNatName()
hostProject := d.Projects[0]
Copy link
Contributor

Choose a reason for hiding this comment

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

is it always in the first project?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a common assumption throughout the codebase, for example in firewall.go ensureFirewallRulesForMultiProjects:

func (d *Deployer) ensureFirewallRulesForMultiProjects() error {
	hostProject := d.Projects[0]
        ...

But also in multiple places in network.go

Comment on lines 59 to 61
errNat := d.CleanupNat()
errNetwork := d.TeardownNetwork()
errSubnets := d.DeleteSubnets(d.retryCount)
Copy link
Contributor

Choose a reason for hiding this comment

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

keep the check on the error to just logging the error as above, that is useful

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 28, 2025
@aojea
Copy link
Contributor

aojea commented Oct 29, 2025

better to have a clean rebase without the merge commit, there are some comments also , then it lgtm

Comment on lines 58 to 70
if err := d.CleanupNat(); err != nil {
klog.Errorf("Error cleaning-up nat: %v", err)
}

if err := d.TeardownNetwork(); err != nil {
return err
klog.Errorf("Error tearing-down network: %v", err)
}

if err := d.DeleteSubnets(d.retryCount); err != nil {
return err
klog.Errorf("Error deleting subnets: %v", err)
}

return d.DeleteNetwork()
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we need to aggregate the errors and return the final error?
I suggested to log but does not affect if we swallow the error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I misinterpreted previous comment. Changed it so that we log and aggregate errors now. Does this work?

Comment on lines +30 to +31
if d.Network == "default" {
return fmt.Errorf("NAT router should be set manually for the default network")
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So my understanding is that using custom networks for test environments is best practice as it provides isolation and control over resources, like nat and firewalls (reason why in EnsureFirewallRules we've got the same check). Cleaning up test-specific resources on the default network could become difficult/messy

Copy link
Contributor

Choose a reason for hiding this comment

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

the EnsureFirewallRules has

	// Do not modify the firewall rules for the default network
	if d.Network == "default" {
		return nil
	}

so, it is better to fail on validation of the flags that at runtime, specially for these options.

Do we have more clear the use case for enabling the nat creation or are we just trying to map 1 to 1 options?

@Qqkyu
Copy link
Contributor Author

Qqkyu commented Oct 30, 2025

/retest

@Qqkyu
Copy link
Contributor Author

Qqkyu commented Nov 7, 2025

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Qqkyu

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 Nov 7, 2025
@Qqkyu
Copy link
Contributor Author

Qqkyu commented Nov 7, 2025

/lgtm

@k8s-ci-robot
Copy link
Contributor

@Qqkyu: you cannot LGTM your own PR.

In response to this:

/lgtm

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-sigs/prow repository.

@Qqkyu
Copy link
Contributor Author

Qqkyu commented Nov 7, 2025

@aojea any other comments/suggestions? If not, can you give an lgtm here and we can merge this?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 13, 2025
@Qqkyu Qqkyu force-pushed the gke-deployer-add-create-nat-flag branch from c4847c0 to 2ee9260 Compare November 13, 2025 08:14
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 13, 2025
@Qqkyu
Copy link
Contributor Author

Qqkyu commented Dec 8, 2025

Bump @aojea @upodroid

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants