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

[Windows] Interacting with the regions cache hangs forever + Impossible to read stdin #809

Open
EtienneM opened this issue Oct 5, 2022 · 5 comments

Comments

@EtienneM
Copy link
Member

EtienneM commented Oct 5, 2022

When executing the command DEBUG=1 scalingo apps:

[DEBUG]2022/09/28 14:04:06 [Regions] Get the list of regions to fill the cache
[DEBUG]2022/09/28 14:04:06 [API] POST https://auth.scalingo.com/v1/tokens/exchange
[DEBUG]2022/09/28 14:04:06       User Agent: Scalingo CLI v1.25.1
[DEBUG]2022/09/28 14:04:06       Headers: map[User-Agent:[Scalingo CLI v1.25.1]]
[DEBUG]2022/09/28 14:04:06       Params: map[]
[DEBUG]2022/09/28 14:04:07       Request ID: 25b4025f-c8d4-45d8-9af8-45927548f6da
[DEBUG]2022/09/28 14:04:07       Duration: 321.7573ms
[DEBUG]2022/09/28 14:04:07 [API] GET https://auth.scalingo.com/v1/regions?
[DEBUG]2022/09/28 14:04:07       User Agent: Scalingo CLI v1.25.1
[DEBUG]2022/09/28 14:04:07       Headers: map[User-Agent:[Scalingo CLI v1.25.1]]
[DEBUG]2022/09/28 14:04:07       Params: map[]
[DEBUG]2022/09/28 14:04:07       Request ID: 8d17bea5-d893-4057-891c-f3c9ae81e4fe
[DEBUG]2022/09/28 14:04:07       Duration: 145.8675ms
[DEBUG]2022/09/28 14:04:07 {"regions":[{"name":"osc-fr1","display_name":"Paris - Outscale","api":"https://api.osc-fr1.scalingo.com/","database_api":"https://db-api.osc-fr1.scalingo.com/","dashboard":"https://dashboard.scalingo.com/","ssh":"ssh.osc-fr1.scalingo.com:22","default":true}]}

Then it hangs forever. The execution of any command will actually hang except if the region name is explicitly mentioned with --region my-region.

If the cache already contains data, the CLI also hangs forever but the logs are:

[DEBUG]2022/06/23 18:22:21 [Regions] Use the cache

The second issue is that login does not work with the following error between the username being entered, and the prompt for the password:

 !     Fail to login (1/3): fail to read the password on stdin: The handle is invalid.

Reported to the Go team: golang/go#34612

This issue supersedes #734 and #735. SRE issue is SRE-573.

Customers impacted we need to contact when releasing the fix:
https://app.intercom.com/a/apps/w4oogu7s/inbox/inbox/3379738/conversations/12375700071636
https://app.intercom.com/a/inbox/w4oogu7s/inbox/shared/all/conversation/12375700080025
https://app.intercom.com/a/apps/w4oogu7s/inbox/inbox/3379738/conversations/12375700081105
https://app.intercom.com/a/inbox/w4oogu7s/inbox/shared/all/conversation/12375700072124
https://app.intercom.com/a/apps/w4oogu7s/inbox/inbox/all/conversations/12375700129807

@EtienneM EtienneM self-assigned this Oct 6, 2022
@EtienneM EtienneM changed the title [Windows] Interacting with the regions cache hangs forever [Windows] Interacting with the regions cache hangs forever + Impossible to read stdin Oct 7, 2022
@EtienneM
Copy link
Member Author

EtienneM commented Oct 7, 2022

Cross post with the following issue: golang/go#34612 (comment)


We are facing the same issue but found out something slightly odd. First, we use the new golang.org/x/term package rather than x/crypto/ssh/terminal as mentioned in the title of this issue.

We face the same issue as described in this issue in Git Bash. The code is here: https://github.com/Scalingo/cli/blob/master/term/password.go#L13

But if we run Git Bash from within the terminal tab of VS Code, we no longer face the same issue, everything works as expected.

Does anyone know what is the difference between Git Bash and Git Bash inside VS Code?

I uploaded the smallest example which reproduces the issue here: https://github.com/EtienneM/mwe_read_password/blob/master/main.go

I'm not exactly sure about what information may be needed. My OS version:

C:\Users\Administrator>systeminfo | findstr /B /C:"OS Name" /C:"OS Version"

OS Name:                   Microsoft Windows Server 2019 Datacenter
OS Version:                10.0.17763 N/A Build 17763

The Go version:

C:\Users\Administrator>go version
go version go1.19.2 windows/amd64

The golang.org/x/term version is:

$ cat go.mod | grep "golang.org/x/term"
require golang.org/x/term v0.0.0-20220919170432-7a66f970e087

With this example, in Git Bash in VS Code I can type a password and the output is:

$ go build && ./mwe.exe
<nil>

In Git Bash outside of VS Code, I can't type the password and immediately get the error:

$ go build && ./mwe.exe
The handle is invalid.

@EtienneM EtienneM removed their assignment Oct 7, 2022
@Barokai
Copy link

Barokai commented Nov 4, 2022

Having the same issue on Windows 11, with PowerShell 7.2.7 and cmd.exe in Windows Terminal.
Using Scalingo Client version 1.26.0

@EtienneM
Copy link
Member Author

EtienneM commented Dec 1, 2022

A workaround could be to disable the regions cache on Windows.

@EtienneM EtienneM self-assigned this Dec 1, 2022
@EtienneM EtienneM removed their assignment Feb 13, 2023
@yanjost
Copy link

yanjost commented Jul 27, 2023

Still hangs with version 1.29.1 in Git Bash on Windows.
Authentication via SSH keys, so I think terminal interaction is to exclude as source of the issue
Given workaround (passing region as parameter is working)

@yanjost
Copy link

yanjost commented Jul 27, 2023

IMHO it's related to trying to write the cache file. The code seems to hang when trying to store a file in the user home directory

Maybe related to Windows security, which is quite paranoid with the access rights on user directories

I would sugget using os.UserHomeDir() and os.UserCacheDir() to get the right paths to write to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants