mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-10 03:30:53 +08:00
fix: 解决容器编辑时端口冲突的问题 (#1615)
This commit is contained in:
parent
66007c07e2
commit
1a891cb048
5 changed files with 20 additions and 5 deletions
|
|
@ -7,6 +7,7 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -421,15 +422,17 @@ func (u *ContainerService) ContainerUpdate(req dto.ContainerOperate) error {
|
||||||
global.LOG.Errorf("force pull image %s failed, err: %v", req.Image, err)
|
global.LOG.Errorf("force pull image %s failed, err: %v", req.Image, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if err := client.ContainerRemove(ctx, req.ContainerID, types.ContainerRemoveOptions{Force: true}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
config := oldContainer.Config
|
config := oldContainer.Config
|
||||||
hostConf := oldContainer.HostConfig
|
hostConf := oldContainer.HostConfig
|
||||||
var networkConf network.NetworkingConfig
|
var networkConf network.NetworkingConfig
|
||||||
if err := loadConfigInfo(req, config, hostConf, &networkConf); err != nil {
|
if err := loadConfigInfo(req, config, hostConf, &networkConf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := client.ContainerRemove(ctx, req.ContainerID, types.ContainerRemoveOptions{Force: true}); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
global.LOG.Infof("new container info %s has been update, now start to recreate", req.Name)
|
global.LOG.Infof("new container info %s has been update, now start to recreate", req.Name)
|
||||||
container, err := client.ContainerCreate(ctx, config, hostConf, &networkConf, &v1.Platform{}, req.Name)
|
container, err := client.ContainerCreate(ctx, config, hostConf, &networkConf, &v1.Platform{}, req.Name)
|
||||||
|
|
@ -540,6 +543,11 @@ func (u *ContainerService) ContainerLogClean(req dto.OperationWithName) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, _ = file.Seek(0, 0)
|
_, _ = file.Seek(0, 0)
|
||||||
|
|
||||||
|
files, _ := filepath.Glob(fmt.Sprintf("%s.*", container.LogPath))
|
||||||
|
for _, file := range files {
|
||||||
|
_ = os.Remove(file)
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -148,10 +148,16 @@ func loadNetIO() {
|
||||||
if net2.BytesSent != 0 && net1.BytesSent != 0 {
|
if net2.BytesSent != 0 && net1.BytesSent != 0 {
|
||||||
itemNet.Up = float64(net2.BytesSent-net1.BytesSent) / 1024 / 60
|
itemNet.Up = float64(net2.BytesSent-net1.BytesSent) / 1024 / 60
|
||||||
}
|
}
|
||||||
|
if itemNet.Up > 100000000 {
|
||||||
|
global.LOG.Errorf("net2: %v, net1: %v, BytesSent: %v \n", net2.BytesSent, net1.BytesSent, float64(net2.BytesSent-net1.BytesSent)/1024/60)
|
||||||
|
}
|
||||||
|
|
||||||
if net2.BytesRecv != 0 && net1.BytesRecv != 0 {
|
if net2.BytesRecv != 0 && net1.BytesRecv != 0 {
|
||||||
itemNet.Down = float64(net2.BytesRecv-net1.BytesRecv) / 1024 / 60
|
itemNet.Down = float64(net2.BytesRecv-net1.BytesRecv) / 1024 / 60
|
||||||
}
|
}
|
||||||
|
if itemNet.Down > 100000000 {
|
||||||
|
global.LOG.Errorf("net2: %v, net1: %v, BytesRecv: %v \n", net2.BytesRecv, net1.BytesRecv, float64(net2.BytesRecv-net1.BytesRecv)/1024/60)
|
||||||
|
}
|
||||||
netList = append(netList, itemNet)
|
netList = append(netList, itemNet)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ const timeOptions = ref([
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const searchLogs = async () => {
|
const searchLogs = async () => {
|
||||||
if (!Number(logSearch.tail) || Number(logSearch.tail) <= 0) {
|
if (!Number(logSearch.tail) || Number(logSearch.tail) < 0) {
|
||||||
MsgError(i18n.global.t('container.linesHelper'));
|
MsgError(i18n.global.t('container.linesHelper'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ const acceptParams = async (params: DialogProps): Promise<void> => {
|
||||||
}
|
}
|
||||||
if (!checkIp(res.data.systemIP)) {
|
if (!checkIp(res.data.systemIP)) {
|
||||||
window.open(`http://${res.data.systemIP}:${params.port}`, '_blank');
|
window.open(`http://${res.data.systemIP}:${params.port}`, '_blank');
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
window.open(`http://[${res.data.systemIP}]:${params.port}`, '_blank');
|
window.open(`http://[${res.data.systemIP}]:${params.port}`, '_blank');
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ watch(logVisiable, (val) => {
|
||||||
if (screenfull.isEnabled && !val && !mobile.value) screenfull.exit();
|
if (screenfull.isEnabled && !val && !mobile.value) screenfull.exit();
|
||||||
});
|
});
|
||||||
const searchLogs = async () => {
|
const searchLogs = async () => {
|
||||||
if (!Number(logSearch.tail) || Number(logSearch.tail) <= 0) {
|
if (!Number(logSearch.tail) || Number(logSearch.tail) < 0) {
|
||||||
MsgError(i18n.global.t('container.linesHelper'));
|
MsgError(i18n.global.t('container.linesHelper'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue