Skip to content

Conversation

@ormergi
Copy link
Contributor

@ormergi ormergi commented Jan 9, 2024

The new disableContainerInterface parameter is added to the bridge plugin to
enable setting the container interface state down.

When the parameter is enabled, the container interface (veth peer that is placed
at the container ns) remain down (i.e: disabled).
The bridge and host peer interfaces state are not affected by the parameter.

Notes for reviewers:

  • Since IPAM logic involve various configurations including waiting for addresses
    to be realized and setting the interface state UP, the new parameter cannot work
    with IPAM.
    In case both IPAM and DisableContainerInterface parameters are set, the bridge
    plugin will raise an error.
  • CNI versions 0.1.0 and 0.2.0 result expect single IP addresses, where newer versions expect multiple addresses (slice).
    When the new parameter is set, there will be no IP to report, thus it cannot work with older versions.
    In newer versions it works and an empty IP addresses slice will return.

Related Issue: #951

@ormergi
Copy link
Contributor Author

ormergi commented Jan 9, 2024

/cc @EdDev @AlonaKaplan

Copy link
Contributor

@EdDev EdDev left a comment

Choose a reason for hiding this comment

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

Thanks!

@ormergi ormergi force-pushed the bridge-cont-iface-state branch 2 times, most recently from 7b93279 to a12ba15 Compare January 10, 2024 12:32
@ormergi
Copy link
Contributor Author

ormergi commented Jan 10, 2024

Changes: fix linter issues

@ormergi ormergi marked this pull request as ready for review January 10, 2024 12:48
@ormergi ormergi force-pushed the bridge-cont-iface-state branch from a12ba15 to 2dccace Compare January 10, 2024 13:31
The new `disableContainerInterface` parameter is added to the bridge plugin to
enable setting the container interface state down.

When the parameter is enabled, the container interface (veth peer that is placed
at the container ns) remain down (i.e: disabled).
The bridge and host peer interfaces state are not affected by the parameter.

Since IPAM logic involve various configurations including waiting for addresses
to be realized and setting the interface state UP, the new parameter cannot work
with IPAM.
In case both IPAM and DisableContainerInterface parameters are set, the bridge
plugin will raise an error.

Signed-off-by: Or Mergi <[email protected]>
@ormergi ormergi force-pushed the bridge-cont-iface-state branch from 2dccace to 7e131a0 Compare January 10, 2024 13:35
@ormergi
Copy link
Contributor Author

ormergi commented Jan 10, 2024

Changes: add failing test when both IPAM and disable-interface parameters are set

Copy link
Member

@mlguerrero12 mlguerrero12 left a comment

Choose a reason for hiding this comment

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

have you checked if there is something to do for the check command? Does it verify that the link is up?

return fmt.Errorf("bridge port in error state: %s", hostVeth.Attrs().OperState)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

from line 581 to here, nothing should be run (except hostVeth initialization) when DisableContainerInterface is set, so I think we could encapsulate this in a function to improve readability. We could simply call that function when DisableContainerInterface is false.

Or multiple functions, something like:
if !DisableContainerInterface {
if layer3 {
setupl3()
} else {
l2link up function or code
}

checkBridgePortSTate()
}

WDYT?

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 have posted a PR for small refactoring around the places this PR change #998
Can we please address what you suggest on a follow up PR?

Copy link
Member

Choose a reason for hiding this comment

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

sure

@ormergi
Copy link
Contributor Author

ormergi commented Jan 14, 2024

have you checked if there is something to do for the check command? Does it verify that the link is up?

Hi @mlguerrero12 thanks for the review 😀 , from what I saw the check cmd does not check the interface state at all.

@squeed
Copy link
Member

squeed commented Jan 15, 2024

From what I saw the check cmd does not check the interface state at

Hah. Oops :-). Well, that would be good to fix, but it could be in a separate PR 😬

Copy link
Member

@mlguerrero12 mlguerrero12 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @ormergi

return fmt.Errorf("bridge port in error state: %s", hostVeth.Attrs().OperState)
}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

sure

@ormergi
Copy link
Contributor Author

ormergi commented Jan 22, 2024

Hey @squeed please take another look, let me know if there is anything else we should do 🙂

@ormergi
Copy link
Contributor Author

ormergi commented Jan 31, 2024

Updating docs PR containernetworking/cni.dev#137

@squeed
Copy link
Member

squeed commented Feb 2, 2024

Thanks for your contribution!

openshift-merge-bot bot added a commit to openshift/containernetworking-plugins that referenced this pull request Dec 23, 2024
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.

5 participants