Skip to content

Reserve Static IPv6 address before syncing L4 ILB#2157

Merged
k8s-ci-robot merged 2 commits intokubernetes:masterfrom
panslava:reserve-ipv6-on-sync
Jun 22, 2023
Merged

Reserve Static IPv6 address before syncing L4 ILB#2157
k8s-ci-robot merged 2 commits intokubernetes:masterfrom
panslava:reserve-ipv6-on-sync

Conversation

@panslava
Copy link
Copy Markdown
Contributor

@panslava panslava commented May 31, 2023

This will prevent losing address while recreating forwarding rule

Tested running locally with real cluster

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 31, 2023
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels May 31, 2023
@panslava
Copy link
Copy Markdown
Contributor Author

CI will fail on vendor folder verification for now

I am waiting for vendor (GoogleCloudPlatform) to have a tag that includes addresses mocks with IPv6 GoogleCloudPlatform/k8s-cloud-provider#123

@panslava panslava force-pushed the reserve-ipv6-on-sync branch 2 times, most recently from 7b1758a to 41458ee Compare June 1, 2023 05:56
@panslava
Copy link
Copy Markdown
Contributor Author

panslava commented Jun 1, 2023

/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 Jun 1, 2023
@panslava panslava force-pushed the reserve-ipv6-on-sync branch 6 times, most recently from c7e3307 to 85d19d9 Compare June 7, 2023 21:59
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 7, 2023
@panslava panslava force-pushed the reserve-ipv6-on-sync branch 2 times, most recently from 6aee662 to b09b781 Compare June 7, 2023 23:00
@cezarygerard
Copy link
Copy Markdown
Contributor

Is it even supported on GCP public APIs?

@panslava
Copy link
Copy Markdown
Contributor Author

@cezarygerard yes, it was added recently, and now all of these code api calls are supported (I verified)

@panslava
Copy link
Copy Markdown
Contributor Author

/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 Jun 13, 2023
@panslava panslava force-pushed the reserve-ipv6-on-sync branch from b09b781 to bac5dc3 Compare June 21, 2023 01:04
@panslava
Copy link
Copy Markdown
Contributor Author

/assign cezarygerard

@cezarygerard
Copy link
Copy Markdown
Contributor

are you going to implement the same for L4NET LB?

@panslava
Copy link
Copy Markdown
Contributor Author

@cezarygerard yes #2165

// Release the address that was reserved, in all cases. If the forwarding rule was successfully created,
// the ephemeral IP is not needed anymore. If it was not created, the address should be released to prevent leaks.
if err := ipv6AddrMgr.ReleaseAddress(); err != nil {
klog.Errorf("EnsureInternalLoadBalancer: failed to release IPv6 address reservation, possibly causing an orphan: %v", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be an event?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure..... I am not 100% sure if this does not return false positive errors, which we don't want to return to customers and scare them

// the ephemeral IP is not needed anymore. If it was not created, the address should be released to prevent leaks.
if err := addrMgr.ReleaseAddress(); err != nil {
klog.Errorf("EnsureInternalLoadBalancer: failed to release address reservation, possibly causing an orphan: %v", err)
klog.Errorf("EnsureInternalLoadBalancer: failed to release IPv4 address reservation, possibly causing an orphan: %v", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should be an event?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not sure..... I am not 100% sure if this does not return false positive errors, which we don't want to return to customers and scare them

defer func() {
// Release the address that was reserved, in all cases. If the forwarding rule was successfully created,
// the ephemeral IP is not needed anymore. If it was not created, the address should be released to prevent leaks.
if err := ipv6AddrMgr.ReleaseAddress(); err != nil {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

what if customer reserved ip before and created the service with this ip?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

ReleaseAddress() deletes only controller managed address. Controller created address will have the same name as forwarding rule name, so controller will try to delete address with this name. If it was custom static address owned by customer -- controller will not delete it (nit: as long as customer didn't use forwarding rule name for their address)

return l4.deleteFirewall(ipv6FirewallName)
}

func (l4 *L4) getOldIPv6ForwardingRule(existingBS *composite.BackendService) (*composite.ForwardingRule, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

no tests for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There is a test TestDualStackInternalLoadBalancerModifyProtocol which verifies the whole flow where this functions is useful, that we reserve IP address when protocol is changed

Though, if you think it would be useful, I can add a test specifically for this function, but I would say this is more a private helper function, that just abstracts functionality for readability

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

leave it as is

panslava added 2 commits June 21, 2023 23:53
This will prevent losing address while recreating forwarding rule
@panslava panslava force-pushed the reserve-ipv6-on-sync branch from bac5dc3 to 9e2d9b1 Compare June 21, 2023 23:59
@cezarygerard
Copy link
Copy Markdown
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 22, 2023
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cezarygerard, panslava

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [cezarygerard,panslava]

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 merged commit d7770ae into kubernetes:master Jun 22, 2023
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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants