Skip to content
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: 9 additions & 3 deletions pkg/app/piped/controller/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ func (s *scheduler) executeStage(sig executor.StopSignal, ps model.PipelineStage
lp = s.logPersister.StageLogPersister(s.deployment.Id, ps.Id)
)
defer func() {
// When the piped has been stopped while the stage is still running
// When the piped has been terminated (PS kill) while the stage is still running
// we should not mark the log persister as completed.
if !model.IsCompletedStage(finalStatus) && sig.Stopped() {
if !model.IsCompletedStage(finalStatus) && sig.Terminated() {
return
}
lp.Complete(time.Minute)
Expand Down Expand Up @@ -499,14 +499,20 @@ func (s *scheduler) executeStage(sig executor.StopSignal, ps model.PipelineStage
// Start running executor.
status := ex.Execute(sig)

// Commit deployment state status in the following cases:
// - Apply state successfully.
// - State was canceled while running (cancel via Controlpane).
// - Apply state failed but not because of terminating piped process.
if status == model.StageStatus_STAGE_SUCCESS ||
status == model.StageStatus_STAGE_CANCELLED ||
(status == model.StageStatus_STAGE_FAILURE && !sig.Stopped()) {
(status == model.StageStatus_STAGE_FAILURE && !sig.Terminated()) {

s.reportStageStatus(ctx, ps.Id, status, ps.Requires)
return status
}

// In case piped process got killed (Terminated signal occurred)
// the original state status will be returned.
return originalStatus
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/app/piped/executor/stopsignal.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type StopSignal interface {
Context() context.Context
Ch() <-chan StopSignalType
Signal() StopSignalType
Stopped() bool
Terminated() bool
}

type StopSignalHandler interface {
Expand Down Expand Up @@ -101,7 +101,7 @@ func (s *stopSignal) Signal() StopSignalType {
return StopSignalType(value)
}

func (s *stopSignal) Stopped() bool {
func (s *stopSignal) Terminated() bool {
value := s.signal.Load()
return StopSignalType(value) != StopSignalNone
return StopSignalType(value) == StopSignalTerminate
}