-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[patch] add storage backup option to agent
Signed-off-by: kpango <i.can.feel.gravity@gmail.com>
- Loading branch information
kpango
committed
May 11, 2020
1 parent
54fba1f
commit 41c2ba9
Showing
11 changed files
with
514 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# | ||
# Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
{{- if .Values.agent.volumeStore.enabled }} | ||
apiVersion: v1 | ||
kind: PersistentVolumeClaim | ||
metadata: | ||
name: {{ .Values.agent.name }}-pvc | ||
spec: | ||
accessModes: | ||
- {{ .Values.agent.volumeStore.accessMode }} | ||
storageClassName: {{ .Values.agent.volumeStore.storageClass }} | ||
spec: | ||
resources: | ||
requests: | ||
storage: {{ .Values.agent.volumeStore.size }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// | ||
// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
// Package file provides file I/O functionality | ||
package file | ||
|
||
import ( | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
func Open(path string, flg int, perm os.FileMode) *os.File { | ||
if path == "" { | ||
return nil | ||
} | ||
|
||
var err error | ||
var file *os.File | ||
if _, err = os.Stat(path); err != nil { | ||
if _, err = os.Stat(filepath.Dir(path)); err != nil { | ||
err = os.MkdirAll(filepath.Dir(path), perm) | ||
if err != nil { | ||
return nil | ||
} | ||
} | ||
file, err = os.Create(path) | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
err = file.Close() | ||
if err != nil { | ||
return nil | ||
} | ||
} | ||
|
||
file, err = os.OpenFile(path, flg, perm) | ||
|
||
if err != nil { | ||
return nil | ||
} | ||
|
||
return file | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
// | ||
// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt ) | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
|
||
// Package file provides file I/O functionality | ||
package file | ||
|
||
import ( | ||
"os" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/vdaas/vald/internal/errors" | ||
"go.uber.org/goleak" | ||
) | ||
|
||
func TestOpen(t *testing.T) { | ||
type args struct { | ||
path string | ||
flg int | ||
perm os.FileMode | ||
} | ||
type want struct { | ||
want *os.File | ||
} | ||
type test struct { | ||
name string | ||
args args | ||
want want | ||
checkFunc func(want, *os.File) error | ||
beforeFunc func(args) | ||
afterFunc func(args) | ||
} | ||
defaultCheckFunc := func(w want, got *os.File) error { | ||
if !reflect.DeepEqual(got, w.want) { | ||
return errors.Errorf("got = %v, want %v", got, w.want) | ||
} | ||
return nil | ||
} | ||
tests := []test{ | ||
// TODO test cases | ||
/* | ||
{ | ||
name: "test_case_1", | ||
args: args { | ||
path: "", | ||
flg: 0, | ||
perm: nil, | ||
}, | ||
want: want{}, | ||
checkFunc: defaultCheckFunc, | ||
}, | ||
*/ | ||
|
||
// TODO test cases | ||
/* | ||
func() test { | ||
return test { | ||
name: "test_case_2", | ||
args: args { | ||
path: "", | ||
flg: 0, | ||
perm: nil, | ||
}, | ||
want: want{}, | ||
checkFunc: defaultCheckFunc, | ||
} | ||
}(), | ||
*/ | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(tt *testing.T) { | ||
defer goleak.VerifyNone(t) | ||
if test.beforeFunc != nil { | ||
test.beforeFunc(test.args) | ||
} | ||
if test.afterFunc != nil { | ||
defer test.afterFunc(test.args) | ||
} | ||
if test.checkFunc == nil { | ||
test.checkFunc = defaultCheckFunc | ||
} | ||
|
||
got := Open(test.args.path, test.args.flg, test.args.perm) | ||
if err := test.checkFunc(test.want, got); err != nil { | ||
tt.Errorf("error = %v", err) | ||
} | ||
|
||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.