Skip to content

Commit

Permalink
Fix erroneous override of work unit status
Browse files Browse the repository at this point in the history
Co-Authored-By: Seth Foster <[email protected]>
  • Loading branch information
2 people authored and AaronH88 committed Feb 7, 2024
1 parent 414c76d commit 7eaf7f2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ func (kw *kubeUnit) kubeLoggingWithReconnect(streamWait *sync.WaitGroup, stdout

for {
if *stdinErr != nil {
break
// fail to send stdin to pod, no need to continue
return
}

// get pod, with retry
Expand All @@ -224,12 +225,14 @@ func (kw *kubeUnit) kubeLoggingWithReconnect(streamWait *sync.WaitGroup, stdout
kw.GetWorkceptor().nc.GetLogger().Error(errMsg)
kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0)

break
// fail to get pod, no need to continue
return
}

logStream, err := kw.kubeLoggingConnectionHandler(true, sinceTime)
if err != nil {
break
// fail to get log stream, no need to continue
return
}

// read from logstream
Expand Down Expand Up @@ -739,7 +742,8 @@ func (kw *kubeUnit) runWorkUsingLogger() {
return
}

if kw.GetContext().Err() != context.Canceled {
// only transition from WorkStateRunning to WorkStateSucceeded if WorkStateFailed is set we do not override
if kw.GetContext().Err() != context.Canceled && kw.Status().State == WorkStateRunning {
kw.UpdateBasicStatus(WorkStateSucceeded, "Finished", stdout.Size())
}
}
Expand Down

0 comments on commit 7eaf7f2

Please sign in to comment.