From ebc170def661fcb34fa2ce0adec52b26cbb7d1a0 Mon Sep 17 00:00:00 2001 From: niusmallnan Date: Sun, 29 Sep 2019 10:31:33 +0800 Subject: [PATCH] Waiting for the network if service has label io.rancher.os.after=network --- pkg/docker/service.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/docker/service.go b/pkg/docker/service.go index b132b4dd..f5565539 100644 --- a/pkg/docker/service.go +++ b/pkg/docker/service.go @@ -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 }