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

feature(no_network) Add an option to disable any network activity on the NIC #128

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

johnsudaar
Copy link

  • Add NoNetwork option that prevent any Gratuitous ARP burst and the addition/removal of the IP on the NIC
  • Add the update command on the link client that let's user customize VIP options

This is a first step toward #97 a next step would be to implements hooks on the FAILING, STANDBY and ACTIVATED state

…the NIC

* Add NoNetwork option that prevent any Gratuitous ARP burst and the addition/removal of the IP on the NIC
* Add the update command on the link client that let's user customize VIP options

This is a first step toward #97 a next step would be to implements hooks on the FAILING, STANDBY and ACTIVATED state
Copy link
Member

@EtienneM EtienneM left a comment

Choose a reason for hiding this comment

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

I'm still submitting my review as it was pending for some times now. I am still not convinced we want to add this feature. This "no-network" flag seems confusing, I'm not fond of it. Maybe @Soulou has an opinion on that matter?

Flags: []cli.Flag{
cli.BoolFlag{
Name: "no-network",
Usage: "Disable any operation on the network interface",
Copy link
Member

Choose a reason for hiding this comment

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

I find this option so counterintuitive that I would add in the usage an example of why one would want to call it. WDYT?

cli.BoolFlag{
Name: "no-network",
Usage: "Disable any operation on the network interface",
},
},
Action: func(c *cli.Context) error {
if c.NArg()%2 == 0 {
Copy link
Member

Choose a reason for hiding this comment

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

Is this condition still working with the flag no-network?

Comment on lines +185 to +194
var noNetwork bool
if c.Bool("no-network") {
noNetwork = true
updateParams.NoNetwork = &noNetwork
}

if c.Bool("network") {
noNetwork = false
updateParams.NoNetwork = &noNetwork
}
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: I don't think you need to declare it outside the conditions:

Suggested change
var noNetwork bool
if c.Bool("no-network") {
noNetwork = true
updateParams.NoNetwork = &noNetwork
}
if c.Bool("network") {
noNetwork = false
updateParams.NoNetwork = &noNetwork
}
if c.Bool("no-network") {
noNetwork := true
updateParams.NoNetwork = &noNetwork
}
if c.Bool("network") {
noNetwork := false
updateParams.NoNetwork = &noNetwork
}

@@ -27,12 +27,14 @@ type Manager interface {
Status() string
IP() models.IP
SetHealthchecks(context.Context, config.Config, []models.Healthcheck)
UpdateIP(ctx context.Context, ip models.IP)
Copy link
Member

Choose a reason for hiding this comment

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

nitpick: like for the other methods, don't name the arguments if it doesn't add any value:

Suggested change
UpdateIP(ctx context.Context, ip models.IP)
UpdateIP(context.Context, models.IP)

log.Info("NoNetwork option enabled: Removing IP from network interface")
err := m.networkInterface.RemoveIP(ip.IP)
if err != nil {
log.WithError(err).Error("Fail to remove IP from network interface")
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain in a comment why we don't return in case of error here? This is unclear for me

log.Info("NoNetwork option disabled and we are MASTER: Adding the IP to our network interface")
err := m.networkInterface.EnsureIP(ip.IP)
if err != nil {
log.WithError(err).Error("fail to add IP to our network interface")
Copy link
Member

Choose a reason for hiding this comment

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

Can you explain in a comment why we don't return in case of error here? This is unclear for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants