106 Commits

Author SHA1 Message Date
Aaron U'Ren
4b6cf6c896 fact(protocol): standardize protocol conversions 2022-02-11 17:34:10 -06:00
Aaron U'Ren
28aab6ea20 fact(service_endpoints_sync): simplify external IP logic
This is an attempt to make the external IP logic easier to follow and
more straight forward for future changes like consolidating the iptables
logic.
2022-02-11 17:34:10 -06:00
noillir
d27c317891
change to account for internet headers also when setting MSS (#1232)
Co-authored-by: noillir <miq@noillir.eu>
2022-02-02 15:46:18 -06:00
Aaron U'Ren
b74689785a
feat(nsc): only hairpin endpoints on local node (#1208) 2021-12-10 23:19:20 +05:30
Aaron U'Ren
2ca39f14f8 fix(nsc): properly check hairpinning rule
Previously, we would iterate over rulesFromNode, but then check it
against the entirety of the rulesNeeded hash. This resulted in the loop
breaking as soon as it found any matching rule from the host rather than
it breaking if it matched the rule that we were currently processing.
2021-12-03 11:02:55 -06:00
Aaron U'Ren
146786ad8a fix(nsc): sync hairpinning on service modification
When we receive service or endpoint updates from Kubernetes we process a
type of partial sync because the service and endpoints have already been
updated by the handler. However, previously, this partial update did not
include updating the hairpinning rules for services.

This would cause hairpinning changes to be delayed until the next full
sync or until kube-router restart. This changes adds hairpinning into
the partial service sync flow.
2021-12-03 11:02:55 -06:00
Aaron U'Ren
8f13f069b6 fix(nsc): don't overwrite err & add comments 2021-12-03 11:02:55 -06:00
Aaron U'Ren
5101a4fe81 fix(nsc): remove error for lookupFWMarkByService
lookupFWMarkByService() was previous returning an error when no fwmark
was found in the tracking map for a given service. However, this isn't
really an error condition and shouldn't be treated as such. When it was
treated as an error condition users got a lot of confusing errors in the
logs.
2021-12-03 11:49:28 +01:00
Kailun
bee2c2089f
fix bug when adding ip rule for fwmark (#1178)
Co-authored-by: Kailun Shi <kailun.shi@bytedance.com>
2021-11-05 18:42:24 +05:30
Aaron U'Ren
c3f90c54b3
Fix Misc DSR Issues (#1174)
* fact(NSC): consolidate constants to top

* fix(NSC): increase IPVS add service logging

* fix(NSC): improve logging for FWMark IPVS entries

* fix(NSC): add missing parameter to logging

* feat(NSC): generate unique FW marks

Because we trim the 32-bit FNV-1a hash to 16 bits there is the potential
for FW marks to collide with each other even for unique inputs of IP,
protocol, and port. This reduces that chance up to the 16-bit max by
keeping track of which FW marks we've already allocated and what IP,
protocol, port combo they've been allocated for.

Fixes #1045

* fact(NSC): move utility funcs to utils

* fix(NSC): reduce IPVS service shell outs

This also aligns it more with the almost identical function used for
non-FWmarked services ipvsAddService() which is also called from
setupExternalIPServices and passes in this same list of ipvsServices.

* fix(NSC): fix & consolidate DSR cleanup code

A lot of this is refactor work, but its important to know why the DSR
mangle tables were not being cleaned up in the first place. When we
transitioned to iptables-save to look over the mangle rules, we didn't
realize that iptables-save changes the format of the marks from integer
values (which is what the CLI works with) to hexadecimal.

This made it so that we were never actually matching on a mangle rule,
which left them all behind. When these mangle rules were left, it meant
that IPs that used to be part of a DSR service were essentially
black-holed on the system and were no longer route-able.

Fixes #1167

* doc(dsr): expand DSR documentation

fixes #1055

* ensure active service map is updated for non DSR services

Co-authored-by: Murali Reddy <muralimmreddy@gmail.com>
2021-10-14 16:14:05 +05:30
Aaron U'Ren
8572f3a17f fact(hairpin): remove one last direct ref of KUBE-ROUTER-HAIRPIN 2021-09-13 17:39:28 -05:00
Aaron U'Ren
5e1d033a44 fix(sysctl): revert is fatal check for some conditions 2021-09-13 17:39:28 -05:00
Aaron U'Ren
feb16d0d0b doc(NSC): add some comments around DSR 2021-09-11 16:20:07 -05:00
Aaron U'Ren
8f3861de40 fact(sysctl): consolidate sysctl usage into utils 2021-09-11 16:20:07 -05:00
Aaron U'Ren
da5f8e0044 fix: address minor PR feedback and misspells 2021-09-11 16:20:07 -05:00
Aaron U'Ren
1d90e215e9 feat(.golangci.yml): enable stylecheck linter and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
85f28411dc feat(.golangci.yml): enable long lines linter and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
874a746e30 feat(.golangci.yml): enable gosec and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
6208bfac46 feat(.golangci.yml): enable gomnd and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
f52fddddee feat(.golangci.yml): enable gocritic and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
d6ccc22519 feat(.golangci.yml): enable goconst and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
c5f4c00d63 feat(.golangci.yml): enable dupl and remediate 2021-09-11 16:20:07 -05:00
Aaron U'Ren
35d334ca96 fix: add sleeps between iptables and ipset cleanup
I found that without taking a brief pause between iptables cleanup and
ipset deletion, sometimes the system still thought that there were
iptables references to the ipsets and would error instead of cleaning
the ipsets.
2021-08-05 16:39:28 -05:00
Aaron U'Ren
fb070265a2 fix(NSC): actually remove IPVS definitions 2021-08-05 16:39:28 -05:00
Aaron U'Ren
bbc0666a4c fix(NSC): add exists checking to Cleanup() 2021-08-05 16:39:28 -05:00
Billie Cleek
d5a18cac67
remove IPVS metrics (#1133)
* remove IPVS metrics

Remove metrics for IPVS services when the IPVS service is deleted so
that the number of metrics does not grow without bound.

Fixes #734

* delete metricsMap key when IPVS service is removed

Delete the key in NetworkServicesController.metricsMap when the
respective IPVS configuration is removed.

Remove a period from a comment to conform to kube-router norms

* cleanup stale metrics in a distinct method

* remove unnecessary error return value on cleanupStaleMetrics
2021-07-31 01:25:58 +05:30
Aaron U'Ren
e9be04ef2f
fix: add nil checking to ipsetMutex cleanup actions (#1129) 2021-07-20 01:22:48 +05:30
Aaron U'Ren
fa8d69edd8 fix: add locking around ipset invocations 2021-06-01 10:42:08 -05:00
Aaron U'Ren
4306e5d47c feat(DSR): make TCPMSS based on primary link MTU 2021-05-17 16:33:15 -05:00
icefed
e223ea80a1 Fix DSR(tunneling) mode mtu limit
https://github.com/cloudnativelabs/kube-router/issues/630
2021-05-17 16:33:15 -05:00
Alexander "Ananace" Olofsson
bd5ee4f708
fix(nsc): Overly eager IPVS updating
* fix(nsc): Overly eager IPVS updating

Switches the endpoint map comparison in OnEndpointsUpdate from being a
DeepEqual, to instead checking that all services exist, and that their
associated endpoints are similar.

Ordering is no longer considered important in regards to the IPVS
update check.

Fixes #1026
2021-04-21 17:25:16 -05:00
Manuel Rüger
8d4731737a moq: Regenerate 2021-04-20 16:53:49 -05:00
Aaron U'Ren
be01f317c7 fact: other misc cleanups 2021-04-14 16:23:59 -05:00
Aaron U'Ren
53cfbe30eb fix: return early when we might be holding nil references 2021-04-14 16:23:59 -05:00
Aaron U'Ren
4efa5ccc48 fact: remove function parameters that are never referenced 2021-04-14 16:23:59 -05:00
Aaron U'Ren
a86b3fad35 fact: handle errors from Close() explicitely 2021-04-14 16:23:59 -05:00
Aaron U'Ren
57ddac3a57 fact(NSC): consolidate repeat logic 2021-04-14 16:23:59 -05:00
Aaron U'Ren
96675e620b fix: don't capitalize error messages
It is standard practice in Go to not capitalize error messages:
https://github.com/golang/go/wiki/CodeReviewComments#error-strings
2021-04-14 16:23:59 -05:00
Aaron U'Ren
e9c77d0a35 fix(comments): misspellings and bad doc strings 2021-04-14 16:23:59 -05:00
bazuchan
46f54e964f
Fix PMTU discovery for service IPs (#733) 2021-04-11 19:28:52 -05:00
Aurélien Dunand
5fc39db6a0 Add hairpin support for externalIps
Add an extra annotation for service in order to generate haipin related
iptables rules for externalsIps of the service.
2021-04-11 17:27:03 -05:00
Manuel Rüger
7d47aefe7d Replace github.com/golang/glog with k8s.io/klog/v2
glog is effectively unmaintained and the kubernetes ecosystem is mainly
using its fork klog

Fixes: #1051
2021-04-11 13:16:03 -05:00
Murali Reddy
c309b276ae skip logging Error when there is no Service object for an Endpoint 2021-03-24 14:30:27 -05:00
Aaron U'Ren
43c3c9de86
Handle headless services (#1047)
* doc(ecmp_vip.go): add info around extra withdraw

Rename getWithdraw to make it more explicit what its doing here. Also
add documentation as to why this is needed on Update and not
Create/Delete as well as why we only treat externalIPs.

* fix(ecmp_vip.go): remove superfluous AddPolicies

AddPolicies is already called downstream of nrc.OnEndpointsUpdate() so
there is no need to do it here as well, the only result is that this
expensive operation and idempotent operation is run twice.

* feat: better handling of headless services

Also introduces a consolidated Service utilities section for controller
functionality related to services that is shared.

* fix: add logging back to tryHandleServiceDelete
2021-03-24 08:31:39 +05:30
Murali Reddy
d1e1923b63 prevent iptable command calls when necessary rules already exists 2021-03-18 09:21:22 -05:00
ep4eg
ca2008e576
feat: simple CRI implementation in addition to Docker, required for DSR functionality. CRI compliant runtimes support (e.g. containerd, cri-o, etc.) (#1027)
* feat: simple CRI implementation in addition to Docker, required for DSR functionality. CRI compliant runtimes support (e.g. containerd, cri-o, etc.)

* upd: dependencies

* cleanup

* feat: cleanup gRPC connections after we did the job

* upd: go.sum
2021-02-08 20:04:13 +05:30
Murali Reddy
54b921f1f8 Merge remote-tracking branch 'iamakulov/master' 2021-01-04 16:56:41 +05:30
Philipp Schleier
fd5af1823f Cleanup non-DSR externalIPs 2020-10-16 18:01:27 -05:00
Murali Reddy
3c734fb96a
merge gobgp-update into master (#982)
* merge gobgp-update into master

* update travis.yaml go version:

* go get github.com/osrg/gobgp to build gobgp

* install git as go get needs it
2020-09-07 10:27:58 +05:30
Aaron U'Ren
c6ef3b8876
Merge pull request #975 from mrueg/conv-fix
Fix unnecessary conversions
2020-08-21 16:07:41 -05:00