From 323cdf4ea81bf33d549e8713ec39d97f87ce0ff9 Mon Sep 17 00:00:00 2001 From: timfeirg Date: Tue, 5 Sep 2017 16:18:28 +0800 Subject: [PATCH] remove the notion of permdir --- README.md | 4 +++- cluster/calcium/helper.go | 8 ++------ cluster/calcium/helper_test.go | 6 +++--- core.yaml.sample | 18 ++++++++---------- rpc/rpc_test.go | 1 - types/config.go | 1 - 6 files changed, 16 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 48acafa4b..feb284e36 100644 --- a/README.md +++ b/README.md @@ -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 :/etc/eru/core.yaml \ + --restart always \ + -v :/etc/eru \ + -v :/data/backup \ projecteru2/core \ /usr/bin/eru-core ``` diff --git a/cluster/calcium/helper.go b/cluster/calcium/helper.go index 7b95bbc10..a40ffc4d0 100644 --- a/cluster/calcium/helper.go +++ b/cluster/calcium/helper.go @@ -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, ":") diff --git a/cluster/calcium/helper_test.go b/cluster/calcium/helper_test.go index f21b64141..fe62771e0 100644 --- a/cluster/calcium/helper_test.go +++ b/cluster/calcium/helper_test.go @@ -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{}{}}) } diff --git a/core.yaml.sample b/core.yaml.sample index 664dec12c..4cfbdb319 100644 --- a/core.yaml.sample +++ b/core.yaml.sample @@ -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 @@ -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: diff --git a/rpc/rpc_test.go b/rpc/rpc_test.go index d45797317..6b99a77fe 100644 --- a/rpc/rpc_test.go +++ b/rpc/rpc_test.go @@ -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 diff --git a/types/config.go b/types/config.go index 00180be57..e726107b1 100644 --- a/types/config.go +++ b/types/config.go @@ -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