Skip to content

Commit

Permalink
fix: 解决容器存储卷创建时间加载错误的问题 (#3169)
Browse files Browse the repository at this point in the history
Refs #3147
  • Loading branch information
ssongliu authored Dec 4, 2023
1 parent a09fd97 commit 86d5a68
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions backend/app/service/container_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/1Panel-dev/1Panel/backend/app/dto"
"github.com/1Panel-dev/1Panel/backend/buserr"
"github.com/1Panel-dev/1Panel/backend/constant"
"github.com/1Panel-dev/1Panel/backend/utils/common"
"github.com/1Panel-dev/1Panel/backend/utils/docker"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
Expand Down Expand Up @@ -51,15 +52,20 @@ func (u *ContainerService) PageVolume(req dto.SearchWithPage) (int64, interface{
records = list.Volumes[start:end]
}

nyc, _ := time.LoadLocation(common.LoadTimeZone())
for _, item := range records {
tag := make([]string, 0)
for _, val := range item.Labels {
tag = append(tag, val)
}
if len(item.CreatedAt) > 19 {
item.CreatedAt = item.CreatedAt[0:19]
var createTime time.Time
if strings.Contains(item.CreatedAt, "Z") {
createTime, _ = time.ParseInLocation("2006-01-02T15:04:05Z", item.CreatedAt, nyc)
} else if strings.Contains(item.CreatedAt, "+") {
createTime, _ = time.ParseInLocation("2006-01-02T15:04:05+08:00", item.CreatedAt, nyc)
} else {
createTime, _ = time.ParseInLocation("2006-01-02T15:04:05", item.CreatedAt, nyc)
}
createTime, _ := time.Parse("2006-01-02T15:04:05", item.CreatedAt)
data = append(data, dto.Volume{
CreatedAt: createTime,
Name: item.Name,
Expand Down
2 changes: 1 addition & 1 deletion backend/app/service/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ func (f *FileService) ReadLogByLine(req request.FileReadByLineReq) (*response.Fi
logFilePath = ssl.GetLogPath()
case constant.TypeSystem:
fileName := ""
if req.Name == time.Now().Format("2006-01-02") {
if len(req.Name) == 0 || req.Name == time.Now().Format("2006-01-02") {
fileName = "1Panel.log"
} else {
fileName = "1Panel-" + req.Name + ".log"
Expand Down
2 changes: 1 addition & 1 deletion backend/app/service/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func (u *ImageService) ImageRemove(req dto.BatchDelete) error {
}
for _, id := range req.Names {
if _, err := client.ImageRemove(context.TODO(), id, types.ImageRemoveOptions{Force: req.Force, PruneChildren: true}); err != nil {
if strings.Contains(err.Error(), "image is being used") {
if strings.Contains(err.Error(), "image is being used") || strings.Contains(err.Error(), "is using") {
if strings.Contains(id, "sha256:") {
return buserr.New(constant.ErrObjectInUsed)
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/views/container/container/log/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const globalStore = GlobalStore();
const terminalSocket = ref<WebSocket>();
const logSearch = reactive({
isWatch: false,
isWatch: true,
container: '',
containerID: '',
mode: 'all',
Expand Down Expand Up @@ -197,7 +197,7 @@ const acceptParams = (props: DialogProps): void => {
logSearch.containerID = props.containerID;
logSearch.tail = 100;
logSearch.mode = 'all';
logSearch.isWatch = false;
logSearch.isWatch = true;
logSearch.container = props.container;
searchLogs();
Expand Down

0 comments on commit 86d5a68

Please sign in to comment.