mirror of
https://github.com/portainer/portainer.git
synced 2025-08-03 04:45:21 +02:00
fix(docker): check len of device capabilities [BE-11898] (#750)
This commit is contained in:
parent
1bc91d0c7c
commit
45471ce86d
2 changed files with 13 additions and 9 deletions
|
@ -14,8 +14,7 @@ import (
|
|||
networkingutils "github.com/portainer/portainer/pkg/networking"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
_container "github.com/docker/docker/api/types/container"
|
||||
dockercontainer "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/docker/client"
|
||||
|
@ -128,7 +127,7 @@ func dockerSnapshotSwarmServices(snapshot *portainer.DockerSnapshot, cli *client
|
|||
}
|
||||
|
||||
func dockerSnapshotContainers(snapshot *portainer.DockerSnapshot, cli *client.Client) error {
|
||||
containers, err := cli.ContainerList(context.Background(), container.ListOptions{All: true})
|
||||
containers, err := cli.ContainerList(context.Background(), dockercontainer.ListOptions{All: true})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -170,11 +169,16 @@ func dockerSnapshotContainers(snapshot *portainer.DockerSnapshot, cli *client.Cl
|
|||
|
||||
containerEnvs[container.ID] = response.Config.Env
|
||||
|
||||
var gpuOptions *_container.DeviceRequest
|
||||
var gpuOptions *dockercontainer.DeviceRequest
|
||||
|
||||
for _, deviceRequest := range response.HostConfig.Resources.DeviceRequests {
|
||||
if deviceRequest.Driver == "nvidia" || deviceRequest.Capabilities[0][0] == "gpu" {
|
||||
gpuOptions = &deviceRequest
|
||||
if response.HostConfig != nil {
|
||||
for _, deviceRequest := range response.HostConfig.DeviceRequests {
|
||||
if deviceRequest.Driver == "nvidia" ||
|
||||
(len(deviceRequest.Capabilities) > 0 &&
|
||||
len(deviceRequest.Capabilities[0]) > 0 &&
|
||||
deviceRequest.Capabilities[0][0] == "gpu") {
|
||||
gpuOptions = &deviceRequest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -298,7 +302,7 @@ func dockerSnapshotContainerErrorLogs(snapshot *portainer.DockerSnapshot, cli *c
|
|||
return nil
|
||||
}
|
||||
|
||||
rd, err := cli.ContainerLogs(context.Background(), containerId, container.LogsOptions{
|
||||
rd, err := cli.ContainerLogs(context.Background(), containerId, dockercontainer.LogsOptions{
|
||||
ShowStdout: false,
|
||||
ShowStderr: true,
|
||||
Tail: "5",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue