Skip to content

Conversation

jandubois
Copy link
Member

By default all additional interfaces use a metric of 100, so take precedence over the builtin SLIRP network. With this commit the metric of each interface can be set separately.

Fixes #2867
(It doesn't restore the pre-1.0.0 behaviour, but lets the user restore it themselves, if it is important to them. The new settings still seem like a sensible default).

Copy link
Member

@nirs nirs left a comment

Choose a reason for hiding this comment

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

Nice, testing it.

By default all additional interfaces use a metric of 100, so
take precedence over the builtin SLIRP network. With this commit
the metric of each interface can be set separately.

Signed-off-by: Jan Dubois <[email protected]>
@jandubois jandubois added this to the v1.0.1 milestone Nov 7, 2024
@nirs
Copy link
Member

nirs commented Nov 7, 2024

Tested using ramen drenv tool, starting a cluster using ramen k8s based template:
https://github.com/RamenDR/ramen/blob/main/test/drenv/providers/lima/k8s.yaml

Testing defaults

% limactl --version
limactl version 1.0.0-16-gf8d02bc8

% drenv start envs/vm.yaml 
2024-11-07 21:51:55,435 INFO    [vm] Starting environment
2024-11-07 21:51:55,460 INFO    [cluster] Starting lima cluster
2024-11-07 21:53:57,130 INFO    [cluster] Cluster started in 121.67 seconds
2024-11-07 21:53:57,131 INFO    [cluster/0] Running addons/example/start
2024-11-07 21:54:22,553 INFO    [cluster/0] addons/example/start completed in 25.42 seconds
2024-11-07 21:54:22,553 INFO    [cluster/0] Running addons/example/test
2024-11-07 21:54:22,761 INFO    [cluster/0] addons/example/test completed in 0.21 seconds
2024-11-07 21:54:22,762 INFO    [vm] Environment started in 147.32 seconds

% limactl shell cluster ip r
default via 192.168.105.1 dev lima0 proto dhcp src 192.168.105.4 metric 100 
default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.15 metric 200 
192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.15 metric 200 
192.168.5.2 dev eth0 proto dhcp scope link src 192.168.5.15 metric 200 
192.168.105.0/24 dev lima0 proto kernel scope link src 192.168.105.4 metric 100 
192.168.105.1 dev lima0 proto dhcp scope link src 192.168.105.4 metric 100 

% drenv delete envs/vm.yaml
...

Testing custom metric

% git diff                            
diff --git a/test/drenv/providers/lima/__init__.py b/test/drenv/providers/lima/__init__.py
index d2db1c75..481c687a 100644
--- a/test/drenv/providers/lima/__init__.py
+++ b/test/drenv/providers/lima/__init__.py
@@ -186,7 +186,7 @@ def _write_config(profile, path):
         config["rosetta"] = {"enabled": True, "binfmt": True}
 
     # We always use socket_vmnet to get shared network.
-    config["networks"] = [{"socket": "/var/run/socket_vmnet"}]
+    config["networks"] = [{"socket": "/var/run/socket_vmnet", "metric": 42}]
 
     # Add profile options to template

% drenv start envs/vm.yaml
2024-11-07 22:00:20,652 INFO    [vm] Starting environment
2024-11-07 22:00:20,674 INFO    [cluster] Starting lima cluster
2024-11-07 22:02:29,224 INFO    [cluster] Cluster started in 128.55 seconds
2024-11-07 22:02:29,237 INFO    [cluster/0] Running addons/example/start
2024-11-07 22:02:35,860 INFO    [cluster/0] addons/example/start completed in 6.62 seconds
2024-11-07 22:02:35,860 INFO    [cluster/0] Running addons/example/test
2024-11-07 22:02:36,040 INFO    [cluster/0] addons/example/test completed in 0.18 seconds
2024-11-07 22:02:36,040 INFO    [vm] Environment started in 135.39 seconds

% limactl shell cluster ip r
default via 192.168.105.1 dev lima0 proto dhcp src 192.168.105.4 metric 42 
default via 192.168.5.2 dev eth0 proto dhcp src 192.168.5.15 metric 200 
192.168.5.0/24 dev eth0 proto kernel scope link src 192.168.5.15 metric 200 
192.168.5.2 dev eth0 proto dhcp scope link src 192.168.5.15 metric 200 
192.168.105.0/24 dev lima0 proto kernel scope link src 192.168.105.4 metric 42 
192.168.105.1 dev lima0 proto dhcp scope link src 192.168.105.4 metric 42 

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks

@AkihiroSuda AkihiroSuda merged commit 25baa9d into lima-vm:master Nov 7, 2024
29 checks passed
Interface string `yaml:"interface,omitempty" json:"interface,omitempty"`
MACAddress string `yaml:"macAddress,omitempty" json:"macAddress,omitempty"`
Interface string `yaml:"interface,omitempty" json:"interface,omitempty"`
Metric *uint32 `yaml:"metric,omitempty" json:"metric,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

limactl start now prints

WARN[0000] vmType vz: ignoring networks[0]: [Metric]

@jandubois jandubois deleted the metric branch December 6, 2024 17:10
jandubois added a commit to jandubois/lima that referenced this pull request Dec 11, 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.

Network metric weight regression with additional networks

3 participants