mirror of https://github.com/portainer/portainer
fix(podman): ensure initial env type matches container runtime [r8s-98] (#12259)
parent
32e94d4e4e
commit
da010f3d08
|
@ -769,6 +769,7 @@
|
||||||
"GpuUseList": null,
|
"GpuUseList": null,
|
||||||
"HealthyContainerCount": 0,
|
"HealthyContainerCount": 0,
|
||||||
"ImageCount": 9,
|
"ImageCount": 9,
|
||||||
|
"IsPodman": false,
|
||||||
"NodeCount": 0,
|
"NodeCount": 0,
|
||||||
"RunningContainerCount": 5,
|
"RunningContainerCount": 5,
|
||||||
"ServiceCount": 0,
|
"ServiceCount": 0,
|
||||||
|
|
|
@ -267,6 +267,17 @@ func snapshotVersion(snapshot *portainer.DockerSnapshot, cli *client.Client) err
|
||||||
}
|
}
|
||||||
|
|
||||||
snapshot.SnapshotRaw.Version = version
|
snapshot.SnapshotRaw.Version = version
|
||||||
|
snapshot.IsPodman = isPodman(version)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// isPodman checks if the version is for Podman by checking if any of the components contain "podman".
|
||||||
|
// If it's podman, a component name should be "Podman Engine"
|
||||||
|
func isPodman(version types.Version) bool {
|
||||||
|
for _, component := range version.Components {
|
||||||
|
if strings.Contains(strings.ToLower(component.Name), "podman") {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
@ -219,6 +219,10 @@ func (service *Service) snapshotDockerEndpoint(endpoint *portainer.Endpoint) err
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := validateContainerEngineCompatibility(endpoint, dockerSnapshot); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if dockerSnapshot != nil {
|
if dockerSnapshot != nil {
|
||||||
snapshot := &portainer.Snapshot{EndpointID: endpoint.ID, Docker: dockerSnapshot}
|
snapshot := &portainer.Snapshot{EndpointID: endpoint.ID, Docker: dockerSnapshot}
|
||||||
|
|
||||||
|
@ -228,6 +232,20 @@ func (service *Service) snapshotDockerEndpoint(endpoint *portainer.Endpoint) err
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func validateContainerEngineCompatibility(endpoint *portainer.Endpoint, dockerSnapshot *portainer.DockerSnapshot) error {
|
||||||
|
if endpoint.ContainerEngine == portainer.ContainerEngineDocker && dockerSnapshot.IsPodman {
|
||||||
|
err := errors.New("the Docker environment option doesn't support Podman environments. Please select the Podman option instead.")
|
||||||
|
log.Error().Err(err).Str("endpoint", endpoint.Name).Msg(err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if endpoint.ContainerEngine == portainer.ContainerEnginePodman && !dockerSnapshot.IsPodman {
|
||||||
|
err := errors.New("the Podman environment option doesn't support Docker environments. Please select the Docker option instead.")
|
||||||
|
log.Error().Err(err).Str("endpoint", endpoint.Name).Msg(err.Error())
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (service *Service) startSnapshotLoop() {
|
func (service *Service) startSnapshotLoop() {
|
||||||
ticker := time.NewTicker(time.Duration(service.snapshotIntervalInSeconds) * time.Second)
|
ticker := time.NewTicker(time.Duration(service.snapshotIntervalInSeconds) * time.Second)
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,7 @@ type (
|
||||||
NodeCount int `json:"NodeCount"`
|
NodeCount int `json:"NodeCount"`
|
||||||
GpuUseAll bool `json:"GpuUseAll"`
|
GpuUseAll bool `json:"GpuUseAll"`
|
||||||
GpuUseList []string `json:"GpuUseList"`
|
GpuUseList []string `json:"GpuUseList"`
|
||||||
|
IsPodman bool `json:"IsPodman"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DockerContainerSnapshot is an extent of Docker's Container struct
|
// DockerContainerSnapshot is an extent of Docker's Container struct
|
||||||
|
|
Loading…
Reference in New Issue