-
Notifications
You must be signed in to change notification settings - Fork 42
fix aws ssh issue #446
fix aws ssh issue #446
Conversation
The string output check should be succeeded
pkg/cmd/ssh_aws.go
Outdated
@@ -242,7 +246,7 @@ func (a *AwsInstanceAttribute) sshPortCheck() { | |||
cmd := exec.Command("bash", "-c", ncCmd) | |||
output, _ := cmd.CombinedOutput() | |||
fmt.Println("=>", string(output)) | |||
if strings.Contains(string(output), "succeeded") { | |||
if strings.Contains(string(output), "open") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this should be succeeded
.
With open
, I get:
Bastion host instance running.
Opened SSH Port on Node.
Waiting 60 seconds for Bastion SSH port open
=> Connection to ... port 22 [tcp/*] succeeded!
=> Connection to ... port 22 [tcp/*] succeeded!
=> Connection to ... port 22 [tcp/*] succeeded!
=> Connection to ... port 22 [tcp/*] succeeded!
=> Connection to ... port 22 [tcp/*] succeeded!
=> Connection to ... port 22 [tcp/*] succeeded!
SSH Port Open on Bastion TimeOut
(4/4) Cleanup
Cleaning up bastion host configurations...
With succeeded
:
Bastion host instance running.
Opened SSH Port on Node.
Waiting 60 seconds for Bastion SSH port open
=> Connection to ... port 22 [tcp/*] succeeded!
Opened SSH Port on Bastion
SSH gardener@... => gardener@ip-...compute.internal
Warning: Permanently added '...' (ED25519) to the list of known hosts.
Warning: Permanently added 'ip-....compute.internal' (ED25519) to the list of known hosts.
(4/4) Cleanup
Cleaning up bastion host configurations...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dansible , i used a newly introduced function CheckIPPortReachable
which is using native go code (so we don't have dependency on different version of binary like your nc returns succeeded but mine returns open) to perform ssh port check
pkg/cmd/ssh_aws.go
Outdated
@@ -242,7 +246,7 @@ func (a *AwsInstanceAttribute) sshPortCheck() { | |||
cmd := exec.Command("bash", "-c", ncCmd) | |||
output, _ := cmd.CombinedOutput() | |||
fmt.Println("=>", string(output)) | |||
if strings.Contains(string(output), "succeeded") { | |||
if strings.Contains(string(output), "open") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of sshPortCheck()
, can't we reuse the newly introduced [function]?(https://github.com/gardener/gardenctl/pull/445/files#diff-8a970d51dea43e926c0b913c26887464b362c5f723fb1d740a5a07d428434c07R355)
func CheckIPPortReachable(ip string, port string) error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @petersutter , i add retry logic in CheckIPPortReachable
function and use it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's what I was asking in the other PR #445 (comment)
and this works without having to dial/try multiple times within a certain amount of time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, previously i though it was working as retry but later i found it's not, so i added the logic
87a0b58
to
3637bc6
Compare
pkg/cmd/utils.go
Outdated
fmt.Printf("IP %s port %s is reachable\n", ip, port) | ||
return nil | ||
} | ||
time.Sleep(time.Second * 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there a need to sleep 10 seconds?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, i removed this line
pkg/cmd/utils.go
Outdated
@@ -349,17 +349,22 @@ func PrintoutObject(objectToPrint interface{}, writer io.Writer, outputFormat st | |||
return nil | |||
} | |||
|
|||
//CheckIPPortReachable check whether IP with port is reachable with 1 min | |||
//CheckIPPortReachable check whether IP with port is reachable with 2 min |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//CheckIPPortReachable check whether IP with port is reachable with 2 min | |
//CheckIPPortReachable check whether IP with port is reachable within 2 min |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, i fixed the typo
pkg/cmd/utils.go
Outdated
timeout := time.Second * 10 | ||
conn, err := net.DialTimeout("tcp", net.JoinHostPort(ip, port), timeout) | ||
if err != nil { | ||
fmt.Println("Connecting error:", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either omit the error as long as you are retrying or add a hint in case another try is made
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, i omitted the error
3637bc6
to
dd3c4df
Compare
build failed due to #455 , |
How could this even happen in the first place, that code slips into |
2d3d580
to
de1beb7
Compare
all check passed after #455 is fixed , @petersutter could you please review this PR when you have time? thanks! |
pkg/cmd/utils.go
Outdated
defer conn.Close() | ||
fmt.Printf("IP %s port %s is reachable\n", ip, port) | ||
return nil | ||
attemptCnt := 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would rather name it attemptCount or just attempt.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
feel free to also change the variable name as suggested.
What this PR does / why we need it:
fix aws ssh issue
Which issue(s) this PR fixes:
Fixes #442
Special notes for your reviewer:
nc -vtnz ip port
returns sth like127.0.0.1 49269 open
so the result should grepopen
, instead ofsucceed
not sure my
nc
is correct onefix a small typo,
shh
tossh
when bastion exist,
a.BastionPrivIP
anda.BastionIP
should also be assigned with values (like what they are treat in non bastion exist path) , otherwise following step will fail due to these two properties emptyRelease note: