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

Enable multiple non-IP interface to be connected via tc redirect #836

Merged
merged 28 commits into from
Jun 25, 2021
Merged
Show file tree
Hide file tree
Changes from 24 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
0d7046e
First crack at multinet implementation
networkop May 10, 2021
0b3dfdb
fix the dhcp server bug
networkop May 10, 2021
9acef4f
Merge branch 'weaveworks:main' into multinet
networkop May 10, 2021
56ca546
Added wait for X number of interfaces to be connected
networkop May 10, 2021
52776a6
Merge branch 'weaveworks:main' into multinet
networkop May 10, 2021
e3baa91
Merge branch 'multinet' of github.com:networkop/ignite into multinet
networkop May 10, 2021
17765be
Fixed multiple bugs
networkop May 11, 2021
6e19436
Ensure maxIntfs is at least 1
networkop May 11, 2021
39d395e
Fixed formatting
networkop May 11, 2021
9a31fb9
Forgot to assign envVars
networkop May 11, 2021
20b4aa8
Updated docs
networkop May 11, 2021
35dc891
More updated docs
networkop May 11, 2021
e8bd47c
More docs updates
networkop May 11, 2021
b8ef5d3
Not using env vars anymore
networkop May 22, 2021
47c9140
Re-introducing env var support
networkop May 23, 2021
6f1f14a
Reverting the order to error checks
networkop May 24, 2021
90eaa58
Added multinet tests
networkop Jun 9, 2021
1020f90
Fixing dox
networkop Jun 9, 2021
053def5
Refactored StartVM with async spawn channel
networkop Jun 10, 2021
eb8997f
Refactored ignite-spawn's network setup
networkop Jun 10, 2021
051ad2b
Fixed the CNI plugin bug
networkop Jun 11, 2021
1c70e78
Tested with containerlab
networkop Jun 12, 2021
9957b70
Merging suggested changes
networkop Jun 21, 2021
3161ef4
Alternative e2e test
networkop Jun 22, 2021
f8d361d
Removed --wait flag and fixed up multinet tests
networkop Jun 22, 2021
668b5fe
Removing waitForSSH from exec
networkop Jun 24, 2021
71c801c
Removing leftover comment
networkop Jun 24, 2021
abddda2
Adding waitforSSH back
networkop Jun 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/ignite-spawn/ignite-spawn.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ func decodeVM(vmID string) (*api.VM, error) {
}

