Commit bc7635f0 authored by Brad Davidson's avatar Brad Davidson Committed by Brad Davidson

Move containerd wait into exported function

parent fc8309a4
...@@ -94,9 +94,20 @@ func Run(ctx context.Context, cfg *config.Node) error { ...@@ -94,9 +94,20 @@ func Run(ctx context.Context, cfg *config.Node) error {
os.Exit(1) os.Exit(1)
}() }()
if err := WaitForContainerd(ctx, cfg.Containerd.Address); err != nil {
return err
}
return preloadImages(ctx, cfg)
}
// WaitForContainerd blocks in a retry loop until the Containerd CRI service
// is functional at the provided socket address. It will return only on success,
// or when the context is cancelled.
func WaitForContainerd(ctx context.Context, address string) error {
first := true first := true
for { for {
conn, err := CriConnection(ctx, cfg.Containerd.Address) conn, err := CriConnection(ctx, address)
if err == nil { if err == nil {
conn.Close() conn.Close()
break break
...@@ -113,8 +124,7 @@ func Run(ctx context.Context, cfg *config.Node) error { ...@@ -113,8 +124,7 @@ func Run(ctx context.Context, cfg *config.Node) error {
} }
} }
logrus.Info("Containerd is now running") logrus.Info("Containerd is now running")
return nil
return preloadImages(ctx, cfg)
} }
// preloadImages reads the contents of the agent images directory, and attempts to // preloadImages reads the contents of the agent images directory, and attempts to
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment