-
Notifications
You must be signed in to change notification settings - Fork 95
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
feat: resolve special IP host-gateway #453
base: main
Are you sure you want to change the base?
Conversation
@TrungBui59 Thanks. Looks like your screenshot only covers the final summary of the failing e2e tests. Could you scroll up, find the verbose logs for each failing scenario, and paste here (Please paste instead of screenshotting for convenient search)? |
Here are the log, for the errors that is causing by my changes, it is mostly timeout issue |
There are 3 ways of filling host gateway IP in nerdctl: config, command arg and env var. Finch should also support all of them for feature parity. By default users can already use command arg to fill IP in Finch, as Finch inherits commands from Nerdctl. Env var should also work as Finch passes the envs to nerdctl commands. Only Finch config needs some additional work. If we fill the value from Finch config to nerdctl command arg (as the current revision of the PR is doing) or env var, they may have conflict with the user-input command arg and env var. Finch can set some rules to let one override another, but that would cause unnecessary business logic in Finch. We could have directly passed the value from Finch config to nerdctl config, so nerdctl will decide whatever rules to let one override another. |
Oh I see, I will working on that approach right away |
2f506f9
to
fef6e77
Compare
Could you add e2e tests? The host-gateway-ip arg and env var can be added in common-tests repo around here. (can be a separated PR as it is separated repo) https://github.com/runfinch/common-tests/blob/6c7275007bf34fb6ddecc4013c16f1d79ff6d1d0/tests/run.go#L335 |
Please rename the PR to conventional commit message style to pass the PR title check. https://www.conventionalcommits.org/en/v1.0.0/ |
@ningziwen Sorry for not being responsive, I was busy with my intern work. I still dont know how to make it change the host-gateway-ip when the VM starts/restarts. I can make it change when we init the VM. Any suggestion on how to make it work with start and restart? so far, I have tried reading the finch config during the postVMStartAction, but it still does not work as I planned |
@ningziwen Sorry for not being really responsive, I was busy with my intern work. I still dont know how to make it change the host-gateway-ip when the VM starts/restarts. I can make it change when we init the VM. Any suggestion on how to make it work with start and restart? so far, I have tried reading the finch config during the postVMStartAction, but it still does not work as I planned |
@TrungBui59 Reading the code, it seems passing it here should work. Have you tried it? What is the error? |
@ningziwen The current approach is that I will pass the already existing finch config to the nerdctl, but when we restart it, the config change. And I still haven't found a way to pass the new value to it. I have tried to read the new config and create a new NerdctlConfigApplier with a new config, but it doesn't work |
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.
concept / implementation LGTM, just a few more minor things in addition to what @ningziwen already commented on
pkg/config/config.go
Outdated
@@ -67,6 +68,7 @@ type Nerdctl struct { | |||
CgroupManager string `toml:"cgroup_manager,omitempty"` | |||
InsecureRegistry bool `toml:"insecure_registry,omitempty"` | |||
HostsDir []string `toml:"hosts_dir,omitempty"` | |||
HostGatewayIP *string `toml:"host_gateway_ip,omitempty"` |
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.
nit: formatting
pkg/config/nerdctl_config_applier.go
Outdated
@@ -9,10 +9,12 @@ import ( | |||
"path" | |||
"strings" | |||
|
|||
"github.com/lima-vm/lima/pkg/networks" |
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.
nit: import order
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.
How can I know prevent these nit issue? I ran golang-lint and it didnt give me anything
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.
Hi @TrungBui59, golang-lint will lint code, but not format it. You can use gofmt -w .
from the top level directory of a Go project to format all Go files, writing the correctly formatted files. Go plugins for modern IDEs will typically do this every time a Go file is saved.
pkg/config/nerdctl_config_applier.go
Outdated
@@ -23,6 +25,7 @@ const ( | |||
) | |||
|
|||
type nerdctlConfigApplier struct { | |||
fc *Finch |
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.
nit: formatting
pkg/config/nerdctl_config_applier.go
Outdated
return &nerdctlConfigApplier{ | ||
fc: fc, |
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.
nit: formatting
Hi @pendo324, I can only add the host-gateway-ip when we init the VM. However, @ningziwen wants me to make the host-gateway-ip to be configurable when the user starts/restarts the VM. I have tried to update the finch config at the postVMStartAction state, but it is not working. Can you give some insight on how to make it work? |
Sure, I will also need to change some unit test |
@ningziwen sorry for the late response, I have finalized by adding unit tests and e2e tests |
Signed-off-by: TrungBui59 <bui23@purdue.edu>
pkg/config/config.go
Outdated
@@ -54,7 +54,8 @@ type Finch struct { | |||
// Requires macOS 13.0 or later and an Apple Silicon (ARM64) mac. | |||
// Has no effect on systems where Rosetta 2 is not available (Intel/AMD64 macs, or macOS < 13.0). | |||
// This setting will only be applied on vm init. | |||
Rosetta *bool `yaml:"rosetta,omitempty"` | |||
Rosetta *bool `yaml:"rosetta,omitempty"` | |||
HostGatewayIp *string `yaml:"host_gateway_ip,omitempty"` |
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.
Please make the naming consistent with line 76. Probably follow the pattern in nerdctl. https://github.com/containerd/nerdctl/blob/1f8f8af4d19d651a6300d8d48f3f21c91048a716/pkg/config/config.go#L41
HostGatewayIP
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.
Just fix 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.
One nit pick. Also need to fix the errors in CI.
Others LGTM.
Need a follow-up PR in https://github.com/runfinch/common-tests to test CLI flag and env var.
Signed-off-by: TrungBui59 <bui23@purdue.edu>
@ningziwen I just finish with it, I will do the follow up work on the common tests file. Can you assign me another issue to do? |
Same issue is fine. One issue can map to multiple PRs. |
Could you make the PR title more accurate? Such as "feat: make host gateway ip configurable". The PR title will be the final commit message. |
Please follow the guideline to fix DCO. https://github.com/runfinch/finch/pull/453/checks?check_run_id=16527210509 go linter and go-mod-tidy-check are still failing. |
Sure, I will do it. I mean like after the follow up work, can you assign me another one? I am still a newbie with Finch so I will need sometime to understand and find a way to address it |
pkg/config/config.go
Outdated
@@ -54,7 +54,8 @@ type Finch struct { | |||
// Requires macOS 13.0 or later and an Apple Silicon (ARM64) mac. | |||
// Has no effect on systems where Rosetta 2 is not available (Intel/AMD64 macs, or macOS < 13.0). | |||
// This setting will only be applied on vm init. | |||
Rosetta *bool `yaml:"rosetta,omitempty"` | |||
Rosetta *bool `yaml:"rosetta,omitempty"` | |||
HostGatewayIp *string `yaml:"host_gateway_ip,omitempty"` |
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.
Please add godoc comment i.e.
HostGatewayIp *string `yaml:"host_gateway_ip,omitempty"` | |
// HostGatewayIp sets the default host gateway ip.... | |
HostGatewayIp *string `yaml:"host_gateway_ip,omitempty"` |
@@ -124,6 +126,10 @@ func updateNerdctlConfig(fs afero.Fs, user string, rootless bool) error { | |||
} | |||
|
|||
cfg.Namespace = nerdctlNamespace | |||
cfg.HostGatewayIP = "192.168.5.2" |
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.
instead of having this magic string down here, could we define as a constant defaultNerdctlHostGatewayIP
here https://github.com/runfinch/finch/pull/453/files#diff-531afb9f97a7384e0de895046f9e14befbebc49c896b080fce4c41c75f14f1b4L20-L21
then you can also reference it in unit tests where you expect the HostGatewayIP
to be the default value.
@TrungBui59 We don't do assignments proactively normally. Feel free to try out any issues that you are interested. If you are concerned about the difficulty, you can filter "good first issue". If you are not clear about the requirements of specific issue, you can also reply to clarify. There are also other simple but interesting issues under other subprojects of runfinch, such as runfinch/common-tests#72. Once you find the issue you want to take, you can reply it and we will assign to you. |
@TrungBui59 e2e tests are failing in CI. Could you fix it? |
Issue #209
Description of changes:
I add the host-gateway-ip to the finch config file and use that to make the host-gateway-ip configurable using nerdctl
Testing done:
I have done some unit test, it passed most of the e2e tests, but now it show some weird error that I don't think is a problem because of my code change
License Acceptance
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.