Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Improve the CNI implementation, and documentation #308

Merged
merged 6 commits into from
Aug 9, 2019

Conversation

luxas
Copy link
Contributor

@luxas luxas commented Aug 9, 2019

Fixes: #171
Fixes: #303

This PR:

  • Improves the network plugins interface, and makes the docker implementation consistent
  • Makes ignite support multiple initialized network plugins
  • Adds networking documentation

cc @twelho

@luxas luxas added this to the v0.5.0 milestone Aug 9, 2019
@luxas luxas changed the title Fix the CNI implementation at HEAD, and add docs Improve the CNI implementation, and documentation Aug 9, 2019
@luxas luxas added the kind/enhancement Categorizes issue or PR as related to improving an existing feature. label Aug 9, 2019
Copy link
Contributor

@twelho twelho left a comment

Choose a reason for hiding this comment

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

Thanks, very welcome changes! ✨
Some nits, otherwise LGTM 👍

**Cons:**

- **docker-dependent**: By design, this mode is can only be used with docker, and is hence not portable across container runtimes.
- **No multi-node support**: The IP is local (in the `172.17.0.0/16` range), and hence other computers can't connect to your VM's IP address.
Copy link
Contributor

Choose a reason for hiding this comment

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

This IP range differs from the one given above, I believe this one here (172.17.0.0/16) is correct and the one above should be changed.

}

func GetDockerNetworkPlugin(r runtime.Interface) (network.Plugin, error) {
return &dockerNetworkPlugin{r}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need to return an error?

IP: result.IPAddress,
Mask: net.IPv4Mask(255, 255, 0, 0),
},
Gateway: net.IPv4(result.IPAddress[0], result.IPAddress[1], result.IPAddress[2], 1),
Copy link
Contributor

Choose a reason for hiding this comment

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

Add TODO to make this configurable/auto-retrievable if someone has changed their gateway?

@@ -162,22 +163,46 @@ func (plugin *cniNetworkPlugin) Status() error {
return plugin.checkInitialized()
}

func (plugin *cniNetworkPlugin) SetupContainerNetwork(containerid string) error {
func (plugin *cniNetworkPlugin) PrepareContainerSpec(container *runtime.ContainerConfig) error {
// we will handle the networking on our own
Copy link
Contributor

Choose a reason for hiding this comment

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

we -> We

}

log.Infof("Networking is handled by %s", networkPlugin.Name())
Copy link
Contributor

Choose a reason for hiding this comment

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

%s -> %q for UX consistency

func SetDockerNetwork() error {
log.Trace("Initializing the Docker network provider...")
plugin, err := network.GetDockerNetworkPlugin(providers.Runtime)
if err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

This error is unnecessary, it's always nil

@@ -22,6 +22,10 @@ var Storage storage.Storage

type ProviderInitFunc func() error

func init() {
NetworkPlugins = make(map[string]network.Plugin)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can be an inline initialization: var NetworkPlugins = make(map[string]network.Plugin), no need for init()

@luxas
Copy link
Contributor Author

luxas commented Aug 9, 2019

Comments addressed, and the CI is green, merging 👍

@luxas luxas merged commit 4bb08db into weaveworks:master Aug 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/enhancement Categorizes issue or PR as related to improving an existing feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support fetching IP addresses from CNI Add CNI usage docs
2 participants