Skip to content

Commit

Permalink
Async post-deploy actions for sonic
Browse files Browse the repository at this point in the history
  • Loading branch information
networkop committed Nov 5, 2021
1 parent 96a107f commit 7aa30b2
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions nodes/sonic/sonic.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func (s *sonic) Init(cfg *types.NodeConfig, opts ...nodes.NodeOption) error {
for _, o := range opts {
o(s)
}
// the entrypoint is reset to prevent it from starting before all interfaces are connected
// all main sonic agents are started in a post-deploy phase
s.cfg.Entrypoint = "/bin/bash"
return nil
}
Expand All @@ -48,22 +50,17 @@ func (s *sonic) Deploy(ctx context.Context) error {

func (s *sonic) PostDeploy(ctx context.Context, ns map[string]nodes.Node) error {
log.Debugf("Running postdeploy actions for sonic-vs '%s' node", s.cfg.ShortName)
// TODO: change this calls to c.ExecNotWait
// exec `supervisord` to start sonic services
_, stderr, err := s.runtime.Exec(ctx, s.cfg.ContainerID, []string{"supervisord"})

err := s.runtime.ExecNotWait(ctx, s.cfg.ContainerID, []string{"supervisord"})
if err != nil {
return err
}
if len(stderr) > 0 {
return fmt.Errorf("failed post-deploy node %q: %s", s.cfg.ShortName, string(stderr))
return fmt.Errorf("failed post-deploy node %q: %w", s.cfg.ShortName, err)
}
_, stderr, err = s.runtime.Exec(ctx, s.cfg.ContainerID, []string{"/usr/lib/frr/bgpd"})

err = s.runtime.ExecNotWait(ctx, s.cfg.ContainerID, []string{"supervisorctl start bgpd"})
if err != nil {
return err
}
if len(stderr) > 0 {
return fmt.Errorf("failed post-deploy node %q: %s", s.cfg.ShortName, string(stderr))
return fmt.Errorf("failed post-deploy node %q: %w", s.cfg.ShortName, err)
}

return nil
}

Expand Down

0 comments on commit 7aa30b2

Please sign in to comment.