update to go1.17 and update direct dependencies

pull/737/head
iwilltry42 3 years ago
parent 630788f1e7
commit 5aa1edfb73
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
  1. 4
      .drone.yml
  2. 2
      Dockerfile
  3. 82
      go.mod
  4. 456
      go.sum
  5. 11
      pkg/client/ipam.go
  6. 8
      pkg/runtimes/docker/network.go
  7. 4
      tools/Dockerfile
  8. 12
      tools/go.mod
  9. 3
      tools/vendor/github.com/opencontainers/go-digest/go.mod
  10. 10
      tools/vendor/github.com/sirupsen/logrus/go.mod
  11. 8
      tools/vendor/github.com/sirupsen/logrus/go.sum
  12. 21
      tools/vendor/modules.txt
  13. 9
      vendor/github.com/Microsoft/go-winio/go.mod
  14. 14
      vendor/github.com/Microsoft/go-winio/go.sum
  15. 2
      vendor/github.com/Microsoft/hcsshim/.gitignore
  16. 17
      vendor/github.com/Microsoft/hcsshim/.gometalinter.json
  17. 4
      vendor/github.com/Microsoft/hcsshim/CODEOWNERS
  18. 29
      vendor/github.com/Microsoft/hcsshim/Protobuild.toml
  19. 2
      vendor/github.com/Microsoft/hcsshim/README.md
  20. 45
      vendor/github.com/Microsoft/hcsshim/appveyor.yml
  21. 6
      vendor/github.com/Microsoft/hcsshim/computestorage/attach.go
  22. 6
      vendor/github.com/Microsoft/hcsshim/computestorage/destroy.go
  23. 6
      vendor/github.com/Microsoft/hcsshim/computestorage/detach.go
  24. 6
      vendor/github.com/Microsoft/hcsshim/computestorage/export.go
  25. 6
      vendor/github.com/Microsoft/hcsshim/computestorage/format.go
  26. 12
      vendor/github.com/Microsoft/hcsshim/computestorage/helpers.go
  27. 6
      vendor/github.com/Microsoft/hcsshim/computestorage/import.go
  28. 6
      vendor/github.com/Microsoft/hcsshim/computestorage/initialize.go
  29. 6
      vendor/github.com/Microsoft/hcsshim/computestorage/mount.go
  30. 13
      vendor/github.com/Microsoft/hcsshim/computestorage/setup.go
  31. 2
      vendor/github.com/Microsoft/hcsshim/computestorage/storage.go
  32. 2
      vendor/github.com/Microsoft/hcsshim/container.go
  33. 38
      vendor/github.com/Microsoft/hcsshim/errors.go
  34. 35
      vendor/github.com/Microsoft/hcsshim/go.mod
  35. 161
      vendor/github.com/Microsoft/hcsshim/go.sum
  36. 6
      vendor/github.com/Microsoft/hcsshim/hnsendpoint.go
  37. 2
      vendor/github.com/Microsoft/hcsshim/interface.go
  38. 12
      vendor/github.com/Microsoft/hcsshim/internal/cow/cow.go
  39. 5
      vendor/github.com/Microsoft/hcsshim/internal/hcs/callback.go
  40. 23
      vendor/github.com/Microsoft/hcsshim/internal/hcs/errors.go
  41. 87
      vendor/github.com/Microsoft/hcsshim/internal/hcs/process.go
  42. 9
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema1/schema1.go
  43. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/attachment.go
  44. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/battery.go
  45. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cache_query_stats_response.go
  46. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/chipset.go
  47. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/close_handle.go
  48. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/com_port.go
  49. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/compute_system.go
  50. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/configuration.go
  51. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/console_size.go
  52. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container.go
  53. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_credential_guard_add_instance_request.go
  54. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_credential_guard_hv_socket_service_config.go
  55. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_credential_guard_instance.go
  56. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_credential_guard_modify_operation.go
  57. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_credential_guard_operation_request.go
  58. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_credential_guard_remove_instance_request.go
  59. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_credential_guard_state.go
  60. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_credential_guard_system_info.go
  61. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/container_memory_information.go
  62. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cpu_group.go
  63. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cpu_group_affinity.go
  64. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cpu_group_config.go
  65. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cpu_group_configurations.go
  66. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cpu_group_operations.go
  67. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/cpu_group_property.go
  68. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/create_group_operation.go
  69. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/delete_group_operation.go
  70. 4
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/device.go
  71. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/devices.go
  72. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/enhanced_mode_video.go
  73. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/flexible_io_device.go
  74. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/guest_connection.go
  75. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/guest_connection_info.go
  76. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/guest_crash_reporting.go
  77. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/guest_os.go
  78. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/guest_state.go
  79. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/host_processor_modify_request.go
  80. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/hosted_system.go
  81. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/hv_socket.go
  82. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/hv_socket_2.go
  83. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/hv_socket_address.go
  84. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/hv_socket_service_config.go
  85. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/hv_socket_system_config.go
  86. 42
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/interrupt_moderation_mode.go
  87. 22
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/iov_settings.go
  88. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/keyboard.go
  89. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/layer.go
  90. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/linux_kernel_direct.go
  91. 8
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/logical_processor.go
  92. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/mapped_directory.go
  93. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/mapped_pipe.go
  94. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/memory.go
  95. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/memory_2.go
  96. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/memory_information_for_vm.go
  97. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/memory_stats.go
  98. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modification_request.go
  99. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/modify_setting_request.go
  100. 0
      vendor/github.com/Microsoft/hcsshim/internal/hcs/schema2/mouse.go
  101. Some files were not shown because too many files have changed in this diff Show More

@ -14,7 +14,7 @@ platform:
steps: steps:
- name: lint - name: lint
image: golang:1.16 image: golang:1.17
commands: commands:
- make ci-setup - make ci-setup
- make check-fmt lint - make check-fmt lint
@ -40,7 +40,7 @@ steps:
- tag - tag
- name: build - name: build
image: golang:1.16 image: golang:1.17
environment: environment:
GIT_TAG: "${DRONE_TAG}" GIT_TAG: "${DRONE_TAG}"
commands: commands:

@ -3,7 +3,7 @@
# -> golang image used solely for building the k3d binary # # -> golang image used solely for building the k3d binary #
# -> built executable can then be copied into other stages # # -> built executable can then be copied into other stages #
############################################################ ############################################################
FROM golang:1.16 as builder FROM golang:1.17 as builder
ARG GIT_TAG_OVERRIDE ARG GIT_TAG_OVERRIDE
WORKDIR /app WORKDIR /app
COPY . . COPY . .

@ -1,16 +1,15 @@
module github.com/rancher/k3d/v4 module github.com/rancher/k3d/v4
go 1.16 go 1.17
require ( require (
github.com/Microsoft/go-winio v0.4.17-0.20210211115548-6eac466e5fa3 // indirect github.com/Microsoft/go-winio v0.4.17 // indirect
github.com/Microsoft/hcsshim v0.8.14 // indirect github.com/Microsoft/hcsshim v0.8.18 // indirect
github.com/containerd/cgroups v0.0.0-20210114181951-8a68de567b68 // indirect github.com/containerd/cgroups v1.0.1 // indirect
github.com/containerd/containerd v1.4.4 github.com/containerd/containerd v1.5.5
github.com/containerd/continuity v0.0.0-20210208174643-50096c924a4e // indirect github.com/docker/cli v20.10.8+incompatible
github.com/docker/cli v20.10.7+incompatible github.com/docker/docker v20.10.8+incompatible
github.com/docker/docker v20.10.7+incompatible github.com/docker/docker-credential-helpers v0.6.4 // indirect
github.com/docker/docker-credential-helpers v0.6.3 // indirect
github.com/docker/go-connections v0.4.0 github.com/docker/go-connections v0.4.0
github.com/docker/go-metrics v0.0.1 // indirect github.com/docker/go-metrics v0.0.1 // indirect
github.com/docker/go-units v0.4.0 github.com/docker/go-units v0.4.0
@ -37,8 +36,67 @@ require (
golang.org/x/text v0.3.6 // indirect golang.org/x/text v0.3.6 // indirect
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
gotest.tools v2.2.0+incompatible gotest.tools v2.2.0+incompatible
gotest.tools/v3 v3.0.3 // indirect inet.af/netaddr v0.0.0-20210903134321-85fa6c94624e
inet.af/netaddr v0.0.0-20210421205553-78c777480f22 k8s.io/client-go v0.22.1
k8s.io/client-go v0.21.0
sigs.k8s.io/yaml v1.2.0 sigs.k8s.io/yaml v1.2.0
) )
require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c // indirect
github.com/docker/libtrust v0.0.0-20160708172513-aabc10ec26b7 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-logr/logr v0.4.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.5 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/gorilla/mux v1.7.3 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.11 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/miekg/pkcs11 v1.0.3 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/moby/sys/mountinfo v0.4.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/prometheus/client_golang v1.7.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.10.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
go.opencensus.io v0.23.0 // indirect
go4.org/intern v0.0.0-20210108033219-3eb7198706b2 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20201222180813-1025295fd063 // indirect
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 // indirect
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 // indirect
golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602 // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
google.golang.org/grpc v1.38.0 // indirect
google.golang.org/protobuf v1.26.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.62.0 // indirect
k8s.io/apimachinery v0.22.1 // indirect
k8s.io/klog/v2 v2.9.0 // indirect
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
)

