aboutsummaryrefslogtreecommitdiff
path: root/vendor/github.com/Microsoft/hcsshim/internal/hcs
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-04-12 12:23:11 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-04-12 12:23:11 -0400
commit986cd2a6a4b3e9f6ac54f96237bc1c9d1cea497b (patch)
tree26c0bbe76278880d6aaf7dc9b1f404d837a30ea1 /vendor/github.com/Microsoft/hcsshim/internal/hcs
parent3803a2630f2bc53f18cbf2b7a825ff1b068a0fb7 (diff)
downloadpodman-986cd2a6a4b3e9f6ac54f96237bc1c9d1cea497b.tar.gz
podman-986cd2a6a4b3e9f6ac54f96237bc1c9d1cea497b.tar.bz2
podman-986cd2a6a4b3e9f6ac54f96237bc1c9d1cea497b.zip
vendor in containers/storage v1.29.0
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'vendor/github.com/Microsoft/hcsshim/internal/hcs')
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go16
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go20
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go74
-rw-r--r--vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go1
4 files changed, 47 insertions, 64 deletions
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
index bca824b8e..7696e4b48 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
@@ -171,7 +171,6 @@ type SystemError struct {
ID string
Op string
Err error
- Extra string
Events []ErrorEvent
}
@@ -182,9 +181,6 @@ func (e *SystemError) Error() string {
for _, ev := range e.Events {
s += "\n" + ev.String()
}
- if e.Extra != "" {
- s += "\n(extra info: " + e.Extra + ")"
- }
return s
}
@@ -198,7 +194,7 @@ func (e *SystemError) Timeout() bool {
return ok && err.Timeout()
}
-func makeSystemError(system *System, op string, extra string, err error, events []ErrorEvent) error {
+func makeSystemError(system *System, op string, err error, events []ErrorEvent) error {
// Don't double wrap errors
if _, ok := err.(*SystemError); ok {
return err
@@ -206,7 +202,6 @@ func makeSystemError(system *System, op string, extra string, err error, events
return &SystemError{
ID: system.ID(),
Op: op,
- Extra: extra,
Err: err,
Events: events,
}
@@ -332,12 +327,3 @@ func getInnerError(err error) error {
}
return err
}
-
-func getOperationLogResult(err error) (string, error) {
- switch err {
- case nil:
- return "Success", nil
- default:
- return "Error", err
- }
-}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
index 2ad978f29..b74389eca 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
@@ -64,11 +64,7 @@ type processStatus struct {
LastWaitResult int32
}
-const (
- stdIn string = "StdIn"
- stdOut string = "StdOut"
- stdErr string = "StdErr"
-)
+const stdIn string = "StdIn"
const (
modifyConsoleSize string = "ConsoleSize"
@@ -176,8 +172,10 @@ func (process *Process) waitBackground() {
trace.Int64Attribute("pid", int64(process.processID)))
var (
- err error
- exitCode = -1
+ err error
+ exitCode = -1
+ propertiesJSON string
+ resultJSON string
)
err = waitForNotification(ctx, process.callbackNumber, hcsNotificationProcessExited, nil)
@@ -190,15 +188,15 @@ func (process *Process) waitBackground() {
// Make sure we didnt race with Close() here
if process.handle != 0 {
- propertiesJSON, resultJSON, err := vmcompute.HcsGetProcessProperties(ctx, process.handle)
+ propertiesJSON, resultJSON, err = vmcompute.HcsGetProcessProperties(ctx, process.handle)
events := processHcsResult(ctx, resultJSON)
if err != nil {
- err = makeProcessError(process, operation, err, events)
+ err = makeProcessError(process, operation, err, events) //nolint:ineffassign
} else {
properties := &processStatus{}
err = json.Unmarshal([]byte(propertiesJSON), properties)
if err != nil {
- err = makeProcessError(process, operation, err, nil)
+ err = makeProcessError(process, operation, err, nil) //nolint:ineffassign
} else {
if properties.LastWaitResult != 0 {
log.G(ctx).WithField("wait-result", properties.LastWaitResult).Warning("non-zero last wait result")
@@ -468,7 +466,7 @@ func (process *Process) unregisterCallback(ctx context.Context) error {
delete(callbackMap, callbackNumber)
callbackMapLock.Unlock()
- handle = 0
+ handle = 0 //nolint:ineffassign
return nil
}
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
index bda393a6d..cea11dee7 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
@@ -73,8 +73,8 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in
if err = computeSystem.registerCallback(ctx); err != nil {
// Terminate the compute system if it still exists. We're okay to
// ignore a failure here.
- computeSystem.Terminate(ctx)
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ _ = computeSystem.Terminate(ctx)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
}
@@ -83,9 +83,9 @@ func CreateComputeSystem(ctx context.Context, id string, hcsDocumentInterface in
if err == ErrTimeout {
// Terminate the compute system if it still exists. We're okay to
// ignore a failure here.
- computeSystem.Terminate(ctx)
+ _ = computeSystem.Terminate(ctx)
}
- return nil, makeSystemError(computeSystem, operation, hcsDocument, err, events)
+ return nil, makeSystemError(computeSystem, operation, err, events)
}
go computeSystem.waitBackground()
if err = computeSystem.getCachedProperties(ctx); err != nil {
@@ -102,7 +102,7 @@ func OpenComputeSystem(ctx context.Context, id string) (*System, error) {
handle, resultJSON, err := vmcompute.HcsOpenComputeSystem(ctx, id)
events := processHcsResult(ctx, resultJSON)
if err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, events)
+ return nil, makeSystemError(computeSystem, operation, err, events)
}
computeSystem.handle = handle
defer func() {
@@ -111,7 +111,7 @@ func OpenComputeSystem(ctx context.Context, id string) (*System, error) {
}
}()
if err = computeSystem.registerCallback(ctx); err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
go computeSystem.waitBackground()
if err = computeSystem.getCachedProperties(ctx); err != nil {
@@ -187,13 +187,13 @@ func (computeSystem *System) Start(ctx context.Context) (err error) {
defer computeSystem.handleLock.RUnlock()
if computeSystem.handle == 0 {
- return makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil)
+ return makeSystemError(computeSystem, operation, ErrAlreadyClosed, nil)
}
resultJSON, err := vmcompute.HcsStartComputeSystem(ctx, computeSystem.handle, "")
events, err := processAsyncHcsResult(ctx, err, resultJSON, computeSystem.callbackNumber, hcsNotificationSystemStartCompleted, &timeout.SystemStart)
if err != nil {
- return makeSystemError(computeSystem, operation, "", err, events)
+ return makeSystemError(computeSystem, operation, err, events)
}
return nil
@@ -220,7 +220,7 @@ func (computeSystem *System) Shutdown(ctx context.Context) error {
switch err {
case nil, ErrVmcomputeAlreadyStopped, ErrComputeSystemDoesNotExist, ErrVmcomputeOperationPending:
default:
- return makeSystemError(computeSystem, operation, "", err, events)
+ return makeSystemError(computeSystem, operation, err, events)
}
return nil
}
@@ -241,7 +241,7 @@ func (computeSystem *System) Terminate(ctx context.Context) error {
switch err {
case nil, ErrVmcomputeAlreadyStopped, ErrComputeSystemDoesNotExist, ErrVmcomputeOperationPending:
default:
- return makeSystemError(computeSystem, operation, "", err, events)
+ return makeSystemError(computeSystem, operation, err, events)
}
return nil
}
@@ -263,10 +263,10 @@ func (computeSystem *System) waitBackground() {
log.G(ctx).Debug("system exited")
case ErrVmcomputeUnexpectedExit:
log.G(ctx).Debug("unexpected system exit")
- computeSystem.exitError = makeSystemError(computeSystem, operation, "", err, nil)
+ computeSystem.exitError = makeSystemError(computeSystem, operation, err, nil)
err = nil
default:
- err = makeSystemError(computeSystem, operation, "", err, nil)
+ err = makeSystemError(computeSystem, operation, err, nil)
}
computeSystem.closedWaitOnce.Do(func() {
computeSystem.waitError = err
@@ -304,13 +304,13 @@ func (computeSystem *System) Properties(ctx context.Context, types ...schema1.Pr
queryBytes, err := json.Marshal(schema1.PropertyQuery{PropertyTypes: types})
if err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
propertiesJSON, resultJSON, err := vmcompute.HcsGetComputeSystemProperties(ctx, computeSystem.handle, string(queryBytes))
events := processHcsResult(ctx, resultJSON)
if err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, events)
+ return nil, makeSystemError(computeSystem, operation, err, events)
}
if propertiesJSON == "" {
@@ -318,7 +318,7 @@ func (computeSystem *System) Properties(ctx context.Context, types ...schema1.Pr
}
properties := &schema1.ContainerProperties{}
if err := json.Unmarshal([]byte(propertiesJSON), properties); err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
return properties, nil
@@ -333,13 +333,13 @@ func (computeSystem *System) PropertiesV2(ctx context.Context, types ...hcsschem
queryBytes, err := json.Marshal(hcsschema.PropertyQuery{PropertyTypes: types})
if err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
propertiesJSON, resultJSON, err := vmcompute.HcsGetComputeSystemProperties(ctx, computeSystem.handle, string(queryBytes))
events := processHcsResult(ctx, resultJSON)
if err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, events)
+ return nil, makeSystemError(computeSystem, operation, err, events)
}
if propertiesJSON == "" {
@@ -347,7 +347,7 @@ func (computeSystem *System) PropertiesV2(ctx context.Context, types ...hcsschem
}
properties := &hcsschema.Properties{}
if err := json.Unmarshal([]byte(propertiesJSON), properties); err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
return properties, nil
@@ -368,13 +368,13 @@ func (computeSystem *System) Pause(ctx context.Context) (err error) {
defer computeSystem.handleLock.RUnlock()
if computeSystem.handle == 0 {
- return makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil)
+ return makeSystemError(computeSystem, operation, ErrAlreadyClosed, nil)
}
resultJSON, err := vmcompute.HcsPauseComputeSystem(ctx, computeSystem.handle, "")
events, err := processAsyncHcsResult(ctx, err, resultJSON, computeSystem.callbackNumber, hcsNotificationSystemPauseCompleted, &timeout.SystemPause)
if err != nil {
- return makeSystemError(computeSystem, operation, "", err, events)
+ return makeSystemError(computeSystem, operation, err, events)
}
return nil
@@ -395,13 +395,13 @@ func (computeSystem *System) Resume(ctx context.Context) (err error) {
defer computeSystem.handleLock.RUnlock()
if computeSystem.handle == 0 {
- return makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil)
+ return makeSystemError(computeSystem, operation, ErrAlreadyClosed, nil)
}
resultJSON, err := vmcompute.HcsResumeComputeSystem(ctx, computeSystem.handle, "")
events, err := processAsyncHcsResult(ctx, err, resultJSON, computeSystem.callbackNumber, hcsNotificationSystemResumeCompleted, &timeout.SystemResume)
if err != nil {
- return makeSystemError(computeSystem, operation, "", err, events)
+ return makeSystemError(computeSystem, operation, err, events)
}
return nil
@@ -427,13 +427,13 @@ func (computeSystem *System) Save(ctx context.Context, options interface{}) (err
defer computeSystem.handleLock.RUnlock()
if computeSystem.handle == 0 {
- return makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil)
+ return makeSystemError(computeSystem, operation, ErrAlreadyClosed, nil)
}
result, err := vmcompute.HcsSaveComputeSystem(ctx, computeSystem.handle, string(saveOptions))
events, err := processAsyncHcsResult(ctx, err, result, computeSystem.callbackNumber, hcsNotificationSystemSaveCompleted, &timeout.SystemSave)
if err != nil {
- return makeSystemError(computeSystem, operation, "", err, events)
+ return makeSystemError(computeSystem, operation, err, events)
}
return nil
@@ -444,19 +444,19 @@ func (computeSystem *System) createProcess(ctx context.Context, operation string
defer computeSystem.handleLock.RUnlock()
if computeSystem.handle == 0 {
- return nil, nil, makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil)
+ return nil, nil, makeSystemError(computeSystem, operation, ErrAlreadyClosed, nil)
}
configurationb, err := json.Marshal(c)
if err != nil {
- return nil, nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, nil, makeSystemError(computeSystem, operation, err, nil)
}
configuration := string(configurationb)
processInfo, processHandle, resultJSON, err := vmcompute.HcsCreateProcess(ctx, computeSystem.handle, configuration)
events := processHcsResult(ctx, resultJSON)
if err != nil {
- return nil, nil, makeSystemError(computeSystem, operation, configuration, err, events)
+ return nil, nil, makeSystemError(computeSystem, operation, err, events)
}
log.G(ctx).WithField("pid", processInfo.ProcessId).Debug("created process pid")
@@ -478,7 +478,7 @@ func (computeSystem *System) CreateProcess(ctx context.Context, c interface{}) (
pipes, err := makeOpenFiles([]syscall.Handle{processInfo.StdInput, processInfo.StdOutput, processInfo.StdError})
if err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
process.stdin = pipes[0]
process.stdout = pipes[1]
@@ -486,7 +486,7 @@ func (computeSystem *System) CreateProcess(ctx context.Context, c interface{}) (
process.hasCachedStdio = true
if err = process.registerCallback(ctx); err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
go process.waitBackground()
@@ -501,18 +501,18 @@ func (computeSystem *System) OpenProcess(ctx context.Context, pid int) (*Process
operation := "hcsshim::System::OpenProcess"
if computeSystem.handle == 0 {
- return nil, makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil)
+ return nil, makeSystemError(computeSystem, operation, ErrAlreadyClosed, nil)
}
processHandle, resultJSON, err := vmcompute.HcsOpenProcess(ctx, computeSystem.handle, uint32(pid))
events := processHcsResult(ctx, resultJSON)
if err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, events)
+ return nil, makeSystemError(computeSystem, operation, err, events)
}
process := newProcess(processHandle, pid, computeSystem)
if err = process.registerCallback(ctx); err != nil {
- return nil, makeSystemError(computeSystem, operation, "", err, nil)
+ return nil, makeSystemError(computeSystem, operation, err, nil)
}
go process.waitBackground()
@@ -536,12 +536,12 @@ func (computeSystem *System) Close() (err error) {
}
if err = computeSystem.unregisterCallback(ctx); err != nil {
- return makeSystemError(computeSystem, operation, "", err, nil)
+ return makeSystemError(computeSystem, operation, err, nil)
}
err = vmcompute.HcsCloseComputeSystem(ctx, computeSystem.handle)
if err != nil {
- return makeSystemError(computeSystem, operation, "", err, nil)
+ return makeSystemError(computeSystem, operation, err, nil)
}
computeSystem.handle = 0
@@ -605,7 +605,7 @@ func (computeSystem *System) unregisterCallback(ctx context.Context) error {
delete(callbackMap, callbackNumber)
callbackMapLock.Unlock()
- handle = 0
+ handle = 0 //nolint:ineffassign
return nil
}
@@ -618,7 +618,7 @@ func (computeSystem *System) Modify(ctx context.Context, config interface{}) err
operation := "hcsshim::System::Modify"
if computeSystem.handle == 0 {
- return makeSystemError(computeSystem, operation, "", ErrAlreadyClosed, nil)
+ return makeSystemError(computeSystem, operation, ErrAlreadyClosed, nil)
}
requestBytes, err := json.Marshal(config)
@@ -630,7 +630,7 @@ func (computeSystem *System) Modify(ctx context.Context, config interface{}) err
resultJSON, err := vmcompute.HcsModifyComputeSystem(ctx, computeSystem.handle, requestJSON)
events := processHcsResult(ctx, resultJSON)
if err != nil {
- return makeSystemError(computeSystem, operation, requestJSON, err, events)
+ return makeSystemError(computeSystem, operation, err, events)
}
return nil
diff --git a/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go b/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go
index f07f532c1..db4e14fdf 100644
--- a/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go
+++ b/vendor/github.com/Microsoft/hcsshim/internal/hcs/waithelper.go
@@ -65,5 +65,4 @@ func waitForNotification(ctx context.Context, callbackNumber uintptr, expectedNo
case <-c:
return ErrTimeout
}
- return nil
}