Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

fix(cancel): remove SIGTERM in favor of executor.DestroyBuild #129

Merged
merged 2 commits into from
Feb 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions executor/linux/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@
package linux

import (
"context"
"fmt"
"os"
"syscall"
"time"

"github.com/go-vela/pkg-executor/internal/service"
Expand Down Expand Up @@ -191,14 +190,9 @@ func (c *client) CancelBuild() (*library.Build, error) {
}
}

p, err := os.FindProcess(os.Getpid())
err = c.DestroyBuild(context.Background())
if err != nil {
return nil, fmt.Errorf("unable to find PID: %v", err)
}

err = p.Signal(syscall.SIGTERM)
if err != nil {
return nil, fmt.Errorf("unable to cancel PID: %v", err)
c.logger.Errorf("unable to destroy build: %v", err)
}

return b, nil
Expand Down
11 changes: 3 additions & 8 deletions executor/local/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
package local

import (
"context"
"fmt"
"os"
"syscall"
"time"

"github.com/go-vela/pkg-executor/internal/service"
Expand Down Expand Up @@ -191,14 +191,9 @@ func (c *client) CancelBuild() (*library.Build, error) {
}
}

p, err := os.FindProcess(os.Getpid())
err = c.DestroyBuild(context.Background())
if err != nil {
return nil, fmt.Errorf("unable to find PID: %v", err)
}

err = p.Signal(syscall.SIGTERM)
if err != nil {
return nil, fmt.Errorf("unable to cancel PID: %v", err)
fmt.Fprintln(os.Stdout, "unable to destroy build:", err)
}

return b, nil
Expand Down