Skip to content

Commit

Permalink
Fix kubernetes error checking in 2 places (#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
thom-at-redhat authored Oct 29, 2024
1 parent 137a7aa commit 875e98c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pkg/workceptor/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -1019,7 +1019,15 @@ func (kw *KubeUnit) runWorkUsingTCP() {
connChan := make(chan *net.TCPConn)
go func() {
conn, err := li.Accept()
_ = li.Close()
lcerr := li.Close()
if lcerr != nil {
errMsg := fmt.Sprintf("Error closing listener: %+v", lcerr)
kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0)
kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet
cancel()

return
}
if ctx.Err() != nil {
return
}
Expand Down Expand Up @@ -1092,7 +1100,15 @@ func (kw *KubeUnit) runWorkUsingTCP() {
if ctx.Err() != nil {
return
}
_ = conn.CloseWrite()
cwerr := conn.CloseWrite()
if cwerr != nil {
errMsg := fmt.Sprintf("Error closing writing side: %+v", cwerr)
kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet
kw.UpdateBasicStatus(WorkStateFailed, errMsg, 0)
cancel()

return
}
if err != nil {
errMsg := fmt.Sprintf("Error sending stdin to pod: %s", err)
kw.GetWorkceptor().nc.GetLogger().Error(errMsg) //nolint:govet
Expand Down

0 comments on commit 875e98c

Please sign in to comment.