mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-26 04:05:40 +01:00
read capacity from adminserver
This commit is contained in:
parent
e02dd11703
commit
383997f785
@ -50,6 +50,7 @@ services:
|
||||
volumes:
|
||||
- /data/config/:/etc/adminserver/
|
||||
- /data/secretkey:/etc/adminserver/key
|
||||
- /data/:/data/
|
||||
depends_on:
|
||||
- log
|
||||
logging:
|
||||
|
@ -56,6 +56,7 @@ services:
|
||||
volumes:
|
||||
- /data/config/:/etc/adminserver/
|
||||
- /data/secretkey:/etc/adminserver/key
|
||||
- /data/:/data/
|
||||
networks:
|
||||
- harbor
|
||||
depends_on:
|
||||
@ -74,7 +75,6 @@ services:
|
||||
volumes:
|
||||
- ./common/config/ui/app.conf:/etc/ui/app.conf
|
||||
- ./common/config/ui/private_key.pem:/etc/ui/private_key.pem
|
||||
- /data:/harbor_storage
|
||||
- /data/secretkey:/etc/ui/key
|
||||
networks:
|
||||
- harbor
|
||||
|
@ -3,9 +3,7 @@ package api
|
||||
import (
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"syscall"
|
||||
|
||||
"github.com/vmware/harbor/src/common"
|
||||
"github.com/vmware/harbor/src/common/api"
|
||||
@ -21,7 +19,6 @@ type SystemInfoAPI struct {
|
||||
isAdmin bool
|
||||
}
|
||||
|
||||
const harborStoragePath = "/harbor_storage"
|
||||
const defaultRootCert = "/harbor_storage/ca_download/ca.crt"
|
||||
|
||||
//SystemInfo models for system info.
|
||||
@ -66,18 +63,16 @@ func (sia *SystemInfoAPI) GetVolumeInfo() {
|
||||
sia.RenderError(http.StatusForbidden, "User does not have admin role.")
|
||||
return
|
||||
}
|
||||
var stat syscall.Statfs_t
|
||||
err := syscall.Statfs(filepath.Join("/", harborStoragePath), &stat)
|
||||
if err != nil {
|
||||
log.Errorf("Error occurred in syscall.Statfs: %v", err)
|
||||
sia.CustomAbort(http.StatusInternalServerError, "Internal error.")
|
||||
return
|
||||
}
|
||||
|
||||
capacity, err := config.AdminserverClient.Capacity()
|
||||
if err != nil {
|
||||
log.Errorf("failed to get capacity: %v", err)
|
||||
sia.CustomAbort(http.StatusInternalServerError, http.StatusText(http.StatusInternalServerError))
|
||||
}
|
||||
systemInfo := SystemInfo{
|
||||
HarborStorage: Storage{
|
||||
Total: stat.Blocks * uint64(stat.Bsize),
|
||||
Free: stat.Bavail * uint64(stat.Bsize),
|
||||
Total: capacity.Total,
|
||||
Free: capacity.Free,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -31,5 +31,6 @@ services:
|
||||
volumes:
|
||||
- /data/config/:/etc/adminserver/
|
||||
- /data/secretkey:/etc/adminserver/key
|
||||
- /data/:/data/
|
||||
ports:
|
||||
- 8888:80
|
||||
|
Loading…
Reference in New Issue
Block a user