mirror of https://github.com/docker/buildx.git
remote: use --bootstrap to wait for remote to become active
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:
parent
43968ffa68
commit
c245f30a94
|
@ -139,28 +139,13 @@ jobs:
|
|||
name: Launch remote buildkitd
|
||||
if: matrix.driver == 'remote'
|
||||
run: |
|
||||
docker run -d --privileged \
|
||||
docker run -d \
|
||||
--privileged \
|
||||
--name=remote-buildkit \
|
||||
-p 1234:1234 \
|
||||
--health-cmd "buildctl debug workers" \
|
||||
--health-interval 1s \
|
||||
${{ matrix.buildkit }} \
|
||||
--addr unix:///run/buildkit/buildkitd.sock \
|
||||
--addr tcp://0.0.0.0:1234
|
||||
-
|
||||
name: Check remote buildkitd
|
||||
if: matrix.driver == 'remote'
|
||||
run: |
|
||||
try=0
|
||||
max=10
|
||||
until [ "$(docker container inspect remote-buildkit --format '{{ .State.Health.Status }}')" = "healthy" ]; do
|
||||
if [ $try -gt $max ]; then
|
||||
echo >&2 "healthcheck failed after $max trials"
|
||||
exit 1
|
||||
fi
|
||||
sleep $(awk "BEGIN{print (100 + $try * 20) * 0.002}")
|
||||
try=$(expr $try + 1)
|
||||
done
|
||||
-
|
||||
name: Test
|
||||
run: |
|
||||
|
|
|
@ -2,11 +2,11 @@ package remote
|
|||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/docker/buildx/driver"
|
||||
"github.com/docker/buildx/util/progress"
|
||||
"github.com/moby/buildkit/client"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type Driver struct {
|
||||
|
@ -23,17 +23,39 @@ type tlsOpts struct {
|
|||
}
|
||||
|
||||
func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error {
|
||||
return nil
|
||||
for i := 0; ; i++ {
|
||||
info, err := d.Info(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if info.Status != driver.Inactive {
|
||||
return nil
|
||||
}
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
default:
|
||||
if i > 10 {
|
||||
i = 10
|
||||
}
|
||||
time.Sleep(time.Duration(i) * time.Second)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Driver) Info(ctx context.Context) (*driver.Info, error) {
|
||||
c, err := d.Client(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(driver.ErrNotConnecting, err.Error())
|
||||
return &driver.Info{
|
||||
Status: driver.Inactive,
|
||||
}, nil
|
||||
}
|
||||
|
||||
if _, err := c.ListWorkers(ctx); err != nil {
|
||||
return nil, errors.Wrapf(driver.ErrNotConnecting, err.Error())
|
||||
return &driver.Info{
|
||||
Status: driver.Inactive,
|
||||
}, nil
|
||||
}
|
||||
|
||||
return &driver.Info{
|
||||
|
|
|
@ -55,6 +55,7 @@ if [ "$DRIVER" != "docker" ]; then
|
|||
createFlags="$createFlags --append"
|
||||
fi
|
||||
buildxCmd create ${createFlags} \
|
||||
--bootstrap \
|
||||
--name="${builderName}" \
|
||||
--node="${builderName}-${platform/\//-}" \
|
||||
--platform="${platform}" \
|
||||
|
@ -69,6 +70,7 @@ if [ "$DRIVER" != "docker" ]; then
|
|||
createFlags="$createFlags --config=${BUILDKIT_CFG}"
|
||||
fi
|
||||
buildxCmd create ${createFlags} \
|
||||
--bootstrap \
|
||||
--name="${builderName}" \
|
||||
--platform="${PLATFORMS}" \
|
||||
--driver="${DRIVER}" \
|
||||
|
|
Loading…
Reference in New Issue