mirror of
https://github.com/goharbor/harbor.git
synced 2024-12-23 00:57:44 +01:00
Merge pull request #1700 from ywk253100/170321_mount_data
Read capacity from adminserver
This commit is contained in:
commit
a05f1e3507
@ -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,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ import (
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/beego/i18n"
|
||||
"github.com/vmware/harbor/src/common/config"
|
||||
"github.com/vmware/harbor/src/common"
|
||||
"github.com/vmware/harbor/src/common/dao"
|
||||
"github.com/vmware/harbor/src/common/models"
|
||||
"github.com/vmware/harbor/src/common/utils"
|
||||
@ -113,7 +113,7 @@ func (cc *CommonController) SendEmail() {
|
||||
|
||||
message := new(bytes.Buffer)
|
||||
|
||||
harborURL := config.ExtEndpoint
|
||||
harborURL := common.ExtEndpoint
|
||||
if harborURL == "" {
|
||||
harborURL = "localhost"
|
||||
}
|
||||
|
@ -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