Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions agent/app/service/backup_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ func stepRecreateContainer(recoverCtx *containerRecoverContext, taskItem *task.T
}

networkConfig, extraNetworks := buildContainerRecoverNetworkConfig(recoverCtx.inspectInfo.NetworkSettings, hostConfig)
removeBridgeDriverIPAM(recoverCtx.client, networkConfig, extraNetworks)
createRes, err := recoverCtx.client.ContainerCreate(ctx, config, hostConfig, networkConfig, nil, recoverCtx.targetName)
if err != nil {
return err
Expand All @@ -615,6 +616,28 @@ func stepRecreateContainer(recoverCtx *containerRecoverContext, taskItem *task.T
return nil
}

func removeBridgeDriverIPAM(cli *client.Client, primary *network.NetworkingConfig, extras map[string]*network.EndpointSettings) {
if primary != nil {
removeBridgeDriverIPAMFromEndpoints(cli, primary.EndpointsConfig)
}
removeBridgeDriverIPAMFromEndpoints(cli, extras)
}

func removeBridgeDriverIPAMFromEndpoints(cli *client.Client, endpoints map[string]*network.EndpointSettings) {
for netName, endpoint := range endpoints {
if endpoint == nil || endpoint.IPAMConfig == nil {
continue
}
info, err := cli.NetworkInspect(context.Background(), netName, network.InspectOptions{})
if err != nil {
continue
}
if info.Driver == "bridge" {
endpoint.IPAMConfig = nil
Comment on lines +635 to +636

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid clearing IPAM on all bridge networks

This now clears endpoint.IPAMConfig for every network using the bridge driver, which also includes user-defined bridge networks. During restore, containers that were intentionally configured with a fixed IP on such networks will lose that assignment and come up with a different address after ContainerCreate/NetworkConnect, which can break service-to-service connectivity that depends on the pinned IP. The IPAM removal should be limited to cases where the address was auto-assigned (or only the default bridge network), not all bridge-driver networks.

Useful? React with 👍 / 👎.

}
}
}

func ensureContainerRecoverNetworks(recoverCtx *containerRecoverContext) error {
if recoverCtx.inspectInfo.NetworkSettings == nil {
return nil
Expand Down
3 changes: 3 additions & 0 deletions frontend/src/components/backup/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ import { useGlobalStore } from '@/composables/useGlobalStore';
import { mysqlArgs } from '@/views/cronjob/cronjob/helper';
const { currentNode } = useGlobalStore();

const emit = defineEmits(['close']);

const PushApp = defineAsyncComponent(async () => {
const modules = import.meta.glob('@/xpack/views/appstore/push-app/index.vue');
const loader = modules['/src/xpack/views/appstore/push-app/index.vue'];
Expand Down Expand Up @@ -258,6 +260,7 @@ const acceptParams = (params: DialogProps): void => {
};
const handleClose = () => {
backupVisible.value = false;
emit('close');
};
const handleBackupClose = () => {
open.value = false;
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/components/drawer-pro/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ const handleBack = () => {
} else {
localOpenPage.value = false;
globalStore.isFullScreen = false;
emit('close');
}
};
emit('beforeClose', done);
Expand All @@ -142,7 +141,6 @@ const handleBack = () => {
} else {
localOpenPage.value = false;
globalStore.isFullScreen = false;
emit('close');
}
}
};
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/views/container/compose/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@

<div v-show="showType === 'log'">
<ContainerLog
v-model:loading="detailLoading"
:key="currentCompose.path"
:compose="currentCompose.path"
:resource="currentCompose.name"
Expand Down Expand Up @@ -440,7 +439,7 @@
<ContainerInspectDialog ref="containerInspectRef" />
<TerminalDialog ref="terminalDialogRef" />
<ContainerLogDialog ref="containerLogDialogRef" :highlightDiff="210" />
<Backups ref="dialogBackupRef" />
<Backups ref="dialogBackupRef" @close="search(true)" />
<Uploads ref="uploadRef" @close="search(true)" />
</div>
</template>
Expand Down Expand Up @@ -733,7 +732,7 @@ const onBackupList = (row: Container.ComposeInfo) => {
type: 'compose',
name: row.name,
detailName: '',
status: 'running',
status: '',
node: globalStore.currentNode,
});
};
Expand Down
Loading