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

use longer time if deadline is set #375

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion support/kwok/kwok.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ func (k *Cluster) initKubernetesAccessClients() error {
return nil
}

// Create creates a cluster. If Cluster is created by NewCluster, the time to wait for the cluster to be ready is 1 minute.
// Longer time is preferred, if ctx has a deadline.
func (k *Cluster) Create(ctx context.Context, args ...string) (string, error) {
klog.V(4).Info("Creating a kwok cluster ", k.name)
if err := k.findOrInstallKwokCtl(); err != nil {
Expand All @@ -132,7 +134,13 @@ func (k *Cluster) Create(ctx context.Context, args ...string) (string, error) {
return k.getKubeconfig()
}

command := fmt.Sprintf(`%s create cluster --name %s --wait %s`, k.path, k.name, k.waitDuration.String())
wait := k.waitDuration
waitTime, ok := ctx.Deadline()
// If the deadline is set and the wait time is less than the time left before the deadline, then we should use the wait time
if ok && waitTime.Before(time.Now().Add(wait)) {
wait = time.Until(waitTime)
}
command := fmt.Sprintf(`%s create cluster --name %s --wait %s`, k.path, k.name, wait)
if len(args) > 0 {
command = fmt.Sprintf("%s %s", command, strings.Join(args, " "))
}
Expand Down