-
Notifications
You must be signed in to change notification settings - Fork 62
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
create kind network #67
Conversation
322364d
to
887542e
Compare
Signed-off-by: Manabu Mccloskey <[email protected]>
Signed-off-by: Manabu Mccloskey <[email protected]>
887542e
to
a79b6ec
Compare
Signed-off-by: Manabu Mccloskey <[email protected]>
Signed-off-by: Manabu Mccloskey <[email protected]>
Signed-off-by: Manabu Mccloskey <[email protected]>
Well, it passes the tests now. I will say that this is very fragile and I can't reproduce the previous test failures on my Linux system. Good news is that we don't need these tests going forward. |
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
yay, first green build. thanks!
for { | ||
if time.Now().After(endTime) { | ||
t.Fatalf("Timed out waiting for port %d to be available", kind.ExposedRegistryPort) | ||
} | ||
conn, cErr := net.DialTimeout("tcp", net.JoinHostPort("0.0.0.0", strconv.Itoa(int(kind.ExposedRegistryPort))), time.Second*3) | ||
if cErr != nil { | ||
break | ||
} | ||
conn.Close() | ||
time.Sleep(waitInterval) |
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.
cosmetics here but pushing the check to a go func
would be nicer
for { | |
if time.Now().After(endTime) { | |
t.Fatalf("Timed out waiting for port %d to be available", kind.ExposedRegistryPort) | |
} | |
conn, cErr := net.DialTimeout("tcp", net.JoinHostPort("0.0.0.0", strconv.Itoa(int(kind.ExposedRegistryPort))), time.Second*3) | |
if cErr != nil { | |
break | |
} | |
conn.Close() | |
time.Sleep(waitInterval) | |
ready := make(chan bool) | |
endTime := time.After(waitTimeout) | |
go func() { | |
for { | |
.... | |
if cErr == nil { | |
close(ready) | |
} | |
} | |
}() | |
select { | |
case <-timeout: | |
err := errors.New("Timeout") | |
log.Error(err, "Didn't reconcile Gitea on time.") | |
return ctrl.Result{}, err | |
case <-ready: | |
log.Info("Gitea is ready!") | |
resource.Status.GiteaAvailable = true | |
} |
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.
I'm using the same format that was used here:
endTime := time.Now().Add(timeout) |
If we are using timeout, we should use the same logic everywhere or make it reusable. not worth the time effort imo.
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.
yeah not a big deal, lets get it over the line.
endTime := time.Now().Add(waitTimeout) | ||
|
||
for { | ||
if time.Now().After(endTime) { | ||
t.Fatalf("Timed out waiting for registry. recent error: %v", 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.
same as above
The test assume we have a docker network named "kind". Since the test only cares about registry image, we'll just create the network prior to reconciling.
Note that we will not need this functionality going forward. If we did, I think the way @cmoulliard did with test containers is the way to go. I want to fix tests so we don't run into test failures for unrelated PRs.
fixes: #28