-
-
Notifications
You must be signed in to change notification settings - Fork 10
Extract CNI networking into its own handler #26
Conversation
) | ||
|
||
// defaultCNIConf is a CNI configuration that enables network access to containers (docker-bridge style) | ||
var defaultCNIConf = fmt.Sprintf(` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I sent a struct over to you which I think might work better. Can you take a look and see if you want to add it in this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might complicate things by adding Opts struct, initializing it, passing it around, etc.
Maybe later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure 👍
handlers/cni_network.go
Outdated
`, defaultNetworkName, defaultBridgeName, defaultSubnet) | ||
|
||
// InitNetwork writes configlist file and initializes CNI network | ||
func InitNetwork() gocni.CNI { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'd be a little more Go idiomatic if this could return an error and we could then throw a fatal if we wanted one level higher.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean returning both like last push?
if config.Sandbox == netNamespace(task) { | ||
for _, ipConfig := range config.IPConfigs { | ||
if ifName != "lo" && ipConfig.IP.To4() != nil { | ||
ip = ipConfig.IP |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not want to break here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case no IP is found, it's nil and returns the error following it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we found the condition we wanted, what would happen if you broken out of the loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much clearer to read, good work. I have left some comments that I'd like you to resolve as soon as you can, then I can merge.
This refactor puts all CNI variables, constants, initialization and functions into it's own handler. This simplifies non-network related code like main and deploy functions and avoids redundant code been called on every container deployment. Signed-off-by: Carlos de Paula <[email protected]>
When deleting or updating the container, remove the created CNI network. Changed CNI id generation to be able to recover from other functions. Signed-off-by: Carlos de Paula <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
I'll try this out on my other RPi3, do I need to do a custom build of the CNI plugins first? |
Until CNI plugins release a new version (with containernetworking/plugins#434 included) the bridge plugin built from master is still needed. |
ok thanks |
Description
This refactor puts all CNI variables, constants, initialization and
functions into it's own handler.
This simplifies non-network related code like main and deploy functions
and avoids redundant code been called on every container deployment.
Signed-off-by: Carlos de Paula [email protected]
Motivation and Context
This PR replaces PR #25 and fixes issue #24.
How Has This Been Tested?
Tested on linux/amd64 deploying images integrated with faasd:
Client:
Types of changes
Checklist:
Commits:
git commit -s
for the Developer Certificate of Origin (DCO)Code:
Docs: