Skip to content
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

Change "Not forwarding" messages to debug level #2596

Closed
wants to merge 1 commit into from

Conversation

nirs
Copy link
Contributor

@nirs nirs commented Sep 8, 2024

Info level should be used only for important events or changes to the system, for example when we forward a port from the guest. Not forwarding a port can be helpful when debugging port forwarding, so keeping it as debug message.

Part-of: #2577

Info level should be used only for important events or changes to the
system, for example when we forward a port from the guest. Not
forwarding a port can be helpful when debugging port forwarding, so
keeping it as debug message.

Part-of: lima-vm#2577
Signed-off-by: Nir Soffer <nsoffer@redhat.com>
@nirs
Copy link
Contributor Author

nirs commented Sep 8, 2024

I tried to run hack/test-port-forwarding.pl but is seems to be broken now:

% ./hack/test-port-forwarding.pl 
Use of uninitialized value $instance in -f at ./hack/test-port-forwarding.pl line 37.
Use of uninitialized value $instance in regexp compilation at ./hack/test-port-forwarding.pl line 64, <$ls> line 1.
Use of uninitialized value $instance in regexp compilation at ./hack/test-port-forwarding.pl line 64, <$ls> line 2.
Use of uninitialized value $instance in regexp compilation at ./hack/test-port-forwarding.pl line 64, <$ls> line 3.
Use of uninitialized value $instance in regexp compilation at ./hack/test-port-forwarding.pl line 64, <$ls> line 4.
Cannot determine sshLocalPort at ./hack/test-port-forwarding.pl line 68, <$ls> line 4.

Or maybe the required perl version is not documented?

@nirs nirs marked this pull request as ready for review September 8, 2024 18:05
@AkihiroSuda
Copy link
Member

I'd say "Not forwarding" message is important and should be printed by default.

Probably limactl start should have --quiet (-q) flag to silence it

@nirs
Copy link
Contributor Author

nirs commented Sep 8, 2024

For the use case of disabling all port forwarding, the "not forwarding" message is not important.

Maybe we need a simple switch for port forwarding?

portForwards:
  enabled: false

In this case the user made it clear that no forwarding should happen so there is no need to log anything.

If you enabled some port forwarding, it makes sense to show what was not forwarded in case you want to know if your rules are correct, although this is mainly for debugging.

@Ranjandas
Copy link

👍 for having a simple switch to disable port forwarding.

@jandubois
Copy link
Member

For the use case of disabling all port forwarding, the "not forwarding" message is not important.

I agree. I've implemented it in #2600.

Maybe we need a simple switch for port forwarding?

portForwards:
  enabled: false

It already exists:

portForwards:
- ignore: true

It relies on the fact that the default for guestPortRange is [1, 65535] (if guestPort is also not set).

You can also set it from the commandline:

limactl start --set '.portForwards=[{"ignore": true}]'

@jandubois
Copy link
Member

It already exists:

portForwards:
- ignore: true

Note that you cannot disable (or override) redirection of the SSH port (22) because without it Lima doesn't work.

@nirs
Copy link
Contributor Author

nirs commented Sep 9, 2024

@jandubois thanks, but I think when I tried this:

portForwards:
- guestPortRange: [1, 65535]
  ignore: true

it did not work, and some ports were forwarded from [::]. I had to use:

portForwards:
- guestPortRange: [1, 65535]
  guestIP: "0.0.0.0"
  ignore: true

But assuming we fix the issue, can we detect this as "I don't want any port forwarding" and log the "not forwarding ..." message in debug level?

I think this is not good user or developer experience when you don't have a simple way to disable a feature, and you need to depend on a special configuration.

@nirs
Copy link
Contributor Author

nirs commented Sep 9, 2024

#2600 seems a better way.

@nirs nirs closed this Sep 9, 2024
@jandubois
Copy link
Member

I tried to run hack/test-port-forwarding.pl but is seems to be broken now:

It is not really something you can run by itself; it is used implicitly by hack/test-templates.sh.

You have to run it twice: once with a template filename to specify the template it should modify with the portForwards section needed for testing, and once you have started an instance with that modified template you run the script again with the instance name as the parameter.

Since you may also need to install the right version of netcat inside the instance, it is probably best to only run it via the test-templates.sh script.

@nirs
Copy link
Contributor Author

nirs commented Sep 9, 2024

I tried to run hack/test-port-forwarding.pl but is seems to be broken now:

It is not really something you can run by itself; it is used implicitly by hack/test-templates.sh.

I ran it based on the documentation in the file (adding debug log level):

# ./hack/test-port-forwarding.pl templates/default.yaml
# limactl --tty=false --log-level debug start templates/default.yaml
# git restore templates/default.yaml
# ./hack/test-port-forwarding.pl default

Maybe the comment should mention the additional requirements, or just remove the comment and add a comment about the script that run it?

@jandubois
Copy link
Member

jandubois commented Sep 9, 2024

I'm confused, you wrote

I tried to run hack/test-port-forwarding.pl but is seems to be broken now:

% ./hack/test-port-forwarding.pl 
Use of uninitialized value $instance in -f at ./hack/test-port-forwarding.pl line 37.
Use of uninitialized value $instance in regexp compilation at ./hack/test-port-forwarding.pl line 64, <$ls> line 1.
…
Cannot determine sshLocalPort at ./hack/test-port-forwarding.pl line 68, <$ls> line 4.

Or maybe the required perl version is not documented?

You should not get these warnings/failures if you specify arguments to the script.

I ran it based on the documentation in the file (adding debug log level):

And, did it work, or show any errors?

@nirs
Copy link
Contributor Author

nirs commented Sep 9, 2024

And, did it work, or show any errors?

If failed with the error I shared, but it looks like I run the last command without the argument.

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.

4 participants