From 419a17034fae6657cdb427c82b1e0712909be5c7 Mon Sep 17 00:00:00 2001 From: Jordan Brockopp Date: Thu, 27 Feb 2020 11:32:29 -0600 Subject: [PATCH] fix: cleanup of build resources (#64) --- cmd/server/operate.go | 9 ++++++++- executor/linux/build.go | 12 ++++++------ runtime/docker/container.go | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cmd/server/operate.go b/cmd/server/operate.go index ddb74897..4f9c6898 100644 --- a/cmd/server/operate.go +++ b/cmd/server/operate.go @@ -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 { @@ -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") } }) diff --git a/executor/linux/build.go b/executor/linux/build.go index 2d3ffd9e..3bc0b7df 100644 --- a/executor/linux/build.go +++ b/executor/linux/build.go @@ -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) } } @@ -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) } } @@ -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) @@ -510,7 +510,7 @@ 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) } } @@ -518,14 +518,14 @@ func (c *client) DestroyBuild(ctx context.Context) error { // 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 diff --git a/runtime/docker/container.go b/runtime/docker/container.go index 060f7035..705e27a1 100644 --- a/runtime/docker/container.go +++ b/runtime/docker/container.go @@ -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