mirror of
https://github.com/containers/skopeo.git
synced 2025-09-26 20:53:16 +00:00
fix(deps): update module github.com/containers/storage to v1.51.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
68
vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
generated
vendored
68
vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
generated
vendored
@@ -12,14 +12,16 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"go.opencensus.io/trace"
|
||||
|
||||
"github.com/Microsoft/hcsshim/internal/cow"
|
||||
hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
|
||||
"github.com/Microsoft/hcsshim/internal/log"
|
||||
"github.com/Microsoft/hcsshim/internal/oc"
|
||||
"github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
|
||||
"github.com/Microsoft/hcsshim/internal/vmcompute"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
|
||||
// ContainerError is an error encountered in HCS
|
||||
type Process struct {
|
||||
handleLock sync.RWMutex
|
||||
handle vmcompute.HcsProcess
|
||||
@@ -50,35 +52,6 @@ func newProcess(process vmcompute.HcsProcess, processID int, computeSystem *Syst
|
||||
}
|
||||
}
|
||||
|
||||
type processModifyRequest struct {
|
||||
Operation string
|
||||
ConsoleSize *consoleSize `json:",omitempty"`
|
||||
CloseHandle *closeHandle `json:",omitempty"`
|
||||
}
|
||||
|
||||
type consoleSize struct {
|
||||
Height uint16
|
||||
Width uint16
|
||||
}
|
||||
|
||||
type closeHandle struct {
|
||||
Handle string
|
||||
}
|
||||
|
||||
type processStatus struct {
|
||||
ProcessID uint32
|
||||
Exited bool
|
||||
ExitCode uint32
|
||||
LastWaitResult int32
|
||||
}
|
||||
|
||||
const stdIn string = "StdIn"
|
||||
|
||||
const (
|
||||
modifyConsoleSize string = "ConsoleSize"
|
||||
modifyCloseHandle string = "CloseHandle"
|
||||
)
|
||||
|
||||
// Pid returns the process ID of the process within the container.
|
||||
func (process *Process) Pid() int {
|
||||
return process.processID
|
||||
@@ -260,14 +233,14 @@ func (process *Process) waitBackground() {
|
||||
process.handleLock.RLock()
|
||||
defer process.handleLock.RUnlock()
|
||||
|
||||
// Make sure we didnt race with Close() here
|
||||
// Make sure we didn't race with Close() here
|
||||
if process.handle != 0 {
|
||||
propertiesJSON, resultJSON, err = vmcompute.HcsGetProcessProperties(ctx, process.handle)
|
||||
events := processHcsResult(ctx, resultJSON)
|
||||
if err != nil {
|
||||
err = makeProcessError(process, operation, err, events)
|
||||
} else {
|
||||
properties := &processStatus{}
|
||||
properties := &hcsschema.ProcessStatus{}
|
||||
err = json.Unmarshal([]byte(propertiesJSON), properties)
|
||||
if err != nil {
|
||||
err = makeProcessError(process, operation, err, nil)
|
||||
@@ -318,10 +291,9 @@ func (process *Process) ResizeConsole(ctx context.Context, width, height uint16)
|
||||
if process.handle == 0 {
|
||||
return makeProcessError(process, operation, ErrAlreadyClosed, nil)
|
||||
}
|
||||
|
||||
modifyRequest := processModifyRequest{
|
||||
Operation: modifyConsoleSize,
|
||||
ConsoleSize: &consoleSize{
|
||||
modifyRequest := hcsschema.ProcessModifyRequest{
|
||||
Operation: guestrequest.ModifyProcessConsoleSize,
|
||||
ConsoleSize: &hcsschema.ConsoleSize{
|
||||
Height: height,
|
||||
Width: width,
|
||||
},
|
||||
@@ -421,18 +393,12 @@ func (process *Process) CloseStdin(ctx context.Context) (err error) {
|
||||
return makeProcessError(process, operation, ErrAlreadyClosed, nil)
|
||||
}
|
||||
|
||||
process.stdioLock.Lock()
|
||||
defer process.stdioLock.Unlock()
|
||||
if process.stdin == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
//HcsModifyProcess request to close stdin will fail if the process has already exited
|
||||
if !process.stopped() {
|
||||
modifyRequest := processModifyRequest{
|
||||
Operation: modifyCloseHandle,
|
||||
CloseHandle: &closeHandle{
|
||||
Handle: stdIn,
|
||||
modifyRequest := hcsschema.ProcessModifyRequest{
|
||||
Operation: guestrequest.CloseProcessHandle,
|
||||
CloseHandle: &hcsschema.CloseHandle{
|
||||
Handle: guestrequest.STDInHandle,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -448,8 +414,12 @@ func (process *Process) CloseStdin(ctx context.Context) (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
process.stdin.Close()
|
||||
process.stdin = nil
|
||||
process.stdioLock.Lock()
|
||||
defer process.stdioLock.Unlock()
|
||||
if process.stdin != nil {
|
||||
process.stdin.Close()
|
||||
process.stdin = nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
4
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/close_handle.go
generated
vendored
4
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/close_handle.go
generated
vendored
@@ -9,6 +9,8 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
import "github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
|
||||
|
||||
type CloseHandle struct {
|
||||
Handle string `json:"Handle,omitempty"`
|
||||
Handle guestrequest.STDIOHandle `json:"Handle,omitempty"` // NOTE: Swagger generated as string. Locally updated.
|
||||
}
|
||||
|
9
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/console_size.go
generated
vendored
9
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/console_size.go
generated
vendored
@@ -9,8 +9,11 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
type ConsoleSize struct {
|
||||
Height int32 `json:"Height,omitempty"`
|
||||
// NOTE: Swagger generated fields as int32. Locally updated to uint16 to match documentation.
|
||||
// https://learn.microsoft.com/en-us/virtualization/api/hcs/schemareference#ConsoleSize
|
||||
|
||||
Width int32 `json:"Width,omitempty"`
|
||||
type ConsoleSize struct {
|
||||
Height uint16 `json:"Height,omitempty"`
|
||||
|
||||
Width uint16 `json:"Width,omitempty"`
|
||||
}
|
||||
|
6
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/process_modify_request.go
generated
vendored
6
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/process_modify_request.go
generated
vendored
@@ -9,9 +9,11 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
// Passed to HcsRpc_ModifyProcess
|
||||
import "github.com/Microsoft/hcsshim/internal/protocol/guestrequest"
|
||||
|
||||
// Passed to HcsRpc_ModifyProcess
|
||||
type ProcessModifyRequest struct {
|
||||
Operation string `json:"Operation,omitempty"`
|
||||
Operation guestrequest.ProcessModifyOperation `json:"Operation,omitempty"` // NOTE: Swagger generated as string. Locally updated.
|
||||
|
||||
ConsoleSize *ConsoleSize `json:"ConsoleSize,omitempty"`
|
||||
|
||||
|
9
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/process_status.go
generated
vendored
9
vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/process_status.go
generated
vendored
@@ -9,13 +9,16 @@
|
||||
|
||||
package hcsschema
|
||||
|
||||
// Status of a process running in a container
|
||||
// NOTE: Swagger generated fields as int32. Locally updated to uint16 to match documentation.
|
||||
// https://learn.microsoft.com/en-us/virtualization/api/hcs/schemareference#ConsoleSize
|
||||
|
||||
// Status of a process running in a container
|
||||
type ProcessStatus struct {
|
||||
ProcessId int32 `json:"ProcessId,omitempty"`
|
||||
ProcessId uint32 `json:"ProcessId,omitempty"` // NOTE: Swagger generated as int32. Locally updated to match documentation.
|
||||
|
||||
Exited bool `json:"Exited,omitempty"`
|
||||
|
||||
ExitCode int32 `json:"ExitCode,omitempty"`
|
||||
ExitCode uint32 `json:"ExitCode,omitempty"` // NOTE: Swagger generated as int32. Locally updated to match documentation.
|
||||
|
||||
LastWaitResult int32 `json:"LastWaitResult,omitempty"`
|
||||
}
|
||||
|
31
vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
generated
vendored
31
vendor/github.com/Microsoft/hcsshim/internal/hcs/system.go
generated
vendored
@@ -304,11 +304,22 @@ func (computeSystem *System) WaitError() error {
|
||||
return computeSystem.waitError
|
||||
}
|
||||
|
||||
// Wait synchronously waits for the compute system to shutdown or terminate. If
|
||||
// the compute system has already exited returns the previous error (if any).
|
||||
// Wait synchronously waits for the compute system to shutdown or terminate.
|
||||
// If the compute system has already exited returns the previous error (if any).
|
||||
func (computeSystem *System) Wait() error {
|
||||
<-computeSystem.WaitChannel()
|
||||
return computeSystem.WaitError()
|
||||
return computeSystem.WaitCtx(context.Background())
|
||||
}
|
||||
|
||||
// WaitCtx synchronously waits for the compute system to shutdown or terminate, or the context to be cancelled.
|
||||
//
|
||||
// See [System.Wait] for more information.
|
||||
func (computeSystem *System) WaitCtx(ctx context.Context) error {
|
||||
select {
|
||||
case <-computeSystem.WaitChannel():
|
||||
return computeSystem.WaitError()
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
}
|
||||
|
||||
// stopped returns true if the compute system stopped.
|
||||
@@ -735,9 +746,17 @@ func (computeSystem *System) OpenProcess(ctx context.Context, pid int) (*Process
|
||||
}
|
||||
|
||||
// Close cleans up any state associated with the compute system but does not terminate or wait for it.
|
||||
func (computeSystem *System) Close() (err error) {
|
||||
func (computeSystem *System) Close() error {
|
||||
return computeSystem.CloseCtx(context.Background())
|
||||
}
|
||||
|
||||
// CloseCtx is similar to [System.Close], but accepts a context.
|
||||
//
|
||||
// The context is used for all operations, including waits, so timeouts/cancellations may prevent
|
||||
// proper system cleanup.
|
||||
func (computeSystem *System) CloseCtx(ctx context.Context) (err error) {
|
||||
operation := "hcs::System::Close"
|
||||
ctx, span := oc.StartSpan(context.Background(), operation)
|
||||
ctx, span := oc.StartSpan(ctx, operation)
|
||||
defer span.End()
|
||||
defer func() { oc.SetSpanStatus(span, err) }()
|
||||
span.AddAttributes(trace.StringAttribute("cid", computeSystem.id))
|
||||
|
7
vendor/github.com/Microsoft/hcsshim/internal/log/format.go
generated
vendored
7
vendor/github.com/Microsoft/hcsshim/internal/log/format.go
generated
vendored
@@ -9,13 +9,16 @@ import (
|
||||
"reflect"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/sirupsen/logrus"
|
||||
"google.golang.org/protobuf/encoding/protojson"
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
const TimeFormat = log.RFC3339NanoFixed
|
||||
// TimeFormat is [time.RFC3339Nano] with nanoseconds padded using
|
||||
// zeros to ensure the formatted time is always the same number of
|
||||
// characters.
|
||||
// Based on RFC3339NanoFixed from github.com/containerd/log
|
||||
const TimeFormat = "2006-01-02T15:04:05.000000000Z07:00"
|
||||
|
||||
func FormatTime(t time.Time) string {
|
||||
return t.Format(TimeFormat)
|
||||
|
5
vendor/github.com/Microsoft/hcsshim/internal/log/hook.go
generated
vendored
5
vendor/github.com/Microsoft/hcsshim/internal/log/hook.go
generated
vendored
@@ -6,7 +6,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/Microsoft/hcsshim/internal/logfields"
|
||||
"github.com/containerd/containerd/log"
|
||||
"github.com/sirupsen/logrus"
|
||||
"go.opencensus.io/trace"
|
||||
)
|
||||
@@ -30,7 +29,7 @@ type Hook struct {
|
||||
// An empty string disables formatting.
|
||||
// When disabled, the fall back will the JSON encoding, if enabled.
|
||||
//
|
||||
// Default is [github.com/containerd/containerd/log.RFC3339NanoFixed].
|
||||
// Default is [TimeFormat].
|
||||
TimeFormat string
|
||||
|
||||
// Duration format converts a [time.Duration] fields to an appropriate encoding.
|
||||
@@ -49,7 +48,7 @@ var _ logrus.Hook = &Hook{}
|
||||
|
||||
func NewHook() *Hook {
|
||||
return &Hook{
|
||||
TimeFormat: log.RFC3339NanoFixed,
|
||||
TimeFormat: TimeFormat,
|
||||
DurationFormat: DurationFormatString,
|
||||
AddSpanContext: true,
|
||||
}
|
||||
|
12
vendor/github.com/Microsoft/hcsshim/internal/log/nopformatter.go
generated
vendored
Normal file
12
vendor/github.com/Microsoft/hcsshim/internal/log/nopformatter.go
generated
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
package log
|
||||
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type NopFormatter struct{}
|
||||
|
||||
var _ logrus.Formatter = NopFormatter{}
|
||||
|
||||
// Format does nothing and returns a nil slice.
|
||||
func (NopFormatter) Format(*logrus.Entry) ([]byte, error) { return nil, nil }
|
22
vendor/github.com/Microsoft/hcsshim/internal/protocol/guestrequest/types.go
generated
vendored
22
vendor/github.com/Microsoft/hcsshim/internal/protocol/guestrequest/types.go
generated
vendored
@@ -5,7 +5,7 @@ package guestrequest
|
||||
type RequestType string
|
||||
type ResourceType string
|
||||
|
||||
// RequestType const
|
||||
// RequestType const.
|
||||
const (
|
||||
RequestTypeAdd RequestType = "Add"
|
||||
RequestTypeRemove RequestType = "Remove"
|
||||
@@ -54,3 +54,23 @@ var (
|
||||
"305891a9-b251-5dfe-91a2-c25d9212275b",
|
||||
}
|
||||
)
|
||||
|
||||
// constants for v2 schema ProcessModifyRequest
|
||||
|
||||
// Operation type for [hcsschema.ProcessModifyRequest].
|
||||
type ProcessModifyOperation string
|
||||
|
||||
const (
|
||||
ModifyProcessConsoleSize ProcessModifyOperation = "ConsoleSize"
|
||||
CloseProcessHandle ProcessModifyOperation = "CloseHandle"
|
||||
)
|
||||
|
||||
// Standard IO handle(s) to close for [hcsschema.CloseHandle] in [hcsschema.ProcessModifyRequest].
|
||||
type STDIOHandle string
|
||||
|
||||
const (
|
||||
STDInHandle STDIOHandle = "StdIn"
|
||||
STDOutHandle STDIOHandle = "StdOut"
|
||||
STDErrHandle STDIOHandle = "StdErr"
|
||||
AllHandles STDIOHandle = "All"
|
||||
)
|
||||
|
24
vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
generated
vendored
24
vendor/github.com/Microsoft/hcsshim/internal/wclayer/layerutils.go
generated
vendored
@@ -7,6 +7,10 @@ package wclayer
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"syscall"
|
||||
|
||||
"github.com/Microsoft/go-winio/pkg/guid"
|
||||
@@ -101,3 +105,23 @@ func layerPathsToDescriptors(ctx context.Context, parentLayerPaths []string) ([]
|
||||
|
||||
return layers, nil
|
||||
}
|
||||
|
||||
// GetLayerUvmBuild looks for a file named `uvmbuildversion` at `layerPath\uvmbuildversion` and returns the
|
||||
// build number of the UVM from that file.
|
||||
func GetLayerUvmBuild(layerPath string) (uint16, error) {
|
||||
data, err := os.ReadFile(filepath.Join(layerPath, UvmBuildFileName))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
ver, err := strconv.ParseUint(string(data), 10, 16)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return uint16(ver), nil
|
||||
}
|
||||
|
||||
// WriteLayerUvmBuildFile writes a file at path `layerPath\uvmbuildversion` that contains the given `build`
|
||||
// version for future reference.
|
||||
func WriteLayerUvmBuildFile(layerPath string, build uint16) error {
|
||||
return os.WriteFile(filepath.Join(layerPath, UvmBuildFileName), []byte(fmt.Sprintf("%d", build)), 0777)
|
||||
}
|
||||
|
Reference in New Issue
Block a user