mirror of
https://github.com/docker/buildx.git
synced 2024-11-22 15:37:16 +08:00
kubernetes: add error when no pods available
This prevents the fall-through to the panic from division by zero in the modulus below, and presents a neater error to the user. Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
3cf549a7f7
commit
d9ef9bec34
@ -6,6 +6,7 @@ import (
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/serialx/hashring"
|
||||
"github.com/sirupsen/logrus"
|
||||
appsv1 "k8s.io/api/apps/v1"
|
||||
@ -29,6 +30,9 @@ func (pc *RandomPodChooser) ChoosePod(ctx context.Context) (*corev1.Pod, error)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(pods) == 0 {
|
||||
return nil, errors.New("no running buildkit pods found")
|
||||
}
|
||||
randSource := pc.RandSource
|
||||
if randSource == nil {
|
||||
randSource = rand.NewSource(time.Now().Unix())
|
||||
|
Loading…
Reference in New Issue
Block a user