Skip to content

Commit

Permalink
remove the notion of permdir
Browse files Browse the repository at this point in the history
  • Loading branch information
timfeirg authored and CMGS committed Sep 14, 2017
1 parent fbd30ea commit 323cdf4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 22 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ Image: [projecteru2/core](https://hub.docker.com/r/projecteru2/core/)
```shell
docker run -d -e IN_DOCKER=1 \
--name eru-core --net host \
-v <HOST_CONFIG_PATH>:/etc/eru/core.yaml \
--restart always \
-v <HOST_CONFIG_DIR_PATH>:/etc/eru \
-v <HOST_BACKUP_DIR_PATH>:/data/backup \
projecteru2/core \
/usr/bin/eru-core
```
8 changes: 2 additions & 6 deletions cluster/calcium/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,19 @@ func trimLeftSlash(name string) string {
}

// make mount paths
// 使用volumes, 参数格式跟docker一样, 支持 $PERMDIR $APPDIR 的展开
// 使用volumes, 参数格式跟docker一样
// volumes:
// - "$PERMDIR/foo-data:$APPDIR/foodata:rw"
// - "/foo-data:$APPDIR/foodata:rw"
func makeMountPaths(specs types.Specs, config types.Config) ([]string, map[string]struct{}) {
binds := []string{}
volumes := make(map[string]struct{})

var expandENV = func(env string) string {
envMap := make(map[string]string)
if config.PermDir != "" {
envMap["PERMDIR"] = filepath.Join(config.PermDir, specs.Appname)
}
envMap["APPDIR"] = filepath.Join(config.AppDir, specs.Appname)
return envMap[env]
}

// volumes
for _, path := range specs.Volumes {
expanded := os.Expand(path, expandENV)
parts := strings.Split(expanded, ":")
Expand Down
6 changes: 3 additions & 3 deletions cluster/calcium/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import (
)

func TestMakeMountPaths(t *testing.T) {
config := types.Config{PermDir: "/mnt/mfs/permdirs", AppDir: "/home"}
specs := types.Specs{Appname: "foo", Volumes: []string{"$PERMDIR/foo-data:$APPDIR/foo-data"}}
config := types.Config{AppDir: "/home"}
specs := types.Specs{Appname: "foo", Volumes: []string{"/foo-data:$APPDIR/foo-data"}}
binds, volumes := makeMountPaths(specs, config)
assert.Equal(t, binds, []string{"/mnt/mfs/permdirs/foo/foo-data:/home/foo/foo-data:rw", "/proc/sys:/writable-proc/sys:rw", "/sys/kernel/mm/transparent_hugepage:/writable-sys/kernel/mm/transparent_hugepage:rw"}, "binds should be the same")
assert.Equal(t, binds, []string{"/foo-data:/home/foo/foo-data:rw", "/proc/sys:/writable-proc/sys:rw", "/sys/kernel/mm/transparent_hugepage:/writable-sys/kernel/mm/transparent_hugepage:rw"}, "binds should be the same")
assert.Equal(t, volumes, map[string]struct{}{"/home/foo/foo-data": struct{}{}, "/writable-proc/sys": struct{}{}, "/writable-sys/kernel/mm/transparent_hugepage": struct{}{}})
}
18 changes: 8 additions & 10 deletions core.yaml.sample
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
log_level: "DEBUG"
bind: ":5002"
agent_port: "12345"
bind: ":5001"
appdir: "/home"
backupdir: "/data/backup"
permdir: "/mnt/mfs/permdirs"
etcd:
- "http://127.0.0.1:2379"
etcd_lock_prefix: "/eru-core/_lock"
statsd: "statsd2.ricebook.net:8125"
statsd: "127.0.0.1:8125"

zone: "test-zone"
zone: "eru-test"
image_cache: 2
global_timeout: 300
lock_timeout: 30
Expand All @@ -18,15 +16,15 @@ git:
public_key: "***REMOVED***"
private_key: "***REMOVED***"
token: "***REMOVED***"
scm_type: "gitlab"
scm_type: "github"

docker:
log_driver: "json-file"
network_mode: "bridge"
cert_path: ""
hub: "hub.ricebook.net"
hub_prefix: ""
build_pod: ""
cert_path: "/etc/eru/tls"
hub: "hub.docker.com"
hub_prefix: "projecteru2"
build_pod: "eru-test"
local_dns: true

scheduler:
Expand Down
1 change: 0 additions & 1 deletion rpc/rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func initConfig(mStore *mockstore.MockStore) (types.Config, *vibranium) {
config := types.Config{
Bind: ":5001", // HTTP API address
AppDir: "/tmp", // App directory inside container
PermDir: "/tmp", // Permanent dir on host
BackupDir: "/tmp", // Backup dir on host
EtcdMachines: []string{"MOCK"}, // etcd cluster addresses
EtcdLockPrefix: "/eru-core/_lock", // etcd lock prefix, all locks will be created under this dir
Expand Down
1 change: 0 additions & 1 deletion types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ type Config struct {
LogLevel string `yaml:"log_level"`
Bind string `yaml:"bind"` // HTTP API address
AppDir string `yaml:"appdir"` // App directory inside container
PermDir string `yaml:"permdir"` // Permanent dir on host
BackupDir string `yaml:"backupdir"` // Backup dir on host
EtcdMachines []string `yaml:"etcd"` // etcd cluster addresses
EtcdLockPrefix string `yaml:"etcd_lock_prefix"` // etcd lock prefix, all locks will be created under this dir
Expand Down

0 comments on commit 323cdf4

Please sign in to comment.