-
-
Notifications
You must be signed in to change notification settings - Fork 138
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
Proposal: Make SSH usage more obvious #701
Comments
Requiring one of Displaying error message early (missing provider configuration argument) instead of later (failure to use SSH when it is needed) is not really an improvement:
Surprise caused by the provider successfully using existing SSH setup should not really happen - user has to either enter ssh password on It may be possible for this to work silently, if user's private ssh key in ~/.ssh is passwordless (in that case user obviously does not care about security).
The user has precise information what was attempted and why it failed, that is great! btw. Linking the section directly does not seem to work (tested firefox and chrome, does not scroll to the ssh section), so in addition to the link, the error message should contain a note to scroll down to "SSH connection" section. Splitting "Authentication" section to "Authentication - API" and "Authentication - SSH" would place the text "SSH" very early in the page: the page's table of contents on the right edge. It is unlikely that a user can effectively use the provider without referencing the documentation, but in case of an error, the message should direct the user to specific part of the documentation relating to the error. Not sure if it would be worth the effort to have a separate page for every possible error in ssh client. In addition to "Resources" and "Data Sources" add a section "Error Codes". If each ssh error message ended with different "
Is there any advantage at having the error at plan time ? Use of SSH depends on resource arguments: Majority of A really determined user could run a possibly useful setup without the provider using SSH. It would be needlessly complex, but it could work:
Possible future:
If both are implemented, it might make sense to add On the other hand, because the provider already uses ssh, it might be possible to have a pve-zsync terraform resource. |
I think failing earlier is better and an improvement. Sure the later error messages could be improved. But when I run a terraform plan first and then apply I would expect that it does not fail in the second step because of a simple connection error (sure there might be other errors but a connection error after already having connected during the plan step is unexpected).
That is not completely true, by default the provider tries to connect with username and password given for the normal API, which is probably also used by many users for SSH too. This means no additional configuration is needed for most new users.
Yes, it saves time and protects from possible inconsistent states. I agree that Terraform should be able to handle it, but that's not always the case (although I haven't encountered it with this provider yet) so why provoke errors when checking beforehand would resolve it? Going forward I mostly agree with your proposal of adding better error messages and hoping that the problems resolves itself™ as the API improves and withdraw my proposal of adding extra configuration options for ssh usage. |
That would be the ideal behavior, but even the big providers do not guarantee that provider configuration and resource description which pass through the planning stage would result in successful resoruce creation.
Just because Incomplete list of possible failures:
and even if ssh connection succeeds, that is not enough:
It looks like that using There could be cases, when user wants a VM to use the same datastore through attribute of another VM (e.g. when using
Opening a SSH connection would slow down Consider this
Place it in an empty directory, run Btw. copying
Thanks! I completely missed that, just used to disabling If it works for new users, the provider probably should not break that.
It looks like
This verification must be skipped, if the user configured the SSH in any way. I.e. anything in Looking around the code a bit more, there might be even better option:
Instead of adding checks causing additional ssh connections and slowing the provider down, make it a feature by reducing the number of ssh connections and make the provider faster. |
It does call read, but only if there is a local state to compare with. Your example may not be representative for the use case, as for a new deployment there is no existing state. So TF does not need to read from PVE to calculate the difference between local and remote states, whatever is in the plan that will be "new". Which means there is no reliable way for provider to check communication with PVE before runing apply, unfortunately. In these circumstances a clear warning at apply, showing that ssh connection is being used without configured ssh agent, with a link to the docs is probably the best what we can do. I also like the idea of cached ssh connections, seems totally reasonable (i.e. we're using http connection pool in the http client, why not in ssh?). But I'm a bit skeptical about performance benefits it could give, unless for some edge-cases where someone is trying to deploy tens of files / VMs in one shot. I guess PVE won't be happy in this scenario anyway, having IO bottlenecks most likely. |
You are right. The API calls are skipped only for "new" resource, and any existing resource in terraform state will cause read, thereby verifying that provider is still configured correctly to use proxmox API.
According to the SDK documentation, it should be called for new resources. It looks like the issue with values from other resources is limited to The problem is the large number of ssh connections it would cause, up to 5 connections per VM (boot disk
Correct, the performance improvement compared to current state would not be noticable.
The ability to start a long terraform run (with slow downloads), without having to be near the computer to ensure that ssh can connect later:
|
Seems like there is another (consistent) way to check the plan: https://developer.hashicorp.com/terraform/plugin/framework/resources/plan-modification |
Hi, sorry to hop on the issue but it felt approriate. I simply would like to add that they are two features about the SSH part of the provider that would be nice to have:
|
Marking this issue as stale due to inactivity in the past 180 days. This helps us focus on the active issues. If this issue is reproducible with the latest version of the provider, please comment. If this issue receives no comments in the next 30 days it will automatically be closed. If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you! |
Is your feature request related to a problem? Please describe.
As a new user it is not completely clear that this module uses SSH under the hood for certain resources.
This could be because of various reasons:
In all of the cases, they would never be in contact with the documentation.
This makes finding the root cause of certain problems harder such as:
Error: failed to open SSH client: failed to dial 192.168.178.147:22: ssh: handshake failed: REMOTE HOST IDENTIFICATION HAS CHANGED for host 192.168.178.147:22! This may indicate a MitM attack)
Error: failed to open SSH client: failed to dial 10.0.0.2:22: dial tcp 10.0.0.2:22: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
This is also closely related to issues where the automatic detection of the IP address for SSH is not working and leaves the user clueless.
Describe the solution you'd like
Make it more obvious that SSH is used, e.g. by
Option 1Requiring to enable SSH in the provider, throws an error when using resources with SSH functionality (on
terraform plan
)This could be done by introducing a new argument in the
ssh
provider block.Option 2
Fail early by adding a connection check during the plan phase (for resources using SSH).
Describe alternatives you've considered
Live with it. Their fault if they did not read the f****** manual. :D
The text was updated successfully, but these errors were encountered: