Skip to content

Commit

Permalink
fix: cleanup of build resources (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockopp authored Feb 27, 2020
1 parent 6a638e9 commit 419a170
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
9 changes: 8 additions & 1 deletion cmd/server/operate.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func operate(q queue.Service, e map[int]executor.Engine, t time.Duration) (err e
}()

defer func() {
// destroying the build on the executor
// destroy the build on the executor
logger.Info("destroying build")
err = executor.DestroyBuild(context.Background())
if err != nil {
Expand All @@ -99,6 +99,13 @@ func operate(q queue.Service, e map[int]executor.Engine, t time.Duration) (err e
return err
}

// destroy the build on the executor
logger.Info("destroying build")
err = executor.DestroyBuild(context.Background())
if err != nil {
logger.Errorf("unable to destroy build: %v", err)
}

logger.Info("completed build")
}
})
Expand Down
12 changes: 6 additions & 6 deletions executor/linux/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func (c *client) DestroyBuild(ctx context.Context) error {
// destroy the step
err = c.DestroyStep(ctx, s)
if err != nil {
c.logger.Errorf("unable to destroy step: %w", err)
c.logger.Errorf("unable to destroy step: %v", err)
}
}

Expand All @@ -483,7 +483,7 @@ func (c *client) DestroyBuild(ctx context.Context) error {
// destroy the stage
err = c.DestroyStage(ctx, s)
if err != nil {
c.logger.Errorf("unable to destroy stage: %w", err)
c.logger.Errorf("unable to destroy stage: %v", err)
}
}

Expand All @@ -493,7 +493,7 @@ func (c *client) DestroyBuild(ctx context.Context) error {
// destroy the service
err = c.DestroyService(ctx, s)
if err != nil {
c.logger.Errorf("unable to destroy service: %w", err)
c.logger.Errorf("unable to destroy service: %v", err)
}

c.logger.Infof("uploading %s service state", s.Name)
Expand All @@ -510,22 +510,22 @@ func (c *client) DestroyBuild(ctx context.Context) error {

_, _, err = c.Vela.Svc.Update(r.GetOrg(), r.GetName(), b.GetNumber(), cService)
if err != nil {
c.logger.Errorf("unable to upload service status: %w", err)
c.logger.Errorf("unable to upload service status: %v", err)
}
}

c.logger.Info("deleting volume")
// remove the runtime volume for the pipeline
err = c.Runtime.RemoveVolume(ctx, p)
if err != nil {
c.logger.Errorf("unable to remove volume: %w", err)
c.logger.Errorf("unable to remove volume: %v", err)
}

c.logger.Info("deleting network")
// remove the runtime network for the pipeline
err = c.Runtime.RemoveNetwork(ctx, p)
if err != nil {
c.logger.Errorf("unable to remove network: %w", err)
c.logger.Errorf("unable to remove network: %v", err)
}

return err
Expand Down
2 changes: 1 addition & 1 deletion runtime/docker/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func ctnConfig(ctn *pipeline.Container) *container.Config {
// parse image from container
image, err := parseImage(ctn.Image)
if err != nil {
logrus.Errorf("unable to parse image: %w", err)
logrus.Errorf("unable to parse image: %v", err)
}

// create container config object
Expand Down

0 comments on commit 419a170

Please sign in to comment.