func StartVM(vm *api.VM) (err error) {

// Setup networking inside of the container, return the available interfaces
dhcpIfaces, err := container.SetupContainerNetworking()
fcIfaces, dhcpIfaces, err := container.SetupContainerNetworking(vm)
if err != nil {
return fmt.Errorf("network setup failed: %v", err)
}
Expand All @@ -66,7 +67,7 @@ func StartVM(vm *api.VM) (err error) {
defer util.DeferErr(&err, func() error { return os.Remove(metricsSocket) })

// Execute Firecracker
if err = container.ExecuteFirecracker(vm, dhcpIfaces); err != nil {
if err = container.ExecuteFirecracker(vm, fcIfaces); err != nil {
return fmt.Errorf("runtime error for VM %q: %v", vm.GetUID(), err)
}

Expand Down
4 changes: 4 additions & 0 deletions cmd/ignite/cmd/cmdutil/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ func AddInteractiveFlag(fs *pflag.FlagSet, interactive *bool) {
fs.BoolVarP(interactive, "interactive", "i", *interactive, "Attach to the VM after starting")
}

func AddWaitFlag(fs *pflag.FlagSet, wait *bool) {
fs.BoolVarP(wait, "wait", "w", true, "wait for VM to start")
}

func AddForceFlag(fs *pflag.FlagSet, force *bool) {
fs.BoolVarP(force, "force", "f", *force, "Force this operation. Warning, use of this mode may have unintended consequences.")
}
Expand Down
1 change: 1 addition & 0 deletions cmd/ignite/cmd/vmcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func NewCmdStart(out io.Writer) *cobra.Command {

func addStartFlags(fs *pflag.FlagSet, sf *run.StartFlags) {
cmdutil.AddInteractiveFlag(fs, &sf.Interactive)
cmdutil.AddWaitFlag(fs, &sf.Wait)
fs.BoolVarP(&sf.Debug, "debug", "d", false, "Debug mode, keep container after VM shutdown")
fs.StringSliceVar(&sf.IgnoredPreflightErrors, "ignore-preflight-checks", []string{}, "A list of checks whose errors will be shown as warnings. Example: 'BinaryInPath,Port,ExistingFile'. Value 'all' ignores errors from all checks.")
}
4 changes: 4 additions & 0 deletions cmd/ignite/run/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package run

import (
api "github.com/weaveworks/ignite/pkg/apis/ignite"
"github.com/weaveworks/ignite/pkg/constants"
)

// ExecFlags contains the flags supported by the exec command.
Expand Down Expand Up @@ -30,5 +31,8 @@ func (ef *ExecFlags) NewExecOptions(vmMatch string, command ...string) (eo *Exec

// Exec executes command in a VM based on the provided ExecOptions.
func Exec(eo *ExecOptions) error {
if err := waitForSSH(eo.vm, constants.SSH_DEFAULT_TIMEOUT_SECONDS, 5); 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 may not be a concern, but I noticed that runSSH() below accepts a timeout parameter. If this waitForSSH() with default timeout of 5 seconds runs before runSSH(), the user provided timeout will not work, waitForSSH() will return error after waiting for 5 seconds and runSSH() with user provided timeout will never be executed.
Should the timeout for waitForSSH() be the same as provided in the ExecOptions.Timeout?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh yeah, that's a good catch. I've added it there to workaround the behavior introduced by the --wait flag and I forgot to remove it. Will fix this up.

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 think my above conclusion was wrong. Complete removal of waitForSSH leads to multinet tests failure when the prometheus socket is up -> VM is started but SSH is still not up yet. So we need it there, but I've changed the 5 second timeout to the user-provided timeout value.

return err
}
return runSSH(eo.vm, eo.IdentityFile, eo.command, eo.Tty, eo.Timeout)
}
13 changes: 11 additions & 2 deletions cmd/ignite/run/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (

type StartFlags struct {
Interactive bool
Wait bool
Debug bool
IgnoredPreflightErrors []string
}
Expand Down Expand Up @@ -78,12 +79,20 @@ func Start(so *StartOptions, fs *flag.FlagSet) error {
return err
}

if err := operations.StartVM(so.vm, so.Debug); err != nil {
var err error
if so.Wait {
err = operations.StartVM(so.vm, so.Debug)
} else {
// Can't do much with vmChannels here, we need to return ASAP
_, err = operations.StartVMNonBlocking(so.vm, so.Debug)
}

if err != nil {
return err
}

// When --ssh is enabled, wait until SSH service started on port 22 at most N seconds
if ssh := so.vm.Spec.SSH; ssh != nil && ssh.Generate && len(so.vm.Status.Network.IPAddresses) > 0 {
if ssh := so.vm.Spec.SSH; ssh != nil && ssh.Generate && len(so.vm.Status.Network.IPAddresses) > 0 && so.Wait {
if err := waitForSSH(so.vm, constants.SSH_DEFAULT_TIMEOUT_SECONDS, 5); err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions docs/cli/ignite/ignite_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ignite run <OCI image> [flags]
-s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB)
--ssh[=<path>] Enable SSH for the VM. If <path> is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM)
-v, --volumes volume Expose block devices from the host inside the VM
-w, --wait wait for VM to start (default true)
```

### Options inherited from parent commands
Expand Down
1 change: 1 addition & 0 deletions docs/cli/ignite/ignite_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ignite start <vm> [flags]
-i, --interactive Attach to the VM after starting
--network-plugin plugin Network plugin to use. Available options are: [cni docker-bridge] (default cni)
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
-w, --wait wait for VM to start (default true)
```

### Options inherited from parent commands
Expand Down
1 change: 1 addition & 0 deletions docs/cli/ignite/ignite_vm_run.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ ignite vm run <OCI image> [flags]
-s, --size size VM filesystem size, for example 5GB or 2048MB (default 4.0 GB)
--ssh[=<path>] Enable SSH for the VM. If <path> is given, it will be imported as the public key. If just '--ssh' is specified, a new keypair will be generated. (default is unset, which disables SSH access to the VM)
-v, --volumes volume Expose block devices from the host inside the VM
-w, --wait wait for VM to start (default true)
```

### Options inherited from parent commands
Expand Down
1 change: 1 addition & 0 deletions docs/cli/ignite/ignite_vm_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ignite vm start <vm> [flags]
-i, --interactive Attach to the VM after starting
--network-plugin plugin Network plugin to use. Available options are: [cni docker-bridge] (default cni)
--runtime runtime Container runtime to use. Available options are: [docker containerd] (default containerd)
-w, --wait wait for VM to start (default true)
```

### Options inherited from parent commands
Expand Down
Loading