1
0
mirror of https://github.com/rancher/os.git synced 2025-07-10 05:13:03 +00:00

Waiting for the network if service has label io.rancher.os.after=network

This commit is contained in:
niusmallnan 2019-09-29 10:31:33 +08:00 committed by niusmallnan
parent ce9d497890
commit ebc170def6

View File

@ -6,6 +6,7 @@ import (
"github.com/rancher/os/config"
"github.com/rancher/os/pkg/log"
"github.com/rancher/os/pkg/util/network"
"github.com/docker/docker/layer"
dockerclient "github.com/docker/engine-api/client"
@ -134,6 +135,13 @@ func (s *Service) shouldRebuild(ctx context.Context) (bool, error) {
func (s *Service) Up(ctx context.Context, options options.Up) error {
labels := s.Config().Labels
// wait for networking if necessary
if after := labels["io.rancher.os.after"]; after == "network" {
if err := network.AllDefaultGWOK(network.DefaultRoutesCheckTimeout); err != nil {
log.Warnf("Timeout to wait for the networking ready: %v", err)
}
}
if err := s.Service.Create(ctx, options.Create); err != nil {
return err
}