nrkno / terraform-provider-lastpass

Terraform Lastpass provider
Apache License 2.0
61 stars 7 forks source link

The STDIO streams did not close within 10 seconds of the exit event from process '/usr/bin/pwsh'. This may indicate a child process inherited the STDIO streams and has not yet exited. #49

Open mattduguid opened 3 years ago

mattduguid commented 3 years ago

Recently we have been trying to get the terraform provider nrkno/lastpass working and we think we have 2 issues which are related to each other so initially have logged them as 1.

Hierarchy of how we have things running,

  1. Azure DevOps Hosted Agent (ubuntu 20.04.2 LTS)
  2. Azure DevOps Pipeline Task (AzurePowerShell@4)
  3. all required environment variables set (LASTPASS_USER, LASTPASS_PASSWORD, LPASS_DISABLE_PINENTRY=1, LPASS_HOME, PATH, etc)
  4. terraform (v0.14.6) and lpass cli (v1.3.3.15.g8767b5e) binaries
  5. terraform provider nrkno/lastpass (v0.5.2)

Issue 1 - azure devops pipeline task hangs indefinitely

Even though it hangs this is after it has completed the task and we can write debug secrets out to screen from lastpass.

This only happens when we add the terraform provider nrkno/lastpass, if we take it away things run OK again.

The error is,

The STDIO streams did not close within 10 seconds of the exit event from process '/usr/bin/pwsh'. This may indicate a child process inherited the STDIO streams and has not yet exited.

To troubleshoot this we dumped a list of processes at start of task and end of task, the one that stood out was "lpass" as we'd expect this not to be running after exiting the provider task. We added some code to detect if the process was running and kill it and this does workaround the issue by closing the task and allowing the pipeline to complete.

We suspect its waiting for input but havent been able to see any useful information by using system.debug=true in Azure DevOps pipeline or $env:TF_LOG = "TRACE" in terraform.

While the workaround works for issue 1 keen to see if we can enable any other debug to determine why this is happening to fix the root cause.

Issue 2 - random failure to display secrets and prompting for password

We are trying to use the data resource to load 19 secrets from lastpass eg:

_data "lastpass_secret" "my_secret_name_1" { id = "1114567890123456789" } data "lastpass_secret" "my_secret_name2" { id = "2224567890123456789" } etc

We tried loading them all and got the following error,

Error Please enter the LastPass master password for ouruser@ourdomain.oursuffix.nz. Master Password: Error: Could not find decryption key. Perhaps you need to login with lpass login. Error Please enter the LastPass master password for ouruser@ourdomain.oursuffix.nz. Master Password: Error: Could not find decryption key. Perhaps you need to login with lpass login. The STDIO streams did not close within 10 seconds of the exit event from process /usr/bin/pwsh. This may indicate a child process inherited the STDIO streams and has not yet exited. Script Execution Complete

So we commented them all out then added them back 1 by 1 testing as we went. Initially we thought we had a couple of problem ones but then worked out through further testing none of them were special and this was failing randomly.

If we take it back to a single secret seems to work every time. We dont have a workaround for this but keen to see if we can enable any other debug to determine why this is happening.

Both issues throw up the same error tending to indicate something is holding the IO streams open which is why we think if we fix that issue we may resolve both.