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

l2: exclude common virtual interfaces for announce services #1767

Merged
merged 1 commit into from Mar 20, 2023

Conversation

cyclinder
Copy link
Contributor

@cyclinder cyclinder commented Jan 5, 2023

In arp mode, Some common virtual interfaces should not be used to announce services, such as kube-ipvs0, docker0, etc. This PR will dispatch these common virtual interfaces.

Signed-off-by: cyclinder qifeng.guo@daocloud.io

#1727

l2: exclude common virtual interfaces for announce services.

internal/layer2/announcer.go Outdated Show resolved Hide resolved
internal/layer2/announcer.go Outdated Show resolved Hide resolved
internal/layer2/announcer.go Outdated Show resolved Hide resolved
internal/layer2/announcer.go Outdated Show resolved Hide resolved
@fedepaol
Copy link
Member

cc @oribon @gclawes want to hear your thoughts about this

@oribon
Copy link
Member

oribon commented Jan 19, 2023

the idea seems good but maybe having it as a configmap is better
also, if someone has an interface selector that selects one of these will this "global exclude" override it? (might be unrelated, need to revisit the l2 code)

@fedepaol
Copy link
Member

So, let's move this forward but let's have the list overrideable and not hardcoded. A configmap read upon start is good enough imo, no need to handle the live reload.

@fedepaol
Copy link
Member

So, let's move this forward but let's have the list overrideable and not hardcoded. A configmap read upon start is good enough imo, no need to handle the live reload.

Wdyt @cyclinder ?

@cyclinder
Copy link
Contributor Author

So, let's move this forward but let's have the list overrideable and not hardcoded. A configmap read upon start is good enough imo, no need to handle the live reload.

I think both are ok, but I prefer hardcoded :)

First of all, it shouldn't be related to the current interface-selector, it's more of a global-exclude list, right? If it is a configmap, I think this will increase its complexity. 🤔

@fedepaol
Copy link
Member

So, let's move this forward but let's have the list overrideable and not hardcoded. A configmap read upon start is good enough imo, no need to handle the live reload.

I think both are ok, but I prefer hardcoded :)

First of all, it shouldn't be related to the current interface-selector, it's more of a global-exclude list, right? If it is a configmap, I think this will increase its complexity. thinking

right, it must be independent and always applied, more or less as your current logic is but loading that list from a configmap when the process starts instead of having it hardcoded. This will help us to avoid releases when users hit a corner case we didn't think about

@cyclinder
Copy link
Contributor Author

@fedepaol got it. I try to working on this.

@cyclinder
Copy link
Contributor Author

Hi @fedepaol , Could you mind having a review? Thanks. It seems this CI failing isn't related to this changes.

@fedepaol
Copy link
Member

fedepaol commented Feb 8, 2023

Hi @fedepaol , Could you mind having a review? Thanks. It seems this CI failing isn't related to this changes.

yup, will do soon-ish (and I have an outstanding pr to fix the ci)

config/manifests/metallb-frr-prometheus.yaml Outdated Show resolved Hide resolved
internal/layer2/announcer.go Outdated Show resolved Hide resolved
@cyclinder
Copy link
Contributor Author

cyclinder commented Feb 27, 2023

I made some testing base on these changes on my local, It works well, as speaker log shown below:

➜  metallb git:(l2ann) ✗ kubectl get po -n metallb-system         
NAME                          READY   STATUS    RESTARTS   AGE
controller-76f86696dd-xznhb   0/1     Running   0          6s
speaker-ccqtb                 0/1     Running   0          4s
speaker-pzznd                 0/1     Running   0          5s
speaker-vsd9l                 0/1     Running   0          4s
➜  metallb git:(l2ann) ✗ kubectl logs -f -n metallb-system speaker-ccqtb 
{"branch":"l2ann","caller":"main.go:97","commit":"f56103a5-dirty","goversion":"gc / go1.18.3 / amd64","level":"info","msg":"MetalLB speaker starting (commit f56103a5-dirty, branch l2ann)","ts":"2023-02-27T09:16:35Z","version":""}
{"caller":"main.go:148","interfacesToExclude":["docker.*","cbr.*","dummy.*","virbr.*","lxcbr.*","veth.*","lo","^cali.*","^tunl.*","flannel.*","kube-ipvs.*","cni.*","^nodelocaldns.*"],"level":"error","op":"show the list of interfaces that announce to exclude","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"lo","level":"info","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"tunl0","level":"info","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth313c8572","level":"info","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth24b1f795","level":"info","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth8013fa28","level":"info","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:134","event":"createARPResponder","interface":"eth0","level":"info","msg":"created ARP responder for interface","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:143","event":"createNDPResponder","interface":"eth0","level":"info","msg":"created NDP responder for interface","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:134","event":"createARPResponder","interface":"eth1","level":"info","msg":"created ARP responder for interface","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:143","event":"createNDPResponder","interface":"eth1","level":"info","msg":"created NDP responder for interface","ts":"2023-02-27T09:16:35Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth24b1f795","level":"info","ts":"2023-02-27T09:16:45Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth8013fa28","level":"info","ts":"2023-02-27T09:16:45Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"lo","level":"info","ts":"2023-02-27T09:16:55Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"tunl0","level":"info","ts":"2023-02-27T09:16:55Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth313c8572","level":"info","ts":"2023-02-27T09:16:55Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth24b1f795","level":"info","ts":"2023-02-27T09:16:55Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth8013fa28","level":"info","ts":"2023-02-27T09:16:55Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"lo","level":"info","ts":"2023-02-27T09:17:05Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"tunl0","level":"info","ts":"2023-02-27T09:17:05Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth313c8572","level":"info","ts":"2023-02-27T09:17:05Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth24b1f795","level":"info","ts":"2023-02-27T09:17:05Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth8013fa28","level":"info","ts":"2023-02-27T09:17:05Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"lo","level":"info","ts":"2023-02-27T09:17:15Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"tunl0","level":"info","ts":"2023-02-27T09:17:15Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth313c8572","level":"info","ts":"2023-02-27T09:17:15Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth24b1f795","level":"info","ts":"2023-02-27T09:17:15Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth8013fa28","level":"info","ts":"2023-02-27T09:17:15Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"lo","level":"info","ts":"2023-02-27T09:17:25Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"tunl0","level":"info","ts":"2023-02-27T09:17:25Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth313c8572","level":"info","ts":"2023-02-27T09:17:25Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth24b1f795","level":"info","ts":"2023-02-27T09:17:25Z"}
{"caller":"announcer.go:85","event":"announced interface to exclude","interface":"veth8013fa28","level":"info","ts":"2023-02-27T09:17:25Z"}

Could you mind taking a look? Thanks :) @fedepaol

speaker/main.go Outdated
@@ -51,6 +52,8 @@ var announcing = prometheus.NewGaugeVec(prometheus.GaugeOpts{
"ip",
})

var defaultConfigPath = "/etc/metallb/conf.yaml"
Copy link
Member

Choose a reason for hiding this comment

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

nit: this doesn't have to be a var, could be a const. Also, I'd use the presence of the file instead of the boolean to understand if we need to enable the mechanism. Maybe that's where we want to override the path? But I think it's fair to have it hardcoded.

Also also, I'd do all the parsing in one shot and have the parse function return the regexp, so we have all the logic in one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It would be better if we provide a flag to override the path, It's good for helm install

when the value is empty in values.yaml: We don't create configMap, and we don't mount the file...

When the value is not empty and the file exists, we enable this mechanism, Is it ok?

Copy link
Contributor Author

@cyclinder cyclinder Mar 9, 2023

Choose a reason for hiding this comment

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

In addition , I think all the configurations here(

type controllerConfig struct {
), should be declared in one place(in a configMap) so that it is easy to configure and update, how about this?

Copy link
Member

Choose a reason for hiding this comment

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

I still don't see the value in setting passing the name as a parameter. It can be a convention.
If we don't want the file, we don't create the volume and the configmap, the load of the file will fail and we won't override.

Copy link
Member

Choose a reason for hiding this comment

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

In addition , I think all the configurations here(

type controllerConfig struct {

), should be declared in one place(in a configMap) so that it is easy to configure and update, how about this?

I don't like this approach, having flags give a better understanding of what's being passed to the process and that's what people expect. Configmaps for knobs are fine if they are tweaks that are not normally expected to be used.

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 don't like this approach, having flags give a better understanding of what's being passed to the process and that's what people expect. Configmaps for knobs are fine if they are tweaks that are not normally expected to be used.

OK, Thanks for the reply. I just had a whim, please ignore my thoughts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we don't want the file, we don't create the volume and the configmap, the load of the file will fail and we won't override.

I currently read the env to determine if this mechanism is enabled and if the value is not empty and the file exists then it is enabled. The -set .speaker.excludeInterfaces.configPath flag is used when the helm install. The default configPath is '/etc/metallb/conf.yaml', if it is empty, it is not enabled.

Do you mean we don't need to expose env to enable this mechanism?

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 still don't see the value in setting passing the name as a parameter.

The benefit of this is that we can decide whether to enable this mechanism when helm install

Copy link
Member

Choose a reason for hiding this comment

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

we can still decide, we set a parameter in helm that drives the creation of the volume and the related configmap (and by default I'd create them). If those are not created, the go code will land in the notexists error and will not parse the map. Or I am missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, That's what the PR does. The difference is that now this parameter is a string, indicating the config path to the file. Or should this be a boolean type? Then we hardcode the config file path in go code.

@fedepaol
Copy link
Member

fedepaol commented Mar 1, 2023

sorry for the delay, left one last comment (I hope). I think the boolean parameter is not necessary as we are using a fixed path by convention, so we can rely on the presence or the absence of the file to drive the parsing

speaker/main.go Outdated Show resolved Hide resolved
@fedepaol
Copy link
Member

Did one last minute change about naming directly on your branch.
LGTM

@cyclinder cyclinder force-pushed the l2ann branch 2 times, most recently from 80df3af to fe297f5 Compare March 19, 2023 03:34
In arp mode, Some common virtual interfaces should not be used to announce services, such as kube-ipvs0, docker0, etc. This PR will dispatch these common virtual interfaces.

Signed-off-by: cyclinder <qifeng.guo@daocloud.io>
@fedepaol
Copy link
Member

There was a nit confgmap.yaml

@fedepaol fedepaol enabled auto-merge March 20, 2023 08:52
@cyclinder
Copy link
Contributor Author

There was a nit confgmap.yaml

Thanks, Does CI Failling is related to these changes?

@fedepaol
Copy link
Member

There was a nit confgmap.yaml

Thanks, Does CI Failling is related to these changes?

nope, it's related to the operator not being updated to the latest frr yet (this PR: metallb/metallb-operator#328)

We can ignore the failure for now.

@fedepaol fedepaol added this pull request to the merge queue Mar 20, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to no response for status checks Mar 20, 2023
@fedepaol fedepaol added this pull request to the merge queue Mar 20, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 20, 2023
@fedepaol fedepaol added this pull request to the merge queue Mar 20, 2023
@fedepaol fedepaol merged commit ebc875a into metallb:main Mar 20, 2023
23 of 24 checks passed
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.

None yet

3 participants