Skip to content

Commit f75ca09

Browse files
committed
Merge branch 'refactor/volume' into 'master'
[skip ci] [WIP] remove the notion of permdir See merge request !151
2 parents 1db5728 + 9f9c2bf commit f75ca09

File tree

5 files changed

+5
-12
lines changed

5 files changed

+5
-12
lines changed

cluster/calcium/helper.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -148,23 +148,19 @@ func trimLeftSlash(name string) string {
148148
}
149149

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

158158
var expandENV = func(env string) string {
159159
envMap := make(map[string]string)
160-
if config.PermDir != "" {
161-
envMap["PERMDIR"] = filepath.Join(config.PermDir, specs.Appname)
162-
}
163160
envMap["APPDIR"] = filepath.Join(config.AppDir, specs.Appname)
164161
return envMap[env]
165162
}
166163

167-
// volumes
168164
for _, path := range specs.Volumes {
169165
expanded := os.Expand(path, expandENV)
170166
parts := strings.Split(expanded, ":")

cluster/calcium/helper_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import (
88
)
99

1010
func TestMakeMountPaths(t *testing.T) {
11-
config := types.Config{PermDir: "/mnt/mfs/permdirs", AppDir: "/home"}
12-
specs := types.Specs{Appname: "foo", Volumes: []string{"$PERMDIR/foo-data:$APPDIR/foo-data"}}
11+
config := types.Config{AppDir: "/home"}
12+
specs := types.Specs{Appname: "foo", Volumes: []string{"/foo-data:$APPDIR/foo-data"}}
1313
binds, volumes := makeMountPaths(specs, config)
14-
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")
14+
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")
1515
assert.Equal(t, volumes, map[string]struct{}{"/home/foo/foo-data": struct{}{}, "/writable-proc/sys": struct{}{}, "/writable-sys/kernel/mm/transparent_hugepage": struct{}{}})
1616
}

core.yaml.sample

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ bind: ":5002"
33
agent_port: "12345"
44
appdir: "/home"
55
backupdir: "/data/backup"
6-
permdir: "/mnt/mfs/permdirs"
76
etcd:
87
- "http://127.0.0.1:2379"
98
etcd_lock_prefix: "/eru-core/_lock"

rpc/rpc_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ func initConfig(mStore *mockstore.MockStore) (types.Config, *vibranium) {
189189
config := types.Config{
190190
Bind: ":5001", // HTTP API address
191191
AppDir: "/tmp", // App directory inside container
192-
PermDir: "/tmp", // Permanent dir on host
193192
BackupDir: "/tmp", // Backup dir on host
194193
EtcdMachines: []string{"MOCK"}, // etcd cluster addresses
195194
EtcdLockPrefix: "/eru-core/_lock", // etcd lock prefix, all locks will be created under this dir

types/config.go

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ type Config struct {
77
LogLevel string `yaml:"log_level"`
88
Bind string `yaml:"bind"` // HTTP API address
99
AppDir string `yaml:"appdir"` // App directory inside container
10-
PermDir string `yaml:"permdir"` // Permanent dir on host
1110
BackupDir string `yaml:"backupdir"` // Backup dir on host
1211
EtcdMachines []string `yaml:"etcd"` // etcd cluster addresses
1312
EtcdLockPrefix string `yaml:"etcd_lock_prefix"` // etcd lock prefix, all locks will be created under this dir

0 commit comments

Comments
 (0)