456
go.sum

File diff suppressed because it is too large Load Diff

@ -48,12 +48,15 @@ func GetIP(ctx context.Context, runtime k3drt.Runtime, network *k3d.ClusterNetwo
} }
// exclude first and last address // exclude first and last address
ipsetbuilder.Remove(network.IPAM.IPPrefix.Range().From) ipsetbuilder.Remove(network.IPAM.IPPrefix.Range().From())
ipsetbuilder.Remove(network.IPAM.IPPrefix.Range().To) ipsetbuilder.Remove(network.IPAM.IPPrefix.Range().To())
ipset := ipsetbuilder.IPSet() ipset, err := ipsetbuilder.IPSet()
if err != nil {
return netaddr.IP{}, err
}
ip := ipset.Ranges()[0].From ip := ipset.Ranges()[0].From()
l.Log().Debugf("Found free IP %s in network %s", ip.String(), network.Name) l.Log().Debugf("Found free IP %s in network %s", ip.String(), network.Name)

@ -95,7 +95,7 @@ func (d Docker) GetNetwork(ctx context.Context, searchNet *k3d.ClusterNetwork) (
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to parse IP of container %s: %w", container.Name, err) return nil, fmt.Errorf("failed to parse IP of container %s: %w", container.Name, err)
} }
network.IPAM.IPsUsed = append(network.IPAM.IPsUsed, prefix.IP) network.IPAM.IPsUsed = append(network.IPAM.IPsUsed, prefix.IP())
} }
} }
@ -116,7 +116,7 @@ func (d Docker) GetNetwork(ctx context.Context, searchNet *k3d.ClusterNetwork) (
} }
network.Members = append(network.Members, &k3d.NetworkMember{ network.Members = append(network.Members, &k3d.NetworkMember{
Name: container.Name, Name: container.Name,
IP: prefix.IP, IP: prefix.IP(),
}) })
} }
@ -188,7 +188,7 @@ func (d Docker) CreateNetworkIfNotPresent(ctx context.Context, inNet *k3d.Cluste
Config: []network.IPAMConfig{ Config: []network.IPAMConfig{
{ {
Subnet: inNet.IPAM.IPPrefix.String(), Subnet: inNet.IPAM.IPPrefix.String(),
Gateway: inNet.IPAM.IPPrefix.Range().From.Next().String(), // second IP in subnet will be the Gateway (Next, so we don't hit x.x.x.0) Gateway: inNet.IPAM.IPPrefix.Range().From().Next().String(), // second IP in subnet will be the Gateway (Next, so we don't hit x.x.x.0)
}, },
}, },
} }
@ -362,7 +362,7 @@ func (d Docker) parseIPAM(config network.IPAMConfig) (ipam k3d.IPAM, err error)
} }
if config.Gateway == "" { if config.Gateway == "" {
gateway = ipam.IPPrefix.IP.Next() gateway = ipam.IPPrefix.IP().Next()
} else { } else {
gateway, err = netaddr.ParseIP(config.Gateway) gateway, err = netaddr.ParseIP(config.Gateway)
} }

@ -1,4 +1,4 @@
FROM golang:1.16 as builder FROM golang:1.17 as builder
ARG GIT_TAG ARG GIT_TAG
WORKDIR /app WORKDIR /app
COPY . . COPY . .
@ -10,4 +10,4 @@ RUN make build
FROM busybox:1.31 FROM busybox:1.31
WORKDIR /app WORKDIR /app
COPY --from=builder /app/bin/k3d-tools . COPY --from=builder /app/bin/k3d-tools .
ENTRYPOINT [ "/app/k3d-tools"] ENTRYPOINT [ "/app/k3d-tools"]

@ -1,6 +1,6 @@
module github.com/rancher/k3d/tools module github.com/rancher/k3d/tools
go 1.16 go 1.17
require ( require (
github.com/Microsoft/go-winio v0.4.12 // indirect github.com/Microsoft/go-winio v0.4.12 // indirect
@ -15,10 +15,18 @@ require (
github.com/morikuni/aec v1.0.0 // indirect github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect github.com/sirupsen/logrus v1.8.1
github.com/urfave/cli v1.20.0 github.com/urfave/cli v1.20.0
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
google.golang.org/grpc v1.36.0 // indirect google.golang.org/grpc v1.36.0 // indirect
gotest.tools/v3 v3.0.3 // indirect gotest.tools/v3 v3.0.3 // indirect
) )
require (
github.com/golang/protobuf v1.4.2 // indirect
github.com/pkg/errors v0.9.1 // indirect
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect
google.golang.org/protobuf v1.25.0 // indirect
)

@ -1,3 +0,0 @@
module github.com/opencontainers/go-digest
go 1.13

@ -1,10 +0,0 @@
module github.com/sirupsen/logrus
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/stretchr/testify v1.2.2
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037
)
go 1.13

@ -1,8 +0,0 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

@ -40,53 +40,58 @@ github.com/docker/go-connections/tlsconfig
## explicit ## explicit
github.com/docker/go-units github.com/docker/go-units
# github.com/gogo/protobuf v1.3.2 # github.com/gogo/protobuf v1.3.2
## explicit ## explicit; go 1.15
github.com/gogo/protobuf/proto github.com/gogo/protobuf/proto
# github.com/golang/protobuf v1.4.2 # github.com/golang/protobuf v1.4.2
## explicit; go 1.9
github.com/golang/protobuf/proto github.com/golang/protobuf/proto
github.com/golang/protobuf/ptypes github.com/golang/protobuf/ptypes
github.com/golang/protobuf/ptypes/any github.com/golang/protobuf/ptypes/any
github.com/golang/protobuf/ptypes/duration github.com/golang/protobuf/ptypes/duration
github.com/golang/protobuf/ptypes/timestamp github.com/golang/protobuf/ptypes/timestamp
# github.com/gorilla/mux v1.8.0 # github.com/gorilla/mux v1.8.0
## explicit ## explicit; go 1.12
# github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 # github.com/moby/term v0.0.0-20201216013528-df9cb8a40635
## explicit ## explicit; go 1.13
# github.com/morikuni/aec v1.0.0 # github.com/morikuni/aec v1.0.0
## explicit ## explicit
# github.com/opencontainers/go-digest v1.0.0 # github.com/opencontainers/go-digest v1.0.0
## explicit ## explicit; go 1.13
github.com/opencontainers/go-digest github.com/opencontainers/go-digest
# github.com/opencontainers/image-spec v1.0.1 # github.com/opencontainers/image-spec v1.0.1
## explicit ## explicit
github.com/opencontainers/image-spec/specs-go github.com/opencontainers/image-spec/specs-go
github.com/opencontainers/image-spec/specs-go/v1 github.com/opencontainers/image-spec/specs-go/v1
# github.com/pkg/errors v0.9.1 # github.com/pkg/errors v0.9.1
## explicit
github.com/pkg/errors github.com/pkg/errors
# github.com/sirupsen/logrus v1.8.1 # github.com/sirupsen/logrus v1.8.1
## explicit ## explicit; go 1.13
github.com/sirupsen/logrus github.com/sirupsen/logrus
# github.com/urfave/cli v1.20.0 # github.com/urfave/cli v1.20.0
## explicit ## explicit
github.com/urfave/cli github.com/urfave/cli
# golang.org/x/net v0.0.0-20201021035429-f5854403a974 # golang.org/x/net v0.0.0-20201021035429-f5854403a974
## explicit; go 1.11
golang.org/x/net/internal/socks golang.org/x/net/internal/socks
golang.org/x/net/proxy golang.org/x/net/proxy
# golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c # golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c
## explicit ## explicit; go 1.17
golang.org/x/sys/internal/unsafeheader golang.org/x/sys/internal/unsafeheader
golang.org/x/sys/unix golang.org/x/sys/unix
golang.org/x/sys/windows golang.org/x/sys/windows
# golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba # golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba
## explicit ## explicit
# google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 # google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
## explicit; go 1.11
google.golang.org/genproto/googleapis/rpc/status google.golang.org/genproto/googleapis/rpc/status
# google.golang.org/grpc v1.36.0 # google.golang.org/grpc v1.36.0
## explicit ## explicit; go 1.11
google.golang.org/grpc/codes google.golang.org/grpc/codes
google.golang.org/grpc/internal/status google.golang.org/grpc/internal/status
google.golang.org/grpc/status google.golang.org/grpc/status
# google.golang.org/protobuf v1.25.0 # google.golang.org/protobuf v1.25.0
## explicit; go 1.9
google.golang.org/protobuf/encoding/prototext google.golang.org/protobuf/encoding/prototext
google.golang.org/protobuf/encoding/protowire google.golang.org/protobuf/encoding/protowire
google.golang.org/protobuf/internal/descfmt google.golang.org/protobuf/internal/descfmt
@ -117,4 +122,4 @@ google.golang.org/protobuf/types/known/anypb
google.golang.org/protobuf/types/known/durationpb google.golang.org/protobuf/types/known/durationpb
google.golang.org/protobuf/types/known/timestamppb google.golang.org/protobuf/types/known/timestamppb
# gotest.tools/v3 v3.0.3 # gotest.tools/v3 v3.0.3
## explicit ## explicit; go 1.11

@ -1,9 +0,0 @@
module github.com/Microsoft/go-winio
go 1.12
require (
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.7.0
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c
)

@ -1,14 +0,0 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.7.0 h1:ShrD1U9pZB12TX0cVy0DtePoCH97K8EtX+mg7ZARUtM=
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c h1:VwygUrnw9jn88c4u8GD3rZQbqrP/tgas88tPUbBxQrk=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=

@ -1 +1,3 @@
*.exe *.exe
.idea
.vscode

@ -1,17 +0,0 @@
{
"Vendor": true,
"Deadline": "2m",
"Sort": [
"linter",
"severity",
"path",
"line"
],
"Skip": [
"internal\\schema2"
],
"EnableGC": true,
"Enable": [
"gofmt"
]
}

@ -1,3 +1 @@
* @microsoft/containerplat * @microsoft/containerplat
/hcn/* @nagiesek

@ -25,6 +25,7 @@ plugins = ["grpc", "fieldpath"]
"gogoproto/gogo.proto" = "github.com/gogo/protobuf/gogoproto" "gogoproto/gogo.proto" = "github.com/gogo/protobuf/gogoproto"
"google/protobuf/any.proto" = "github.com/gogo/protobuf/types" "google/protobuf/any.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/empty.proto" = "github.com/gogo/protobuf/types" "google/protobuf/empty.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/struct.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor" "google/protobuf/descriptor.proto" = "github.com/gogo/protobuf/protoc-gen-gogo/descriptor"
"google/protobuf/field_mask.proto" = "github.com/gogo/protobuf/types" "google/protobuf/field_mask.proto" = "github.com/gogo/protobuf/types"
"google/protobuf/timestamp.proto" = "github.com/gogo/protobuf/types" "google/protobuf/timestamp.proto" = "github.com/gogo/protobuf/types"
@ -35,20 +36,14 @@ plugins = ["grpc", "fieldpath"]
prefixes = ["github.com/Microsoft/hcsshim/internal/shimdiag"] prefixes = ["github.com/Microsoft/hcsshim/internal/shimdiag"]
plugins = ["ttrpc"] plugins = ["ttrpc"]
# Lock down runhcs config [[overrides]]
prefixes = ["github.com/Microsoft/hcsshim/internal/computeagent"]
[[descriptors]] plugins = ["ttrpc"]
prefix = "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
target = "cmd/containerd-shim-runhcs-v1/options/next.pb.txt" [[overrides]]
ignore_files = [ prefixes = ["github.com/Microsoft/hcsshim/internal/ncproxyttrpc"]
"google/protobuf/descriptor.proto", plugins = ["ttrpc"]
"gogoproto/gogo.proto"
] [[overrides]]
prefixes = ["github.com/Microsoft/hcsshim/internal/vmservice"]
[[descriptors]] plugins = ["ttrpc"]
prefix = "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/stats"
target = "cmd/containerd-shim-runhcs-v1/stats/next.pb.txt"
ignore_files = [
"google/protobuf/descriptor.proto",
"gogoproto/gogo.proto"
]

@ -1,6 +1,6 @@
# hcsshim # hcsshim
[![Build status](https://ci.appveyor.com/api/projects/status/nbcw28mnkqml0loa/branch/master?svg=true)](https://ci.appveyor.com/project/WindowsVirtualization/hcsshim/branch/master) [![Build status](https://github.com/microsoft/hcsshim/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/microsoft/hcsshim/actions?query=branch%3Amaster)
This package contains the Golang interface for using the Windows [Host Compute Service](https://techcommunity.microsoft.com/t5/containers/introducing-the-host-compute-service-hcs/ba-p/382332) (HCS) to launch and manage [Windows Containers](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/). It also contains other helpers and functions for managing Windows Containers such as the Golang interface for the Host Network Service (HNS). This package contains the Golang interface for using the Windows [Host Compute Service](https://techcommunity.microsoft.com/t5/containers/introducing-the-host-compute-service-hcs/ba-p/382332) (HCS) to launch and manage [Windows Containers](https://docs.microsoft.com/en-us/virtualization/windowscontainers/about/). It also contains other helpers and functions for managing Windows Containers such as the Golang interface for the Host Network Service (HNS).

@ -1,45 +0,0 @@
version: 0.1.{build}
image: Visual Studio 2017
clone_folder: c:\gopath\src\github.com\Microsoft\hcsshim
environment:
GOPATH: c:\gopath
PATH: "%GOPATH%\\bin;C:\\gometalinter-2.0.12-windows-amd64;%PATH%"
stack: go 1.13.4
build_script:
- appveyor DownloadFile https://github.com/alecthomas/gometalinter/releases/download/v2.0.12/gometalinter-2.0.12-windows-amd64.zip
- 7z x gometalinter-2.0.12-windows-amd64.zip -y -oC:\ > NUL
- gometalinter.exe --config .gometalinter.json ./...
- go build ./cmd/containerd-shim-runhcs-v1
- go build ./cmd/runhcs
- go build ./cmd/tar2ext4
- go build ./cmd/wclayer
- go build ./cmd/device-util
- go build ./internal/tools/grantvmgroupaccess
- go build ./internal/tools/uvmboot
- go build ./internal/tools/zapdir
- go test -v ./... -tags admin
- cd test
- go test -v ./internal -tags admin
- go test -c ./containerd-shim-runhcs-v1/ -tags functional
- go test -c ./cri-containerd/ -tags functional
- go test -c ./functional/ -tags functional
- go test -c ./runhcs/ -tags functional
artifacts:
- path: 'containerd-shim-runhcs-v1.exe'
- path: 'runhcs.exe'
- path: 'tar2ext4.exe'
- path: 'device-util.exe'
- path: 'wclayer.exe'
- path: 'grantvmgroupaccess.exe'
- path: 'uvmboot.exe'
- path: 'zapdir.exe'
- path: './test/containerd-shim-runhcs-v1.test.exe'
- path: './test/cri-containerd.test.exe'
- path: './test/functional.test.exe'
- path: './test/runhcs.test.exe'

@ -3,9 +3,9 @@ package computestorage
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
) )
@ -18,7 +18,7 @@ import (
// `layerData` is the parent read-only layer data. // `layerData` is the parent read-only layer data.
func AttachLayerStorageFilter(ctx context.Context, layerPath string, layerData LayerData) (err error) { func AttachLayerStorageFilter(ctx context.Context, layerPath string, layerData LayerData) (err error) {
title := "hcsshim.AttachLayerStorageFilter" title := "hcsshim.AttachLayerStorageFilter"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes( span.AddAttributes(
@ -32,7 +32,7 @@ func AttachLayerStorageFilter(ctx context.Context, layerPath string, layerData L
err = hcsAttachLayerStorageFilter(layerPath, string(bytes)) err = hcsAttachLayerStorageFilter(layerPath, string(bytes))
if err != nil { if err != nil {
return fmt.Errorf("failed to attach layer storage filter: %s", err) return errors.Wrap(err, "failed to attach layer storage filter")
} }
return nil return nil
} }

@ -2,9 +2,9 @@ package computestorage
import ( import (
"context" "context"
"fmt"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
) )
@ -13,14 +13,14 @@ import (
// `layerPath` is a path to a directory containing the layer to export. // `layerPath` is a path to a directory containing the layer to export.
func DestroyLayer(ctx context.Context, layerPath string) (err error) { func DestroyLayer(ctx context.Context, layerPath string) (err error) {
title := "hcsshim.DestroyLayer" title := "hcsshim.DestroyLayer"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes(trace.StringAttribute("layerPath", layerPath)) span.AddAttributes(trace.StringAttribute("layerPath", layerPath))
err = hcsDestroyLayer(layerPath) err = hcsDestroyLayer(layerPath)
if err != nil { if err != nil {
return fmt.Errorf("failed to destroy layer: %s", err) return errors.Wrap(err, "failed to destroy layer")
} }
return nil return nil
} }

@ -2,9 +2,9 @@ package computestorage
import ( import (
"context" "context"
"fmt"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
) )
@ -13,14 +13,14 @@ import (
// `layerPath` is a path to a directory containing the layer to export. // `layerPath` is a path to a directory containing the layer to export.
func DetachLayerStorageFilter(ctx context.Context, layerPath string) (err error) { func DetachLayerStorageFilter(ctx context.Context, layerPath string) (err error) {
title := "hcsshim.DetachLayerStorageFilter" title := "hcsshim.DetachLayerStorageFilter"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes(trace.StringAttribute("layerPath", layerPath)) span.AddAttributes(trace.StringAttribute("layerPath", layerPath))
err = hcsDetachLayerStorageFilter(layerPath) err = hcsDetachLayerStorageFilter(layerPath)
if err != nil { if err != nil {
return fmt.Errorf("failed to detach layer storage filter: %s", err) return errors.Wrap(err, "failed to detach layer storage filter")
} }
return nil return nil
} }

@ -3,9 +3,9 @@ package computestorage
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
) )
@ -20,7 +20,7 @@ import (
// `options` are the export options applied to the exported layer. // `options` are the export options applied to the exported layer.
func ExportLayer(ctx context.Context, layerPath, exportFolderPath string, layerData LayerData, options ExportLayerOptions) (err error) { func ExportLayer(ctx context.Context, layerPath, exportFolderPath string, layerData LayerData, options ExportLayerOptions) (err error) {
title := "hcsshim.ExportLayer" title := "hcsshim.ExportLayer"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes( span.AddAttributes(
@ -40,7 +40,7 @@ func ExportLayer(ctx context.Context, layerPath, exportFolderPath string, layerD
err = hcsExportLayer(layerPath, exportFolderPath, string(ldbytes), string(obytes)) err = hcsExportLayer(layerPath, exportFolderPath, string(ldbytes), string(obytes))
if err != nil { if err != nil {
return fmt.Errorf("failed to export layer: %s", err) return errors.Wrap(err, "failed to export layer")
} }
return nil return nil
} }

@ -2,9 +2,9 @@ package computestorage
import ( import (
"context" "context"
"fmt"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
@ -14,13 +14,13 @@ import (
// If the VHD is not mounted it will be temporarily mounted. // If the VHD is not mounted it will be temporarily mounted.
func FormatWritableLayerVhd(ctx context.Context, vhdHandle windows.Handle) (err error) { func FormatWritableLayerVhd(ctx context.Context, vhdHandle windows.Handle) (err error) {
title := "hcsshim.FormatWritableLayerVhd" title := "hcsshim.FormatWritableLayerVhd"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
err = hcsFormatWritableLayerVhd(vhdHandle) err = hcsFormatWritableLayerVhd(vhdHandle)
if err != nil { if err != nil {
return fmt.Errorf("failed to format writable layer vhd: %s", err) return errors.Wrap(err, "failed to format writable layer vhd")
} }
return nil return nil
} }

@ -70,11 +70,9 @@ func SetupContainerBaseLayer(ctx context.Context, layerPath, baseVhdPath, diffVh
defer func() { defer func() {
if err != nil { if err != nil {
syscall.CloseHandle(handle) _ = syscall.CloseHandle(handle)
os.RemoveAll(baseVhdPath) os.RemoveAll(baseVhdPath)
if os.Stat(diffVhdPath); err == nil { os.RemoveAll(diffVhdPath)
os.RemoveAll(diffVhdPath)
}
} }
}() }()
@ -148,11 +146,9 @@ func SetupUtilityVMBaseLayer(ctx context.Context, uvmPath, baseVhdPath, diffVhdP
defer func() { defer func() {
if err != nil { if err != nil {
syscall.CloseHandle(handle) _ = syscall.CloseHandle(handle)
os.RemoveAll(baseVhdPath) os.RemoveAll(baseVhdPath)
if os.Stat(diffVhdPath); err == nil { os.RemoveAll(diffVhdPath)
os.RemoveAll(diffVhdPath)
}
} }
}() }()

@ -3,9 +3,9 @@ package computestorage
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
) )
@ -20,7 +20,7 @@ import (
// `layerData` is the parent layer data. // `layerData` is the parent layer data.
func ImportLayer(ctx context.Context, layerPath, sourceFolderPath string, layerData LayerData) (err error) { func ImportLayer(ctx context.Context, layerPath, sourceFolderPath string, layerData LayerData) (err error) {
title := "hcsshim.ImportLayer" title := "hcsshim.ImportLayer"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes( span.AddAttributes(
@ -35,7 +35,7 @@ func ImportLayer(ctx context.Context, layerPath, sourceFolderPath string, layerD
err = hcsImportLayer(layerPath, sourceFolderPath, string(bytes)) err = hcsImportLayer(layerPath, sourceFolderPath, string(bytes))
if err != nil { if err != nil {
return fmt.Errorf("failed to import layer: %s", err) return errors.Wrap(err, "failed to import layer")
} }
return nil return nil
} }

@ -3,9 +3,9 @@ package computestorage
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"fmt"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
) )
@ -17,7 +17,7 @@ import (
// `layerData` is the parent read-only layer data. // `layerData` is the parent read-only layer data.
func InitializeWritableLayer(ctx context.Context, layerPath string, layerData LayerData) (err error) { func InitializeWritableLayer(ctx context.Context, layerPath string, layerData LayerData) (err error) {
title := "hcsshim.InitializeWritableLayer" title := "hcsshim.InitializeWritableLayer"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes( span.AddAttributes(
@ -32,7 +32,7 @@ func InitializeWritableLayer(ctx context.Context, layerPath string, layerData La
// Options are not used in the platform as of RS5 // Options are not used in the platform as of RS5
err = hcsInitializeWritableLayer(layerPath, string(bytes), "") err = hcsInitializeWritableLayer(layerPath, string(bytes), "")
if err != nil { if err != nil {
return fmt.Errorf("failed to intitialize container layer: %s", err) return errors.Wrap(err, "failed to intitialize container layer")
} }
return nil return nil
} }

@ -2,10 +2,10 @@ package computestorage
import ( import (
"context" "context"
"fmt"
"github.com/Microsoft/hcsshim/internal/interop" "github.com/Microsoft/hcsshim/internal/interop"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
@ -13,14 +13,14 @@ import (
// GetLayerVhdMountPath returns the volume path for a virtual disk of a writable container layer. // GetLayerVhdMountPath returns the volume path for a virtual disk of a writable container layer.
func GetLayerVhdMountPath(ctx context.Context, vhdHandle windows.Handle) (path string, err error) { func GetLayerVhdMountPath(ctx context.Context, vhdHandle windows.Handle) (path string, err error) {
title := "hcsshim.GetLayerVhdMountPath" title := "hcsshim.GetLayerVhdMountPath"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
var mountPath *uint16 var mountPath *uint16
err = hcsGetLayerVhdMountPath(vhdHandle, &mountPath) err = hcsGetLayerVhdMountPath(vhdHandle, &mountPath)
if err != nil { if err != nil {
return "", fmt.Errorf("failed to get vhd mount path: %s", err) return "", errors.Wrap(err, "failed to get vhd mount path")
} }
path = interop.ConvertAndFreeCoTaskMemString(mountPath) path = interop.ConvertAndFreeCoTaskMemString(mountPath)
return path, nil return path, nil

@ -3,11 +3,10 @@ package computestorage
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"errors"
"fmt"
"github.com/Microsoft/hcsshim/internal/oc" "github.com/Microsoft/hcsshim/internal/oc"
"github.com/Microsoft/hcsshim/osversion" "github.com/Microsoft/hcsshim/osversion"
"github.com/pkg/errors"
"go.opencensus.io/trace" "go.opencensus.io/trace"
"golang.org/x/sys/windows" "golang.org/x/sys/windows"
) )
@ -23,7 +22,7 @@ import (
// `options` are the options applied while processing the layer. // `options` are the options applied while processing the layer.
func SetupBaseOSLayer(ctx context.Context, layerPath string, vhdHandle windows.Handle, options OsLayerOptions) (err error) { func SetupBaseOSLayer(ctx context.Context, layerPath string, vhdHandle windows.Handle, options OsLayerOptions) (err error) {
title := "hcsshim.SetupBaseOSLayer" title := "hcsshim.SetupBaseOSLayer"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes( span.AddAttributes(
@ -37,7 +36,7 @@ func SetupBaseOSLayer(ctx context.Context, layerPath string, vhdHandle windows.H
err = hcsSetupBaseOSLayer(layerPath, vhdHandle, string(bytes)) err = hcsSetupBaseOSLayer(layerPath, vhdHandle, string(bytes))
if err != nil { if err != nil {
return fmt.Errorf("failed to setup base OS layer: %s", err) return errors.Wrap(err, "failed to setup base OS layer")
} }
return nil return nil
} }
@ -50,11 +49,11 @@ func SetupBaseOSLayer(ctx context.Context, layerPath string, vhdHandle windows.H
// //
// `options` are the options applied while processing the layer. // `options` are the options applied while processing the layer.
func SetupBaseOSVolume(ctx context.Context, layerPath, volumePath string, options OsLayerOptions) (err error) { func SetupBaseOSVolume(ctx context.Context, layerPath, volumePath string, options OsLayerOptions) (err error) {
if osversion.Get().Build < 19645 { if osversion.Build() < 19645 {
return errors.New("SetupBaseOSVolume is not present on builds older than 19645") return errors.New("SetupBaseOSVolume is not present on builds older than 19645")
} }
title := "hcsshim.SetupBaseOSVolume" title := "hcsshim.SetupBaseOSVolume"
ctx, span := trace.StartSpan(ctx, title) ctx, span := trace.StartSpan(ctx, title) //nolint:ineffassign,staticcheck
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes( span.AddAttributes(
@ -69,7 +68,7 @@ func SetupBaseOSVolume(ctx context.Context, layerPath, volumePath string, option
err = hcsSetupBaseOSVolume(layerPath, volumePath, string(bytes)) err = hcsSetupBaseOSVolume(layerPath, volumePath, string(bytes))
if err != nil { if err != nil {
return fmt.Errorf("failed to setup base OS layer: %s", err) return errors.Wrap(err, "failed to setup base OS layer")
} }
return nil return nil
} }

@ -4,7 +4,7 @@
package computestorage package computestorage
import ( import (
hcsschema "github.com/Microsoft/hcsshim/internal/schema2" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
) )
//go:generate go run ../mksyscall_windows.go -output zsyscall_windows.go storage.go //go:generate go run ../mksyscall_windows.go -output zsyscall_windows.go storage.go

@ -8,8 +8,8 @@ import (
"time" "time"
"github.com/Microsoft/hcsshim/internal/hcs" "github.com/Microsoft/hcsshim/internal/hcs"
"github.com/Microsoft/hcsshim/internal/hcs/schema1"
"github.com/Microsoft/hcsshim/internal/mergemaps" "github.com/Microsoft/hcsshim/internal/mergemaps"
"github.com/Microsoft/hcsshim/internal/schema1"
) )
// ContainerProperties holds the properties for a container and the processes running in that container // ContainerProperties holds the properties for a container and the processes running in that container

@ -83,7 +83,6 @@ type NetworkNotFoundError = hns.NetworkNotFoundError
type ProcessError struct { type ProcessError struct {
Process *process Process *process
Operation string Operation string
ExtraInfo string
Err error Err error
Events []hcs.ErrorEvent Events []hcs.ErrorEvent
} }
@ -92,7 +91,6 @@ type ProcessError struct {
type ContainerError struct { type ContainerError struct {
Container *container Container *container
Operation string Operation string
ExtraInfo string
Err error Err error
Events []hcs.ErrorEvent Events []hcs.ErrorEvent
} }
@ -125,22 +123,9 @@ func (e *ContainerError) Error() string {
s += "\n" + ev.String() s += "\n" + ev.String()
} }
if e.ExtraInfo != "" {
s += " extra info: " + e.ExtraInfo
}
return s return s
} }
func makeContainerError(container *container, operation string, extraInfo string, err error) error {
// Don't double wrap errors
if _, ok := err.(*ContainerError); ok {
return err
}
containerError := &ContainerError{Container: container, Operation: operation, ExtraInfo: extraInfo, Err: err}
return containerError
}
func (e *ProcessError) Error() string { func (e *ProcessError) Error() string {
if e == nil { if e == nil {
return "<nil>" return "<nil>"
@ -171,15 +156,6 @@ func (e *ProcessError) Error() string {
return s return s
} }
func makeProcessError(process *process, operation string, extraInfo string, err error) error {
// Don't double wrap errors
if _, ok := err.(*ProcessError); ok {
return err
}
processError := &ProcessError{Process: process, Operation: operation, ExtraInfo: extraInfo, Err: err}
return processError
}
// IsNotExist checks if an error is caused by the Container or Process not existing. // IsNotExist checks if an error is caused by the Container or Process not existing.
// Note: Currently, ErrElementNotFound can mean that a Process has either // Note: Currently, ErrElementNotFound can mean that a Process has either
// already exited, or does not exist. Both IsAlreadyStopped and IsNotExist // already exited, or does not exist. Both IsAlreadyStopped and IsNotExist
@ -230,6 +206,18 @@ func IsNotSupported(err error) bool {
return hcs.IsNotSupported(getInnerError(err)) return hcs.IsNotSupported(getInnerError(err))
} }
// IsOperationInvalidState returns true when err is caused by
// `ErrVmcomputeOperationInvalidState`.
func IsOperationInvalidState(err error) bool {
return hcs.IsOperationInvalidState(getInnerError(err))
}
// IsAccessIsDenied returns true when err is caused by
// `ErrVmcomputeOperationAccessIsDenied`.
func IsAccessIsDenied(err error) bool {
return hcs.IsAccessIsDenied(getInnerError(err))
}
func getInnerError(err error) error { func getInnerError(err error) error {
switch pe := err.(type) { switch pe := err.(type) {
case nil: case nil:
@ -244,7 +232,7 @@ func getInnerError(err error) error {
func convertSystemError(err error, c *container) error { func convertSystemError(err error, c *container) error {
if serr, ok := err.(*hcs.SystemError); ok { if serr, ok := err.(*hcs.SystemError); ok {
return &ContainerError{Container: c, Operation: serr.Op, ExtraInfo: serr.Extra, Err: serr.Err, Events: serr.Events} return &ContainerError{Container: c, Operation: serr.Op, Err: serr.Err, Events: serr.Events}
} }
return err return err
} }

@ -1,35 +0,0 @@
module github.com/Microsoft/hcsshim
go 1.13
require (
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331
github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1
github.com/containerd/containerd v1.3.2
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc // indirect
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448 // indirect
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3
github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2 // indirect
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f // indirect
github.com/opencontainers/runtime-spec v1.0.2
github.com/pkg/errors v0.9.1
github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7 // indirect
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.4.0 // indirect
github.com/urfave/cli v1.22.2
go.opencensus.io v0.22.0
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 // indirect
golang.org/x/sync v0.0.0-20190423024810-112230192c58
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873 // indirect
google.golang.org/grpc v1.23.1
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.2.8 // indirect
gotest.tools v2.2.0+incompatible // indirect
)

@ -1,161 +0,0 @@
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Microsoft/go-winio v0.4.15-0.20200908182639-5b44b70ab3ab h1:9pygWVFqbY9lPxM0peffumuVDyMuIMzNLyO9uFjJuQo=
github.com/Microsoft/go-winio v0.4.15-0.20200908182639-5b44b70ab3ab/go.mod h1:tTuCMEN+UleMWgg9dVx4Hu52b1bJo+59jBh3ajtinzw=
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331 h1:3YnB7Hpmh1lPecPE8doMOtYCrMdrpedZOvxfuNES/Vk=
github.com/Microsoft/go-winio v0.4.16-0.20201130162521-d1ffc52c7331/go.mod h1:XB6nPKklQyQ7GC9LdcBEcBl8PF76WugXOPRXwdLnMv0=
github.com/cilium/ebpf v0.0.0-20200110133405-4032b1d8aae3/go.mod h1:MA5e5Lr8slmEg9bt0VpxxWqJlO4iwu3FBdHUzV7wQVg=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59 h1:qWj4qVYZ95vLWwqyNJCQg7rDsG5wPdze0UaPolH7DUk=
github.com/containerd/cgroups v0.0.0-20200531161412-0dbf7f05ba59/go.mod h1:pA0z1pT8KYB3TCXK/ocprsh7MAkoW8bZVzPdih9snmM=
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1 h1:uict5mhHFTzKLUCufdSLym7z/J0CbBJT59lYbP9wtbg=
github.com/containerd/console v0.0.0-20180822173158-c12b1e7919c1/go.mod h1:Tj/on1eG8kiEhd0+fhSDzsPAFESxzBBvdyEgyryXffw=
github.com/containerd/containerd v1.3.2 h1:ForxmXkA6tPIvffbrDAcPUIB32QgXkt2XFj+F0UxetA=
github.com/containerd/containerd v1.3.2/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc h1:TP+534wVlf61smEIq1nwLLAjQVEK2EADoW3CX9AuT+8=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448 h1:PUD50EuOMkXVcpBIA/R95d56duJR9VxhwncsFbNnxW4=
github.com/containerd/fifo v0.0.0-20190226154929-a9fb20d87448/go.mod h1:ODA38xgv3Kuk8dQz2ZQXpnv/UZZUHUCL7pnLehbXgQI=
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3 h1:esQOJREg8nw8aXj6uCN5dfW5cKUBiEJ/+nni1Q/D/sw=
github.com/containerd/go-runc v0.0.0-20180907222934-5a6d9f37cfa3/go.mod h1:IV7qH3hrUgRmyYrtgEeGWJfWbgcHL9CSRruz2Vqcph0=
github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de h1:dlfGmNcE3jDAecLqwKPMNX6nk2qh1c1Vg1/YTzpOOF4=
github.com/containerd/ttrpc v0.0.0-20190828154514-0e0f228740de/go.mod h1:PvCDdDGpgqzQIzDW1TphrGLssLDZp2GuS+X5DkEJB8o=
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd h1:JNn81o/xG+8NEo3bC/vx9pbi/g2WI8mtP2/nXzu297Y=
github.com/containerd/typeurl v0.0.0-20180627222232-a93fcdb778cd/go.mod h1:Cm3kwCdlkCfMSHURc+r6fwoGH6/F1hH3S4sg0rLFWPc=
github.com/coreos/go-systemd/v22 v22.0.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/docker/go-units v0.4.0 h1:3uh0PgVws3nIA0Q+MwDC8yjEPf9zjRfZZWXZYDct3Tw=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.3.1 h1:DqDEcV5aeaTmdFBePNpYsp3FlcVH/2ISVVM9Qf8PSls=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s=
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2 h1:QhPf3A2AZW3tTGvHPg0TA+CR3oHbVLlXUhlghqISp1I=
github.com/opencontainers/go-digest v0.0.0-20180430190053-c9281466c8b2/go.mod h1:cMLVZDEM3+U2I4VmLI6N8jQYUd2OVphdqWwCJHrFt2s=
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f h1:a969LJ4IQFwRHYqonHtUDMSh9i54WcKggeEkQ3fZMl4=
github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U=
github.com/opencontainers/runtime-spec v1.0.2 h1:UfAcuLBJB9Coz72x1hgl8O5RVzTdNiaglX6v2DM6FI0=
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7 h1:hhvfGDVThBnd4kYisSFmYuHYeUhglxcwag7FhVPH9zM=
github.com/prometheus/procfs v0.0.0-20180125133057-cb4147076ac7/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k=
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
go.opencensus.io v0.22.0 h1:C9hSCOW830chIVkdja34wa6Ky+IzWllkUinR+BtRZd4=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09 h1:KaQtG+aDELoNmXYas3TVkGNYRuq8JQ1aa7LJt8EXVyo=
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9 h1:rjwSpXsdiK0dV8/Naq3kAw9ymfAeJIyd0upUIElB+lI=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6 h1:bjcUS9ztw9kFmmIxJInhon/0Is3p+EHBKNgquIzo1OI=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3 h1:7TYNF4UdlohbFwpNH04CoPMp1cHUZgO1Ebq5r2hIjfo=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191022100944-742c48ecaeb7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200120151820-655fe14d7479 h1:LhLiKguPgZL+Tglay4GhVtfF0kb8cvOJ0dHTCBO8YNI=
golang.org/x/sys v0.0.0-20200120151820-655fe14d7479/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3 h1:kzM6+9dur93BcC2kVlYl34cHU+TYZLanmpSJHVMmL64=
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb h1:i1Ppqkc3WQXikh8bXiwHqAN5Rv3/qDCcRk0/Otx73BY=
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873 h1:nfPFGzJkUDX6uBmpN/pSw7MbOAWegH5QDQuoXFHedLg=
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.20.1 h1:Hz2g2wirWK7H0qIIhGIqRGTuMwTE8HEKFnDZZ7lm9NU=
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
google.golang.org/grpc v1.23.1 h1:q4XQuHFC6I28BKZpo6IYyb3mNO+l7lSOxRuYTCiDfXk=
google.golang.org/grpc v1.23.1/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=

@ -40,6 +40,9 @@ func HNSListEndpointRequest() ([]HNSEndpoint, error) {
// HotAttachEndpoint makes a HCS Call to attach the endpoint to the container // HotAttachEndpoint makes a HCS Call to attach the endpoint to the container
func HotAttachEndpoint(containerID string, endpointID string) error { func HotAttachEndpoint(containerID string, endpointID string) error {
endpoint, err := GetHNSEndpointByID(endpointID) endpoint, err := GetHNSEndpointByID(endpointID)
if err != nil {
return err
}
isAttached, err := endpoint.IsAttached(containerID) isAttached, err := endpoint.IsAttached(containerID)
if isAttached { if isAttached {
return err return err
@ -50,6 +53,9 @@ func HotAttachEndpoint(containerID string, endpointID string) error {
// HotDetachEndpoint makes a HCS Call to detach the endpoint from the container // HotDetachEndpoint makes a HCS Call to detach the endpoint from the container
func HotDetachEndpoint(containerID string, endpointID string) error { func HotDetachEndpoint(containerID string, endpointID string) error {
endpoint, err := GetHNSEndpointByID(endpointID) endpoint, err := GetHNSEndpointByID(endpointID)
if err != nil {
return err
}
isAttached, err := endpoint.IsAttached(containerID) isAttached, err := endpoint.IsAttached(containerID)
if !isAttached { if !isAttached {
return err return err

@ -4,7 +4,7 @@ import (
"io" "io"
"time" "time"
"github.com/Microsoft/hcsshim/internal/schema1" "github.com/Microsoft/hcsshim/internal/hcs/schema1"
) )
// ProcessConfig is used as both the input of Container.CreateProcess // ProcessConfig is used as both the input of Container.CreateProcess

@ -4,8 +4,8 @@ import (
"context" "context"
"io" "io"
"github.com/Microsoft/hcsshim/internal/schema1" "github.com/Microsoft/hcsshim/internal/hcs/schema1"
hcsschema "github.com/Microsoft/hcsshim/internal/schema2" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
) )
// Process is the interface for an OS process running in a container or utility VM. // Process is the interface for an OS process running in a container or utility VM.
@ -17,6 +17,12 @@ type Process interface {
// CloseStdin causes the process's stdin handle to receive EOF/EPIPE/whatever // CloseStdin causes the process's stdin handle to receive EOF/EPIPE/whatever
// is appropriate to indicate that no more data is available. // is appropriate to indicate that no more data is available.
CloseStdin(ctx context.Context) error CloseStdin(ctx context.Context) error
// CloseStdout closes the stdout connection to the process. It is used to indicate
// that we are done receiving output on the shim side.
CloseStdout(ctx context.Context) error
// CloseStderr closes the stderr connection to the process. It is used to indicate
// that we are done receiving output on the shim side.
CloseStderr(ctx context.Context) error
// Pid returns the process ID. // Pid returns the process ID.
Pid() int Pid() int
// Stdio returns the stdio streams for a process. These may be nil if a stream // Stdio returns the stdio streams for a process. These may be nil if a stream
@ -80,4 +86,6 @@ type Container interface {
// container to be terminated by some error condition (including calling // container to be terminated by some error condition (including calling
// Close). // Close).
Wait() error Wait() error
// Modify sends a request to modify container resources
Modify(ctx context.Context, config interface{}) error
} }

@ -13,7 +13,7 @@ import (
var ( var (
nextCallback uintptr nextCallback uintptr
callbackMap = map[uintptr]*notifcationWatcherContext{} callbackMap = map[uintptr]*notificationWatcherContext{}
callbackMapLock = sync.RWMutex{} callbackMapLock = sync.RWMutex{}
notificationWatcherCallback = syscall.NewCallback(notificationWatcher) notificationWatcherCallback = syscall.NewCallback(notificationWatcher)
@ -87,7 +87,7 @@ func (hn hcsNotification) String() string {
type notificationChannel chan error type notificationChannel chan error
type notifcationWatcherContext struct { type notificationWatcherContext struct {
channels notificationChannels channels notificationChannels
handle vmcompute.HcsCallback handle vmcompute.HcsCallback
@ -106,6 +106,7 @@ func newSystemChannels() notificationChannels {
hcsNotificationSystemStartCompleted, hcsNotificationSystemStartCompleted,
hcsNotificationSystemPauseCompleted, hcsNotificationSystemPauseCompleted,
hcsNotificationSystemResumeCompleted, hcsNotificationSystemResumeCompleted,
hcsNotificationSystemSaveCompleted,
} { } {
channels[notif] = make(notificationChannel, 1) channels[notif] = make(notificationChannel, 1)
} }

@ -171,7 +171,6 @@ type SystemError struct {
ID string ID string
Op string Op string
Err error Err error
Extra string
Events []ErrorEvent Events []ErrorEvent
} }
@ -182,9 +181,6 @@ func (e *SystemError) Error() string {
for _, ev := range e.Events { for _, ev := range e.Events {
s += "\n" + ev.String() s += "\n" + ev.String()
} }
if e.Extra != "" {
s += "\n(extra info: " + e.Extra + ")"
}
return s return s
} }
@ -198,7 +194,7 @@ func (e *SystemError) Timeout() bool {
return ok && err.Timeout() 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 // Don't double wrap errors
if _, ok := err.(*SystemError); ok { if _, ok := err.(*SystemError); ok {
return err return err
@ -206,7 +202,6 @@ func makeSystemError(system *System, op string, extra string, err error, events
return &SystemError{ return &SystemError{
ID: system.ID(), ID: system.ID(),
Op: op, Op: op,
Extra: extra,
Err: err, Err: err,
Events: events, Events: events,
} }
@ -312,6 +307,13 @@ func IsOperationInvalidState(err error) bool {
return err == ErrVmcomputeOperationInvalidState return err == ErrVmcomputeOperationInvalidState
} }
// IsAccessIsDenied returns true when err is caused by
// `ErrVmcomputeOperationAccessIsDenied`.
func IsAccessIsDenied(err error) bool {
err = getInnerError(err)
return err == ErrVmcomputeOperationAccessIsDenied
}
func getInnerError(err error) error { func getInnerError(err error) error {
switch pe := err.(type) { switch pe := err.(type) {
case nil: case nil:
@ -325,12 +327,3 @@ func getInnerError(err error) error {
} }
return err return err
} }
func getOperationLogResult(err error) (string, error) {
switch err {
case nil:
return "Success", nil
default:
return "Error", err
}
}

@ -64,11 +64,7 @@ type processStatus struct {
LastWaitResult int32 LastWaitResult int32
} }
const ( const stdIn string = "StdIn"
stdIn string = "StdIn"
stdOut string = "StdOut"
stdErr string = "StdErr"
)
const ( const (
modifyConsoleSize string = "ConsoleSize" modifyConsoleSize string = "ConsoleSize"
@ -122,7 +118,7 @@ func (process *Process) Signal(ctx context.Context, options interface{}) (bool,
process.handleLock.RLock() process.handleLock.RLock()
defer process.handleLock.RUnlock() defer process.handleLock.RUnlock()
operation := "hcsshim::Process::Signal" operation := "hcs::Process::Signal"
if process.handle == 0 { if process.handle == 0 {
return false, makeProcessError(process, operation, ErrAlreadyClosed, nil) return false, makeProcessError(process, operation, ErrAlreadyClosed, nil)
@ -147,7 +143,7 @@ func (process *Process) Kill(ctx context.Context) (bool, error) {
process.handleLock.RLock() process.handleLock.RLock()
defer process.handleLock.RUnlock() defer process.handleLock.RUnlock()
operation := "hcsshim::Process::Kill" operation := "hcs::Process::Kill"
if process.handle == 0 { if process.handle == 0 {
return false, makeProcessError(process, operation, ErrAlreadyClosed, nil) return false, makeProcessError(process, operation, ErrAlreadyClosed, nil)
@ -168,7 +164,7 @@ func (process *Process) Kill(ctx context.Context) (bool, error) {
// This MUST be called exactly once per `process.handle` but `Wait` is safe to // This MUST be called exactly once per `process.handle` but `Wait` is safe to
// call multiple times. // call multiple times.
func (process *Process) waitBackground() { func (process *Process) waitBackground() {
operation := "hcsshim::Process::waitBackground" operation := "hcs::Process::waitBackground"
ctx, span := trace.StartSpan(context.Background(), operation) ctx, span := trace.StartSpan(context.Background(), operation)
defer span.End() defer span.End()
span.AddAttributes( span.AddAttributes(
@ -176,8 +172,10 @@ func (process *Process) waitBackground() {
trace.Int64Attribute("pid", int64(process.processID))) trace.Int64Attribute("pid", int64(process.processID)))
var ( var (
err error err error
exitCode = -1 exitCode = -1
propertiesJSON string
resultJSON string
) )
err = waitForNotification(ctx, process.callbackNumber, hcsNotificationProcessExited, nil) err = waitForNotification(ctx, process.callbackNumber, hcsNotificationProcessExited, nil)
@ -190,15 +188,15 @@ func (process *Process) waitBackground() {
// Make sure we didnt race with Close() here // Make sure we didnt race with Close() here
if process.handle != 0 { if process.handle != 0 {
propertiesJSON, resultJSON, err := vmcompute.HcsGetProcessProperties(ctx, process.handle) propertiesJSON, resultJSON, err = vmcompute.HcsGetProcessProperties(ctx, process.handle)
events := processHcsResult(ctx, resultJSON) events := processHcsResult(ctx, resultJSON)
if err != nil { if err != nil {
err = makeProcessError(process, operation, err, events) err = makeProcessError(process, operation, err, events) //nolint:ineffassign
} else { } else {
properties := &processStatus{} properties := &processStatus{}
err = json.Unmarshal([]byte(propertiesJSON), properties) err = json.Unmarshal([]byte(propertiesJSON), properties)
if err != nil { if err != nil {
err = makeProcessError(process, operation, err, nil) err = makeProcessError(process, operation, err, nil) //nolint:ineffassign
} else { } else {
if properties.LastWaitResult != 0 { if properties.LastWaitResult != 0 {
log.G(ctx).WithField("wait-result", properties.LastWaitResult).Warning("non-zero last wait result") log.G(ctx).WithField("wait-result", properties.LastWaitResult).Warning("non-zero last wait result")
@ -231,7 +229,7 @@ func (process *Process) ResizeConsole(ctx context.Context, width, height uint16)
process.handleLock.RLock() process.handleLock.RLock()
defer process.handleLock.RUnlock() defer process.handleLock.RUnlock()
operation := "hcsshim::Process::ResizeConsole" operation := "hcs::Process::ResizeConsole"
if process.handle == 0 { if process.handle == 0 {
return makeProcessError(process, operation, ErrAlreadyClosed, nil) return makeProcessError(process, operation, ErrAlreadyClosed, nil)
@ -269,7 +267,7 @@ func (process *Process) ExitCode() (int, error) {
} }
return process.exitCode, nil return process.exitCode, nil
default: default:
return -1, makeProcessError(process, "hcsshim::Process::ExitCode", ErrInvalidProcessState, nil) return -1, makeProcessError(process, "hcs::Process::ExitCode", ErrInvalidProcessState, nil)
} }
} }
@ -277,7 +275,7 @@ func (process *Process) ExitCode() (int, error) {
// these pipes does not close the underlying pipes. Once returned, these pipes // these pipes does not close the underlying pipes. Once returned, these pipes
// are the responsibility of the caller to close. // are the responsibility of the caller to close.
func (process *Process) StdioLegacy() (_ io.WriteCloser, _ io.ReadCloser, _ io.ReadCloser, err error) { func (process *Process) StdioLegacy() (_ io.WriteCloser, _ io.ReadCloser, _ io.ReadCloser, err error) {
operation := "hcsshim::Process::StdioLegacy" operation := "hcs::Process::StdioLegacy"
ctx, span := trace.StartSpan(context.Background(), operation) ctx, span := trace.StartSpan(context.Background(), operation)
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
@ -329,7 +327,7 @@ func (process *Process) CloseStdin(ctx context.Context) error {
process.handleLock.RLock() process.handleLock.RLock()
defer process.handleLock.RUnlock() defer process.handleLock.RUnlock()
operation := "hcsshim::Process::CloseStdin" operation := "hcs::Process::CloseStdin"
if process.handle == 0 { if process.handle == 0 {
return makeProcessError(process, operation, ErrAlreadyClosed, nil) return makeProcessError(process, operation, ErrAlreadyClosed, nil)
@ -363,10 +361,59 @@ func (process *Process) CloseStdin(ctx context.Context) error {
return nil return nil
} }
func (process *Process) CloseStdout(ctx context.Context) (err error) {
ctx, span := trace.StartSpan(ctx, "hcs::Process::CloseStdout") //nolint:ineffassign,staticcheck
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes(
trace.StringAttribute("cid", process.SystemID()),
trace.Int64Attribute("pid", int64(process.processID)))
process.handleLock.Lock()
defer process.handleLock.Unlock()
if process.handle == 0 {
return nil
}
process.stdioLock.Lock()
defer process.stdioLock.Unlock()
if process.stdout != nil {
process.stdout.Close()
process.stdout = nil
}
return nil
}
func (process *Process) CloseStderr(ctx context.Context) (err error) {
ctx, span := trace.StartSpan(ctx, "hcs::Process::CloseStderr") //nolint:ineffassign,staticcheck
defer span.End()
defer func() { oc.SetSpanStatus(span, err) }()
span.AddAttributes(
trace.StringAttribute("cid", process.SystemID()),
trace.Int64Attribute("pid", int64(process.processID)))
process.handleLock.Lock()
defer process.handleLock.Unlock()
if process.handle == 0 {
return nil
}
process.stdioLock.Lock()
defer process.stdioLock.Unlock()
if process.stderr != nil {
process.stderr.Close()
process.stderr = nil
}
return nil
}
// Close cleans up any state associated with the process but does not kill // Close cleans up any state associated with the process but does not kill
// or wait on it. // or wait on it.
func (process *Process) Close() (err error) { func (process *Process) Close() (err error) {
operation := "hcsshim::Process::Close" operation := "hcs::Process::Close"
ctx, span := trace.StartSpan(context.Background(), operation) ctx, span := trace.StartSpan(context.Background(), operation)
defer span.End() defer span.End()
defer func() { oc.SetSpanStatus(span, err) }() defer func() { oc.SetSpanStatus(span, err) }()
@ -416,7 +463,7 @@ func (process *Process) Close() (err error) {
} }
func (process *Process) registerCallback(ctx context.Context) error { func (process *Process) registerCallback(ctx context.Context) error {
callbackContext := &notifcationWatcherContext{ callbackContext := &notificationWatcherContext{
channels: newProcessChannels(), channels: newProcessChannels(),
systemID: process.SystemID(), systemID: process.SystemID(),
processID: process.processID, processID: process.processID,
@ -468,7 +515,7 @@ func (process *Process) unregisterCallback(ctx context.Context) error {
delete(callbackMap, callbackNumber) delete(callbackMap, callbackNumber)
callbackMapLock.Unlock() callbackMapLock.Unlock()
handle = 0 handle = 0 //nolint:ineffassign
return nil return nil
} }

@ -5,7 +5,7 @@ import (
"time" "time"
"github.com/Microsoft/go-winio/pkg/guid" "github.com/Microsoft/go-winio/pkg/guid"
hcsschema "github.com/Microsoft/hcsshim/internal/schema2" hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2"
) )
// ProcessConfig is used as both the input of Container.CreateProcess // ProcessConfig is used as both the input of Container.CreateProcess
@ -119,9 +119,9 @@ type PropertyType string
const ( const (
PropertyTypeStatistics PropertyType = "Statistics" // V1 and V2 PropertyTypeStatistics PropertyType = "Statistics" // V1 and V2
PropertyTypeProcessList = "ProcessList" // V1 and V2 PropertyTypeProcessList PropertyType = "ProcessList" // V1 and V2
PropertyTypeMappedVirtualDisk = "MappedVirtualDisk" // Not supported in V2 schema call PropertyTypeMappedVirtualDisk PropertyType = "MappedVirtualDisk" // Not supported in V2 schema call
PropertyTypeGuestConnection = "GuestConnection" // V1 and V2. Nil return from HCS before RS5 PropertyTypeGuestConnection PropertyType = "GuestConnection" // V1 and V2. Nil return from HCS before RS5
) )
type PropertyQuery struct { type PropertyQuery struct {
@ -218,6 +218,7 @@ type GuestDefinedCapabilities struct {
SignalProcessSupported bool `json:",omitempty"` SignalProcessSupported bool `json:",omitempty"`
DumpStacksSupported bool `json:",omitempty"` DumpStacksSupported bool `json:",omitempty"`
DeleteContainerStateSupported bool `json:",omitempty"` DeleteContainerStateSupported bool `json:",omitempty"`
UpdateContainerSupported bool `json:",omitempty"`
} }
// GuestConnectionInfo is the structure of an iterm return by a GuestConnection call on a utility VM // GuestConnectionInfo is the structure of an iterm return by a GuestConnection call on a utility VM

@ -13,8 +13,8 @@ type DeviceType string
const ( const (
ClassGUID DeviceType = "ClassGuid" ClassGUID DeviceType = "ClassGuid"
DeviceInstance = "DeviceInstance" DeviceInstance DeviceType = "DeviceInstance"
GPUMirror = "GpuMirror" GPUMirror DeviceType = "GpuMirror"
) )
type Device struct { type Device struct {

@ -0,0 +1,42 @@
/*
* HCS API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package hcsschema
type InterruptModerationName string
// The valid interrupt moderation modes for I/O virtualization (IOV) offloading.
const (
DefaultName InterruptModerationName = "Default"
AdaptiveName InterruptModerationName = "Adaptive"
OffName InterruptModerationName = "Off"
LowName InterruptModerationName = "Low"
MediumName InterruptModerationName = "Medium"
HighName InterruptModerationName = "High"
)
type InterruptModerationValue uint32
const (
DefaultValue InterruptModerationValue = iota
AdaptiveValue
OffValue
LowValue InterruptModerationValue = 100
MediumValue InterruptModerationValue = 200
HighValue InterruptModerationValue = 300
)
var InterruptModerationValueToName = map[InterruptModerationValue]InterruptModerationName{
DefaultValue: DefaultName,
AdaptiveValue: AdaptiveName,
OffValue: OffName,
LowValue: LowName,
MediumValue: MediumName,
HighValue: HighName,
}

@ -0,0 +1,22 @@
/*
* HCS API
*
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
*
* API version: 2.4
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package hcsschema
type IovSettings struct {
// The weight assigned to this port for I/O virtualization (IOV) offloading.
// Setting this to 0 disables IOV offloading.
OffloadWeight *uint32 `json:"OffloadWeight,omitempty"`
// The number of queue pairs requested for this port for I/O virtualization (IOV) offloading.
QueuePairsRequested *uint32 `json:"QueuePairsRequested,omitempty"`
// The interrupt moderation mode for I/O virtualization (IOV) offloading.
InterruptModeration *InterruptModerationName `json:"InterruptModeration,omitempty"`
}

@ -11,8 +11,8 @@ package hcsschema
type LogicalProcessor struct { type LogicalProcessor struct {
LpIndex uint32 `json:"LpIndex,omitempty"` LpIndex uint32 `json:"LpIndex,omitempty"`
NodeNumber uint8 `json:"NodeNumber, omitempty"` NodeNumber uint8 `json:"NodeNumber,omitempty"`
PackageId uint32 `json:"PackageId, omitempty"` PackageId uint32 `json:"PackageId,omitempty"`
CoreId uint32 `json:"CoreId, omitempty"` CoreId uint32 `json:"CoreId,omitempty"`
RootVpIndex int32 `json:"RootVpIndex, omitempty"` RootVpIndex int32 `json:"RootVpIndex,omitempty"`
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save