-
Notifications
You must be signed in to change notification settings - Fork 5.1k
fix: Minimize logging when waiting for ip address #21753
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,8 +56,7 @@ const ( | |
isoFilename = "boot2docker.iso" | ||
serialFileName = "serial.log" | ||
privateNetworkName = "docker-machines" | ||
|
||
defaultSSHUser = "docker" | ||
defaultSSHUser = "docker" | ||
) | ||
|
||
type Driver struct { | ||
|
@@ -521,13 +520,15 @@ func (d *Driver) Start() error { | |
if detect.NestedVM() { | ||
multiplier = 3 // will help with running in Free github action Macos VMs (takes 112+ retries on average) | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a variable instead of repeating cost maxAttempts := 60 * multiplier Same comment for vfkit.go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Would it be better to put maxAttempts in the const section instead of defining it at the top of the loop? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes it must be in the function and unfortunately const will not work in Go for local value that cannot change after setting it. |
||
for i := 0; i < 60*multiplier; i++ { | ||
log.Debugf("Attempt %d", i) | ||
|
||
maxAttempts := 60 * multiplier | ||
for i := 0; i < maxAttempts; i++ { | ||
err = getIP() | ||
if err == nil { | ||
break | ||
} | ||
time.Sleep(2 * time.Second) | ||
log.Debugf("Searching for %s in %s (attempt %d/%d)", d.MACAddress, common.LeasesPath, i+1, maxAttempts) | ||
} | ||
|
||
if err == nil { | ||
|
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.
Add a constant for maxAttempts since we need it twice:
This will also make it more consistent with other drivers, which will make it easier to extract this loop to a helper function, since all the drivers use the similar logic.