Merge pull request #1700 from ywk253100/170321_mount_data

Read capacity from adminserver
This commit is contained in:
Daniel Jiang 2017-03-21 16:42:32 +08:00 committed by GitHub
commit a05f1e3507
5 changed files with 12 additions and 15 deletions

View File

@ -50,6 +50,7 @@ services:
volumes:
- /data/config/:/etc/adminserver/
- /data/secretkey:/etc/adminserver/key
- /data/:/data/
depends_on:
- log
logging:

View File

@ -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

View File

@ -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,
},
}

View File

@ -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"
}

View File

@ -31,5 +31,6 @@ services:
volumes:
- /data/config/:/etc/adminserver/
- /data/secretkey:/etc/adminserver/key
- /data/:/data/
ports:
- 8888:80