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

Assign ssh.localPort automatically to an available port #131

Closed
jandubois opened this issue Jul 27, 2021 · 5 comments · Fixed by #285
Closed

Assign ssh.localPort automatically to an available port #131

jandubois opened this issue Jul 27, 2021 · 5 comments · Fixed by #285
Labels
enhancement New feature or request priority/high
Milestone

Comments

@jandubois
Copy link
Member

The port may change when the instance is stopped and restarted because the original port may have been taken by a different application (or lima instance) in between.

Question: where should the port be recorded? Do we load lima.yaml, modify the port, and store the file back in YAML format? This would drop any comments from the file, but I think it would be the right thing to do.

Long term I would like to be able to run e.g. lima restart default --memory 12GB and have it modify the config file for me automatically, so there needs to be a machine-writable version of the config eventually anyways.

@jandubois jandubois added the enhancement New feature or request label Jul 27, 2021
@AkihiroSuda
Copy link
Member

Question: where should the port be recorded? Do we load lima.yaml, modify the port, and store the file back in YAML format? This would drop any comments from the file, but I think it would be the right thing to do.

Hostagent should speak REST API over an UNIX socket, and report the port number in GET /v1/info.
The API can be extended to report more dynamic state info.

@jandubois
Copy link
Member Author

Hostagent should speak REST API over an UNIX socket, and report the port number in GET /v1/info.
The API can be extended to report more dynamic state info.

Ok, but wouldn't we want to record the modified information somewhere? Like once you restart the instance with modified RAM or CPU settings, shouldn't the new settings persist for future instance restarts (e.g when the host is rebooted)?

@AkihiroSuda
Copy link
Member

Ok, but wouldn't we want to record the modified information somewhere? Like once you restart the instance with modified RAM or CPU settings, shouldn't the new settings persist for future instance restarts (e.g when the host is rebooted)?

If we are going to have a command like limactl edit <INSTANCE> which executes $EDITOR ~/.lima/<INSTANCE>/lima.yaml for modifying the settings, the modified settings will be obviously just written in ~/.lima/<INSTANCE>/lima.yaml

If we are rather going to have a command like limactl update <INSTANCE> --cpus=2 --memory=4G, maybe we will want to save the configurations in some JSON file like ~/.lima/<INSTANCE>/lima.override.json.
But we can also consider just saving the configuration in ~/.lima/<INSTANCE>/lima.yaml if we can modify YAML without loosing comment lines.

Anyway, the SSH port is ephemeral and should not be inherited after restarting the instance.

@jandubois
Copy link
Member Author

If we are rather going to have a command like limactl update <INSTANCE> --cpus=2 --memory=4G, maybe we will want to save the configurations in some JSON file like ~/.lima/<INSTANCE>/lima.override.json.

Sounds like a good idea!

But we can also consider just saving the configuration in ~/.lima/<INSTANCE>/lima.yaml if we can modify YAML without loosing comment lines.

I have looked into this in the past for a different project, and this is a hard problem. The existing tools all didn't work correctly (messed up the data, not just the comments). And writing a spec on how such a tool should work proved challenging as well: It is often not clear from formatting alone if a comment refers to the element above or below it.

Anyway, the SSH port is ephemeral and should not be inherited after restarting the instance.

Agreed.

@AkihiroSuda
Copy link
Member

PR #285

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority/high
Projects
None yet
2 participants