Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add remote_work close errors #1195

Merged
Merged
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
30 changes: 24 additions & 6 deletions pkg/workceptor/remote_work.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,10 @@
go func() {
conn, reader := rw.getConnection(ctx)
if conn != nil {
_ = action(ctx, conn, reader)
err := action(ctx, conn, reader)
if err != nil {
rw.GetWorkceptor().nc.GetLogger().Error("Error running action function: %s", err)
}

Check warning on line 142 in pkg/workceptor/remote_work.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/remote_work.go#L139-L142

Added lines #L139 - L142 were not covered by tests
} else {
failure()
}
Expand Down Expand Up @@ -297,15 +300,21 @@
_, err := conn.Write([]byte(fmt.Sprintf("work status %s\n", remoteUnitID)))
if err != nil {
rw.GetWorkceptor().nc.GetLogger().Debug("Write error sending to %s: %s\n", remoteUnitID, err)
_ = conn.(interface{ CloseConnection() error }).CloseConnection()
cerr := conn.(interface{ CloseConnection() error }).CloseConnection()
if cerr != nil {
rw.GetWorkceptor().nc.GetLogger().Error("Error closing connection to remote work unit %s: %s", remoteUnitID, cerr)
}

Check warning on line 306 in pkg/workceptor/remote_work.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/remote_work.go#L303-L306

Added lines #L303 - L306 were not covered by tests
conn = nil

continue
}
status, err := utils.ReadStringContext(mw, reader, '\n')
if err != nil {
rw.GetWorkceptor().nc.GetLogger().Debug("Read error reading from %s: %s\n", remoteNode, err)
_ = conn.(interface{ CloseConnection() error }).CloseConnection()
cerr := conn.(interface{ CloseConnection() error }).CloseConnection()
if cerr != nil {
rw.GetWorkceptor().nc.GetLogger().Error("Error closing connection from node %s: %s", remoteNode, cerr)
}

Check warning on line 317 in pkg/workceptor/remote_work.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/remote_work.go#L314-L317

Added lines #L314 - L317 were not covered by tests
conn = nil

continue
Expand Down Expand Up @@ -404,7 +413,10 @@
conn, reader := rw.getConnection(mw)
defer func() {
if conn != nil {
_ = conn.(interface{ CloseConnection() error }).CloseConnection()
cerr := conn.(interface{ CloseConnection() error }).CloseConnection()
if cerr != nil {
rw.GetWorkceptor().nc.GetLogger().Error("Error closing connection to %s: %s", remoteUnitID, cerr)
}

Check warning on line 419 in pkg/workceptor/remote_work.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/remote_work.go#L416-L419

Added lines #L416 - L419 were not covered by tests
}
}()
if conn == nil {
Expand Down Expand Up @@ -464,7 +476,10 @@
if ok {
cr.CancelRead()
}
_ = conn.(interface{ CloseConnection() error }).CloseConnection()
cerr := conn.(interface{ CloseConnection() error }).CloseConnection()
if cerr != nil {
rw.GetWorkceptor().nc.GetLogger().Error("Error closing connection to %s: %s", remoteUnitID, cerr)
}

Check warning on line 482 in pkg/workceptor/remote_work.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/remote_work.go#L479-L482

Added lines #L479 - L482 were not covered by tests

return
}
Expand Down Expand Up @@ -657,9 +672,12 @@
return nil
}
if release && force {
_ = rw.connectAndRun(rw.GetWorkceptor().ctx, func(ctx context.Context, conn net.Conn, reader *bufio.Reader) error {
err := rw.connectAndRun(rw.GetWorkceptor().ctx, func(ctx context.Context, conn net.Conn, reader *bufio.Reader) error {

Check warning on line 675 in pkg/workceptor/remote_work.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/remote_work.go#L675

Added line #L675 was not covered by tests
return rw.cancelOrReleaseRemoteUnit(ctx, conn, reader, true)
})
if err != nil {
rw.GetWorkceptor().nc.GetLogger().Error("Error with connect and run: %s", err)
}

Check warning on line 680 in pkg/workceptor/remote_work.go

View check run for this annotation

Codecov / codecov/patch

pkg/workceptor/remote_work.go#L678-L680

Added lines #L678 - L680 were not covered by tests

return rw.BaseWorkUnitForWorkUnit.Release(true)
}
Expand Down