-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[WIP] Node network Part1 #499
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
6f4d61f
Basic nodeNetwork implementation
rmohr 0bfd253
Generalize and improve Interface detection
rmohr 3cec661
Add test based on goexpect to ensure that nodeNetwork is configured
rmohr b06cfa9
Add CNI plugins to virt-handler
rmohr 7b20ec6
Bring CNI dhcp lease daemon into place
rmohr 65a755b
Add CNI wrapper tool to allow easy invocation of CNI plugins
rmohr b6d4cef
wip
rmohr 2a13c79
Add ipamonly and noroutes CNI plugins
rmohr 8519372
Generalize cni config rewrite
rmohr b628ef8
Add Support for libvirt metadata
rmohr 000cead
Integrate CNI calls into the VMSync flow
rmohr a3a8fd6
Move MAC random generation to the main network plugin
rmohr 7bfdd42
Add mac and IP store for ipamonly plugin
rmohr a2c1650
Set netmaks of the acquired IP to /32
rmohr aba2457
Use store in ipamonly plugin
rmohr f448155
Make sure that CNI DHCP client can be restarted
rmohr 4fa471d
Move all network related code to an independent provider
rmohr e9a5dc4
Publish IP and MAC of interfaces in VM status
rmohr ce6f2b1
Add tests which perform http calls from pods to the VM
rmohr 7946bcf
Fix function signature in tests
rmohr 62ac29b
Fix nodenetwork manifest
rmohr f4f0410
Make unit tests pass again after node networking changes
rmohr 0236bec
Delete CNI cache on first deployment or node restart
rmohr 9510466
Rebase on latest to incorporate virt-handler changes
rmohr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package main | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
"net" | ||
|
||
"github.com/containernetworking/cni/pkg/skel" | ||
"github.com/containernetworking/cni/pkg/types" | ||
"github.com/containernetworking/cni/pkg/types/current" | ||
"github.com/containernetworking/cni/pkg/version" | ||
"github.com/containernetworking/plugins/pkg/ipam" | ||
) | ||
|
||
const socketPath = "/run/cni/dhcp.sock" | ||
|
||
type NetConf struct { | ||
types.NetConf | ||
RealIPAM string `json:"realipam"` | ||
} | ||
|
||
func main() { | ||
skel.PluginMain(cmdAdd, cmdDel, version.All) | ||
} | ||
|
||
func loadConf(bytes []byte) (*NetConf, string, error) { | ||
n := &NetConf{} | ||
if err := json.Unmarshal(bytes, n); err != nil { | ||
return nil, "", fmt.Errorf("failed to load netconf: %v", err) | ||
} | ||
return n, n.CNIVersion, nil | ||
} | ||
|
||
func cmdAdd(args *skel.CmdArgs) error { | ||
|
||
n, cniVersion, err := loadConf(args.StdinData) | ||
if err != nil { | ||
return err | ||
} | ||
r, err := ipam.ExecAdd(n.RealIPAM, args.StdinData) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
res, err := current.NewResultFromResult(r) | ||
if err != nil { | ||
return err | ||
} | ||
// remove all routes | ||
res.Routes = nil | ||
// don't mess around with existing default gateways | ||
for _, ipconfig := range res.IPs { | ||
ipconfig.Gateway = nil | ||
} | ||
// Force only a route for the acquired IP | ||
res.IPs[0].Address.Mask = net.IPv4Mask(255, 255, 255, 255) | ||
|
||
return types.PrintResult(res, cniVersion) | ||
} | ||
|
||
func cmdDel(args *skel.CmdArgs) error { | ||
|
||
n, _, err := loadConf(args.StdinData) | ||
if err != nil { | ||
return err | ||
} | ||
return ipam.ExecDel(n.RealIPAM, args.StdinData) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back 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.
fyi, I think this is left over from some skeleton code you pulled in from container networking.