mirror of
https://github.com/portainer/portainer.git
synced 2025-07-22 14:59:41 +02:00
fix(container): replace container using correct node name EE-7066 (#11847)
Some checks are pending
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
Some checks are pending
ci / build_images (map[arch:ppc64le platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:s390x platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
ci / build_images (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
ci / build_images (map[arch:arm platform:linux version:]) (push) Waiting to run
ci / build_images (map[arch:arm64 platform:linux version:]) (push) Waiting to run
ci / build_manifests (push) Blocked by required conditions
/ triage (push) Waiting to run
Lint / Run linters (push) Waiting to run
Test / test-client (push) Waiting to run
Test / test-server (map[arch:amd64 platform:linux]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:1809]) (push) Waiting to run
Test / test-server (map[arch:amd64 platform:windows version:ltsc2022]) (push) Waiting to run
Test / test-server (map[arch:arm64 platform:linux]) (push) Waiting to run
This commit is contained in:
parent
d283c63a33
commit
d7b412eccc
2 changed files with 13 additions and 6 deletions
|
@ -161,7 +161,7 @@ async function replace({
|
||||||
);
|
);
|
||||||
|
|
||||||
await removeContainer(environment.Id, oldContainer.Id, {
|
await removeContainer(environment.Id, oldContainer.Id, {
|
||||||
nodeName: values.nodeName,
|
nodeName: oldContainer.NodeName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,13 +178,17 @@ async function renameAndCreate(
|
||||||
) {
|
) {
|
||||||
let renamed = false;
|
let renamed = false;
|
||||||
try {
|
try {
|
||||||
await stopContainerIfNeeded(environmentId, oldContainer, nodeName);
|
await stopContainerIfNeeded(
|
||||||
|
environmentId,
|
||||||
|
oldContainer,
|
||||||
|
oldContainer.NodeName
|
||||||
|
);
|
||||||
|
|
||||||
await renameContainer(
|
await renameContainer(
|
||||||
environmentId,
|
environmentId,
|
||||||
oldContainer.Id,
|
oldContainer.Id,
|
||||||
`${oldContainer.Names[0]}-old`,
|
`${oldContainer.Names[0]}-old`,
|
||||||
{ nodeName }
|
{ nodeName: oldContainer.NodeName }
|
||||||
);
|
);
|
||||||
renamed = true;
|
renamed = true;
|
||||||
|
|
||||||
|
@ -192,7 +196,7 @@ async function renameAndCreate(
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (renamed) {
|
if (renamed) {
|
||||||
await renameContainer(environmentId, oldContainer.Id, name, {
|
await renameContainer(environmentId, oldContainer.Id, name, {
|
||||||
nodeName,
|
nodeName: oldContainer.NodeName,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
|
|
|
@ -10,7 +10,10 @@ import {
|
||||||
import { RawAxiosRequestHeaders } from 'axios';
|
import { RawAxiosRequestHeaders } from 'axios';
|
||||||
|
|
||||||
import { PortainerResponse } from '@/react/docker/types';
|
import { PortainerResponse } from '@/react/docker/types';
|
||||||
import axios, { parseAxiosError } from '@/portainer/services/axios';
|
import axios, {
|
||||||
|
agentTargetHeader,
|
||||||
|
parseAxiosError,
|
||||||
|
} from '@/portainer/services/axios';
|
||||||
import { ContainerId } from '@/react/docker/containers/types';
|
import { ContainerId } from '@/react/docker/containers/types';
|
||||||
import { EnvironmentId } from '@/react/portainer/environments/types';
|
import { EnvironmentId } from '@/react/portainer/environments/types';
|
||||||
import { queryClient } from '@/react-tools/react-query';
|
import { queryClient } from '@/react-tools/react-query';
|
||||||
|
@ -115,7 +118,7 @@ async function getContainer(
|
||||||
const headers: RawAxiosRequestHeaders = {};
|
const headers: RawAxiosRequestHeaders = {};
|
||||||
|
|
||||||
if (nodeName) {
|
if (nodeName) {
|
||||||
headers['X-PortainerAgent-Target'] = nodeName;
|
headers[agentTargetHeader] = nodeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data } = await axios.get<ContainerResponse>(
|
const { data } = await axios.get<ContainerResponse>(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue