mirror of
https://github.com/dokku/dokku.git
synced 2025-12-29 00:25:08 +01:00
Merge pull request #7329 from dokku/k3s-correct-wait
Correctly wait for one-off k3s pods to be ready
This commit is contained in:
@@ -52,7 +52,7 @@ type EnterPodInput struct {
|
||||
SelectedPod v1.Pod
|
||||
|
||||
// WaitTimeout is the timeout to wait for the pod to be ready
|
||||
WaitTimeout int
|
||||
WaitTimeout float64
|
||||
}
|
||||
|
||||
// Node contains information about a node
|
||||
@@ -110,7 +110,7 @@ type WaitForPodBySelectorRunningInput struct {
|
||||
Namespace string
|
||||
LabelSelector string
|
||||
PodName string
|
||||
Timeout int
|
||||
Timeout float64
|
||||
Waiter func(ctx context.Context, clientset KubernetesClient, podName, namespace string) wait.ConditionWithContextFunc
|
||||
}
|
||||
|
||||
@@ -374,8 +374,8 @@ func enterPod(ctx context.Context, input EnterPodInput) error {
|
||||
labelSelector = append(labelSelector, fmt.Sprintf("%s=%s", k, v))
|
||||
}
|
||||
|
||||
if input.WaitTimeout > 0 {
|
||||
input.WaitTimeout = 5
|
||||
if input.WaitTimeout == 0 {
|
||||
input.WaitTimeout = 10
|
||||
}
|
||||
|
||||
err := waitForPodBySelectorRunning(ctx, WaitForPodBySelectorRunningInput{
|
||||
@@ -1694,14 +1694,14 @@ func waitForPodBySelectorRunning(ctx context.Context, input WaitForPodBySelector
|
||||
RetryCount: 3,
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error waiting for pod to exist: %w", err)
|
||||
return err
|
||||
}
|
||||
|
||||
if len(pods) == 0 {
|
||||
return fmt.Errorf("no pods in %s with selector %s", input.Namespace, input.LabelSelector)
|
||||
}
|
||||
|
||||
timeout := time.Duration(input.Timeout) * time.Second
|
||||
timeout := time.Duration(input.Timeout * float64(time.Second))
|
||||
for _, pod := range pods {
|
||||
if input.PodName != "" && pod.Name != input.PodName {
|
||||
break
|
||||
@@ -1709,7 +1709,7 @@ func waitForPodBySelectorRunning(ctx context.Context, input WaitForPodBySelector
|
||||
|
||||
if err := wait.PollUntilContextTimeout(ctx, time.Second, timeout, false, input.Waiter(ctx, input.Clientset, pod.Name, pod.Namespace)); err != nil {
|
||||
print("\n")
|
||||
return fmt.Errorf("Error waiting for pod to be ready: %w", err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
print("\n")
|
||||
|
||||
@@ -1190,7 +1190,7 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args []
|
||||
Clientset: clientset,
|
||||
Namespace: namespace,
|
||||
LabelSelector: batchJobSelector,
|
||||
Timeout: 300,
|
||||
Timeout: 10,
|
||||
Waiter: isPodReady,
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1254,6 +1254,7 @@ func TriggerSchedulerRun(scheduler string, appName string, envCount int, args []
|
||||
Command: command,
|
||||
Entrypoint: entrypoint,
|
||||
SelectedPod: selectedPod,
|
||||
WaitTimeout: 10,
|
||||
})
|
||||
default:
|
||||
return fmt.Errorf("Unable to attach as the pod is in an unknown state: %s", selectedPod.Status.Phase)
|
||||
|
||||
Reference in New Issue
Block a user