From 5d3fd4f4b881ee8084151207519040924acffb9c Mon Sep 17 00:00:00 2001 From: kpango Date: Sun, 10 May 2020 19:53:01 +0900 Subject: [PATCH 1/4] [patch] add storage backup option to agent Signed-off-by: kpango --- Makefile.d/functions.mk | 1 + charts/vald/templates/agent/statefulset.yaml | 14 + charts/vald/values.yaml | 9 + go.mod | 15 +- go.sum | 26 +- hack/go.mod.default | 1 + internal/core/ngt/ngt.go | 14 +- internal/file/file.go | 57 ++++ internal/file/file_test.go | 104 ++++++ pkg/agent/ngt/handler/grpc/handler.go | 4 +- pkg/agent/ngt/service/ngt.go | 83 ++++- pkg/agent/ngt/service/ngt_test.go | 336 +++++++++++++------ pkg/agent/ngt/usecase/agentd.go | 1 + 13 files changed, 520 insertions(+), 145 deletions(-) create mode 100644 internal/file/file.go create mode 100644 internal/file/file_test.go diff --git a/Makefile.d/functions.mk b/Makefile.d/functions.mk index 05141e7add..dcf6dae17e 100644 --- a/Makefile.d/functions.mk +++ b/Makefile.d/functions.mk @@ -114,6 +114,7 @@ define gen-test gotests -w -template_dir $${path} -all $${file}; \ done; \ done + rm $(ROOTDIR)/internal/core/ngt/*test.go endef define fix-test diff --git a/charts/vald/templates/agent/statefulset.yaml b/charts/vald/templates/agent/statefulset.yaml index 7a7892484a..2bac1ccd9c 100644 --- a/charts/vald/templates/agent/statefulset.yaml +++ b/charts/vald/templates/agent/statefulset.yaml @@ -107,5 +107,19 @@ spec: priorityClassName: {{ .Values.agent.name }}-priority {{- end }} {{- end }} +{{- if .Values.agent.volumeStore }} +{{- if .Values.agent.volumeStore.enabled }} + volumeClaimTemplates: + - metadata: + name: {{ .Values.agent.name }}-pvc + spec: + accessModes: + - {{ .Values.agent.volumeStore.accessMode }} + storageClassName: {{ .Values.agent.volumeStore.storageClass }} + resources: + requests: + storage: {{ .Values.agent.volumeStore.size }} +{{- end }} +{{- end }} status: {{- end }} diff --git a/charts/vald/values.yaml b/charts/vald/values.yaml index 9568fea6a3..a33ee1be40 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -616,6 +616,15 @@ agent: terminationGracePeriodSeconds: 30 # agent.podManagementPolicy -- pod management policy: OrderedReady or Parallel podManagementPolicy: OrderedReady + volumeStore: + # agent.volumeStore.enabled -- enables agent pod's file store functionality when non in-memory mode + enabled: false + # agent.volumeStore.accessMode -- agent pod storage accessMode + accessMode: ReadWriteOnce + # agent.volumeStore.storageClass -- storageClass name for agent pod volume + storageClass: vald-sc + # agent.volumeStore.size -- size of agent pod volume + size: 100Gi podPriority: # agent.podPriority.enabled -- agent pod PriorityClass enabled enabled: true diff --git a/go.mod b/go.mod index 70668c825d..2f7c67b2f7 100755 --- a/go.mod +++ b/go.mod @@ -5,12 +5,13 @@ go 1.14 replace ( github.com/boltdb/bolt => github.com/boltdb/bolt v1.3.1 github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v0.3.0-java - github.com/go-sql-driver/mysql => github.com/go-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae - github.com/gocql/gocql => github.com/gocql/gocql v0.0.0-20200410100145-b454769479c6 + github.com/go-sql-driver/mysql => github.com/go-sql-driver/mysql v1.5.1-0.20200509130255-343c8030d2cb + github.com/gocql/gocql => github.com/gocql/gocql v0.0.0-20200505093417-effcbd8bcf0e github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.1 github.com/gophercloud/gophercloud => github.com/gophercloud/gophercloud v0.10.0 github.com/gorilla/mux => github.com/gorilla/mux v1.7.4 - golang.org/x/crypto => golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 + github.com/tensorflow/tensorflow => github.com/tensorflow/tensorflow v2.1.0+incompatible + golang.org/x/crypto => golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 k8s.io/api => k8s.io/api v0.18.2 k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.2 k8s.io/apimachinery => k8s.io/apimachinery v0.18.2 @@ -46,18 +47,18 @@ require ( github.com/lucasb-eyer/go-colorful v1.0.3 github.com/pierrec/lz4/v3 v3.3.2 github.com/scylladb/gocqlx v1.5.0 - github.com/tensorflow/tensorflow v2.1.0+incompatible + github.com/tensorflow/tensorflow v0.0.0-00010101000000-000000000000 github.com/yahoojapan/gongt v0.0.0-20190517050727-966dcc7aa5e8 github.com/yahoojapan/ngtd v0.0.0-20200424071638-9872bbae3700 go.opencensus.io v0.22.3 go.uber.org/automaxprocs v1.3.0 go.uber.org/goleak v1.0.0 golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 - golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d // indirect - gonum.org/v1/hdf5 v0.0.0-20191105085658-fe04b73f3b53 + golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5 // indirect + gonum.org/v1/hdf5 v0.0.0-20200504100616-496fefe91614 gonum.org/v1/netlib v0.0.0-20200317120129-c5a04cffd98a // indirect gonum.org/v1/plot v0.7.0 - google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84 + google.golang.org/genproto v0.0.0-20200507105951-43844f6eee31 google.golang.org/grpc v1.29.1 gopkg.in/yaml.v2 v2.2.8 k8s.io/api v0.18.2 diff --git a/go.sum b/go.sum index f81173c4ca..816797b767 100644 --- a/go.sum +++ b/go.sum @@ -187,11 +187,11 @@ github.com/go-redis/redis v6.15.2+incompatible h1:9SpNVG76gr6InJGxoZ6IuuxaCOQwDA github.com/go-redis/redis v6.15.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= github.com/go-redis/redis/v7 v7.2.0 h1:CrCexy/jYWZjW0AyVoHlcJUeZN19VWlbepTh1Vq6dJs= github.com/go-redis/redis/v7 v7.2.0/go.mod h1:JDNMw23GTyLNC4GZu9njt15ctBQVn7xjRfnwdHj/Dcg= -github.com/go-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae h1:L6V0ANsMIMdLgXly241UXhXNFWYgXbgjHupTAAURrV0= -github.com/go-sql-driver/mysql v1.5.1-0.20200311113236-681ffa848bae/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= +github.com/go-sql-driver/mysql v1.5.1-0.20200509130255-343c8030d2cb h1:CgPA5m8ozn8gM7yL2Ohz/HLfRCtJ6mbOpA5KC+nZ4vQ= +github.com/go-sql-driver/mysql v1.5.1-0.20200509130255-343c8030d2cb/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gocql/gocql v0.0.0-20200410100145-b454769479c6 h1:esX8kOWgz5dyrcn/QQQgMmPqPWzX/hNO65/nmfcEOYw= -github.com/gocql/gocql v0.0.0-20200410100145-b454769479c6/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY= +github.com/gocql/gocql v0.0.0-20200505093417-effcbd8bcf0e h1:k4NKEJg2i2J7l6y44DHiq+U2ua0vvLUKbpktGA4UhQM= +github.com/gocql/gocql v0.0.0-20200505093417-effcbd8bcf0e/go.mod h1:DL0ekTmBSTdlNF25Orwt/JMzqIq3EJ4MVa/J/uK64OY= github.com/gocraft/dbr/v2 v2.7.0 h1:x+UnhSBYPFBBdtikLSMLQ9KPuquSUj4yBijsQAhhNZo= github.com/gocraft/dbr/v2 v2.7.0/go.mod h1:wQdbxPBSloo2OlSedMxfNW0mgk0GXys9O1VFmQiwcx4= github.com/gofrs/flock v0.7.1 h1:DP+LD/t0njgoPBvT5MJLeliUIVQR03hiKR6vezdwHlc= @@ -485,8 +485,8 @@ go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9E go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= go.uber.org/zap v1.14.0 h1:/pduUoebOeeJzTDFuoMgC6nRkiasr1sBCIEorly7m4o= go.uber.org/zap v1.14.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= -golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79 h1:IaQbIIB2X/Mp/DKctl6ROxz1KyMlKp4uyvL6+kQ7C88= -golang.org/x/crypto v0.0.0-20200429183012-4b2356b1ed79/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 h1:cg5LA/zNPRzIXIWSCxQW10Rvpy94aQh3LT/ShoCpkHw= +golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -596,10 +596,8 @@ golang.org/x/tools v0.0.0-20191108193012-7d206e10da11/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200501005904-d351ea090f9b h1:2hSR2MyOaYEy6yJYg/CpErymr/m7xJEJpm9kfT7ZMg4= -golang.org/x/tools v0.0.0-20200501005904-d351ea090f9b/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d h1:lzLdP95xJmMpwQ6LUHwrc5V7js93hTiY7gkznu0BgmY= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5 h1:MeC2gMlMdkd67dn17MEby3rGXRxZtWeiRXOnISfTQ74= +golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= @@ -611,8 +609,8 @@ gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJ gonum.org/v1/gonum v0.7.0 h1:Hdks0L0hgznZLG9nzXb8vZ0rRvqNvAcgAp84y7Mwkgw= gonum.org/v1/gonum v0.7.0/go.mod h1:L02bwd0sqlsvRv41G7wGWFCsVNZFv/k1xzGIxeANHGM= gonum.org/v1/hdf5 v0.0.0-20190227001252-83207889d689/go.mod h1:g+PDU5ogjIKcc3Cg4ALAK7X4c8bBQvPzPKWNW5NB7I0= -gonum.org/v1/hdf5 v0.0.0-20191105085658-fe04b73f3b53 h1:y/s3CWVbrGN3fN1yT9VD5+5iox1bYrXh3sXnXQk+N5k= -gonum.org/v1/hdf5 v0.0.0-20191105085658-fe04b73f3b53/go.mod h1:g+PDU5ogjIKcc3Cg4ALAK7X4c8bBQvPzPKWNW5NB7I0= +gonum.org/v1/hdf5 v0.0.0-20200504100616-496fefe91614 h1:6opGC6JlNr8Efmo4HPh6P7JFrNL/8VH2/prV5esilyk= +gonum.org/v1/hdf5 v0.0.0-20200504100616-496fefe91614/go.mod h1:BQUWDHIAygjdt1HnUPQ0eWqLN2n5FwJycrpYUVUOx2I= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/netlib v0.0.0-20200317120129-c5a04cffd98a h1:y158/g9tKwBGw9gnNENlUIi9NTJCoiQg2RFB1gr9atQ= gonum.org/v1/netlib v0.0.0-20200317120129-c5a04cffd98a/go.mod h1:6EVtvAMWMjOBOsTVX0xrjO4A6ULtEgWtAWHzqxDWdJs= @@ -630,8 +628,8 @@ google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRn google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84 h1:pSLkPbrjnPyLDYUO2VM9mDLqo2V6CFBY84lFSZAfoi4= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200507105951-43844f6eee31 h1:Bz1qTn2YRWV+9OKJtxHJiQKCiXIdf+kwuKXdt9cBxyU= +google.golang.org/genproto v0.0.0-20200507105951-43844f6eee31/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/hack/go.mod.default b/hack/go.mod.default index 5f13816eaf..19338ed407 100755 --- a/hack/go.mod.default +++ b/hack/go.mod.default @@ -9,6 +9,7 @@ replace ( github.com/gocql/gocql => github.com/gocql/gocql master github.com/gogo/protobuf => github.com/gogo/protobuf master github.com/gophercloud/gophercloud => github.com/gophercloud/gophercloud v0.10.0 + github.com/tensorflow/tensorflow => github.com/tensorflow/tensorflow v2.1.0 github.com/gorilla/mux => github.com/gorilla/mux master golang.org/x/crypto => golang.org/x/crypto master k8s.io/api => k8s.io/api v0.18.2 diff --git a/internal/core/ngt/ngt.go b/internal/core/ngt/ngt.go index bca274079d..1666e24912 100644 --- a/internal/core/ngt/ngt.go +++ b/internal/core/ngt/ngt.go @@ -435,14 +435,16 @@ func (n *ngt) CreateIndex(poolSize uint32) error { // SaveIndex stores NGT index to storage. func (n *ngt) SaveIndex() error { - n.mu.RLock() - ret := C.ngt_save_index(n.index, C.CString(n.idxPath), n.ebuf) - if ret == ErrorCode { - ne := n.ebuf + if !n.inMemory { + n.mu.Lock() + ret := C.ngt_save_index(n.index, C.CString(n.idxPath), n.ebuf) + if ret == ErrorCode { + ne := n.ebuf + n.mu.Unlock() + return n.newGoError(ne) + } n.mu.Unlock() - return n.newGoError(ne) } - n.mu.RUnlock() return nil } diff --git a/internal/file/file.go b/internal/file/file.go new file mode 100644 index 0000000000..050cf3a518 --- /dev/null +++ b/internal/file/file.go @@ -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 +} diff --git a/internal/file/file_test.go b/internal/file/file_test.go new file mode 100644 index 0000000000..8530146acc --- /dev/null +++ b/internal/file/file_test.go @@ -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) + } + + }) + } +} diff --git a/pkg/agent/ngt/handler/grpc/handler.go b/pkg/agent/ngt/handler/grpc/handler.go index 49294274fb..e8d5786030 100644 --- a/pkg/agent/ngt/handler/grpc/handler.go +++ b/pkg/agent/ngt/handler/grpc/handler.go @@ -375,7 +375,7 @@ func (s *server) SaveIndex(ctx context.Context, _ *payload.Empty) (res *payload. } }() res = new(payload.Empty) - err = s.ngt.SaveIndex() + err = s.ngt.SaveIndex(ctx) if err != nil { log.Errorf("[SaveIndex]\tUnknown error\t%+v", err) if span != nil { @@ -394,7 +394,7 @@ func (s *server) CreateAndSaveIndex(ctx context.Context, c *payload.Control_Crea } }() res = new(payload.Empty) - err = s.ngt.CreateAndSaveIndex(c.GetPoolSize()) + err = s.ngt.CreateAndSaveIndex(ctx, c.GetPoolSize()) if err != nil { log.Errorf("[CreateAndSaveIndex]\tUnknown error\t%+v", err) if span != nil { diff --git a/pkg/agent/ngt/service/ngt.go b/pkg/agent/ngt/service/ngt.go index 896e957730..2fc784a6dd 100644 --- a/pkg/agent/ngt/service/ngt.go +++ b/pkg/agent/ngt/service/ngt.go @@ -19,8 +19,10 @@ package service import ( "context" + "encoding/gob" "os" "runtime" + "strings" "sync" "sync/atomic" "time" @@ -29,6 +31,7 @@ import ( core "github.com/vdaas/vald/internal/core/ngt" "github.com/vdaas/vald/internal/errgroup" "github.com/vdaas/vald/internal/errors" + "github.com/vdaas/vald/internal/file" "github.com/vdaas/vald/internal/log" "github.com/vdaas/vald/internal/safety" "github.com/vdaas/vald/internal/timeutil" @@ -48,9 +51,9 @@ type NGT interface { DeleteMultiple(uuids ...string) (err error) GetObject(uuid string) (vec []float32, err error) CreateIndex(poolSize uint32) (err error) - SaveIndex() (err error) + SaveIndex(ctx context.Context) (err error) Exists(string) (uint32, bool) - CreateAndSaveIndex(poolSize uint32) (err error) + CreateAndSaveIndex(ctx context.Context, poolSize uint32) (err error) IsIndexing() bool Len() uint64 NumberOfCreateIndexExecution() uint64 @@ -58,7 +61,7 @@ type NGT interface { UncommittedUUIDs() (uuids []string) DeleteVCacheLen() uint64 InsertVCacheLen() uint64 - Close() + Close(ctx context.Context) error } type ngt struct { @@ -72,6 +75,7 @@ type ngt struct { eg errgroup.Group ivc *vcaches // insertion vector cache dvc *vcaches // deletion vector cache + path string kvs kvs.BidiMap core core.NGT dcd bool // disable commit daemon @@ -82,8 +86,13 @@ type vcache struct { date int64 } +const ( + kvsFileName = "ngt-meta.kvsdb" +) + func New(cfg *config.NGT) (nn NGT, err error) { n := new(ngt) + cfg.IndexPath = strings.TrimSuffix(cfg.IndexPath, "/") opts := []core.Option{ core.WithInMemoryMode(cfg.EnableInMemoryMode), core.WithIndexPath(cfg.IndexPath), @@ -95,12 +104,37 @@ func New(cfg *config.NGT) (nn NGT, err error) { core.WithSearchEdgeSize(cfg.SearchEdgeSize), } + if !cfg.EnableInMemoryMode && len(cfg.IndexPath) != 0 { + n.path = cfg.IndexPath + } + n.kvs = kvs.New() if _, err = os.Stat(cfg.IndexPath); os.IsNotExist(err) { n.core, err = core.New(opts...) } else { - n.core, err = core.Load(opts...) + eg, _ := errgroup.New(context.Background()) + eg.Go(safety.RecoverFunc(func() (err error) { + n.core, err = core.Load(opts...) + return err + })) + eg.Go(safety.RecoverFunc(func() (err error) { + if len(n.path) != 0 { + m := make(map[string]uint32) + gob.Register(map[string]uint32{}) + f := file.Open(n.path+"/"+kvsFileName, os.O_RDONLY|os.O_SYNC, os.ModePerm) + defer f.Close() + err = gob.NewDecoder(f).Decode(&m) + if err != nil { + return err + } + for k, id := range m { + n.kvs.Set(k, id) + } + } + return nil + })) + err = eg.Wait() } if err != nil { return nil, err @@ -462,20 +496,37 @@ func (n *ngt) CreateIndex(poolSize uint32) (err error) { return err } -func (n *ngt) SaveIndex() (err error) { - return n.core.SaveIndex() +func (n *ngt) SaveIndex(ctx context.Context) (err error) { + eg, ctx := errgroup.New(ctx) + eg.Go(safety.RecoverFunc(func() error { + if len(n.path) != 0 { + m := make(map[string]uint32, n.kvs.Len()) + var mu sync.Mutex + n.kvs.Range(ctx, func(key string, id uint32) bool { + mu.Lock() + m[key] = id + mu.Unlock() + return true + }) + f := file.Open(n.path+"/"+kvsFileName, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, os.ModePerm) + defer f.Close() + gob.Register(map[string]uint32{}) + return gob.NewEncoder(f).Encode(&m) + } + return nil + })) + eg.Go(safety.RecoverFunc(func() error { + return n.core.SaveIndex() + })) + return eg.Wait() } -func (n *ngt) CreateAndSaveIndex(poolSize uint32) (err error) { +func (n *ngt) CreateAndSaveIndex(ctx context.Context, poolSize uint32) (err error) { err = n.CreateIndex(poolSize) if err != nil { return err } - return n.SaveIndex() -} - -func (n *ngt) Close() { - n.core.Close() + return n.SaveIndex(ctx) } func (n *ngt) Exists(uuid string) (oid uint32, ok bool) { @@ -542,3 +593,11 @@ func (n *ngt) InsertVCacheLen() uint64 { func (n *ngt) DeleteVCacheLen() uint64 { return n.dvc.Len() } + +func (n *ngt) Close(ctx context.Context) (err error) { + if len(n.path) != 0 { + err = n.SaveIndex(ctx) + } + n.core.Close() + return +} diff --git a/pkg/agent/ngt/service/ngt_test.go b/pkg/agent/ngt/service/ngt_test.go index 7592722ebe..3b04846efd 100644 --- a/pkg/agent/ngt/service/ngt_test.go +++ b/pkg/agent/ngt/service/ngt_test.go @@ -124,6 +124,7 @@ func Test_ngt_Start(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -165,6 +166,7 @@ func Test_ngt_Start(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -193,6 +195,7 @@ func Test_ngt_Start(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -227,6 +230,7 @@ func Test_ngt_Start(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -259,6 +263,7 @@ func Test_ngt_Search(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -307,6 +312,7 @@ func Test_ngt_Search(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -338,6 +344,7 @@ func Test_ngt_Search(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -372,6 +379,7 @@ func Test_ngt_Search(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -404,6 +412,7 @@ func Test_ngt_SearchByID(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -452,6 +461,7 @@ func Test_ngt_SearchByID(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -483,6 +493,7 @@ func Test_ngt_SearchByID(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -517,6 +528,7 @@ func Test_ngt_SearchByID(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -547,6 +559,7 @@ func Test_ngt_Insert(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -589,6 +602,7 @@ func Test_ngt_Insert(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -618,6 +632,7 @@ func Test_ngt_Insert(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -652,6 +667,7 @@ func Test_ngt_Insert(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -684,6 +700,7 @@ func Test_ngt_insert(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -728,6 +745,7 @@ func Test_ngt_insert(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -759,6 +777,7 @@ func Test_ngt_insert(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -793,6 +812,7 @@ func Test_ngt_insert(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -822,6 +842,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -863,6 +884,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -891,6 +913,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -925,6 +948,7 @@ func Test_ngt_InsertMultiple(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -955,6 +979,7 @@ func Test_ngt_Update(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -997,6 +1022,7 @@ func Test_ngt_Update(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1026,6 +1052,7 @@ func Test_ngt_Update(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1060,6 +1087,7 @@ func Test_ngt_Update(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -1089,6 +1117,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -1130,6 +1159,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1158,6 +1188,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1192,6 +1223,7 @@ func Test_ngt_UpdateMultiple(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -1221,6 +1253,7 @@ func Test_ngt_Delete(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -1262,6 +1295,7 @@ func Test_ngt_Delete(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1290,6 +1324,7 @@ func Test_ngt_Delete(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1324,6 +1359,7 @@ func Test_ngt_Delete(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -1354,6 +1390,7 @@ func Test_ngt_delete(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -1396,6 +1433,7 @@ func Test_ngt_delete(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1425,6 +1463,7 @@ func Test_ngt_delete(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1459,6 +1498,7 @@ func Test_ngt_delete(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -1488,6 +1528,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -1529,6 +1570,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1557,6 +1599,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1591,6 +1634,7 @@ func Test_ngt_DeleteMultiple(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -1620,6 +1664,7 @@ func Test_ngt_GetObject(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -1665,6 +1710,7 @@ func Test_ngt_GetObject(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1693,6 +1739,7 @@ func Test_ngt_GetObject(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1727,6 +1774,7 @@ func Test_ngt_GetObject(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -1756,6 +1804,7 @@ func Test_ngt_CreateIndex(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -1797,6 +1846,7 @@ func Test_ngt_CreateIndex(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1825,6 +1875,7 @@ func Test_ngt_CreateIndex(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1859,6 +1910,7 @@ func Test_ngt_CreateIndex(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, @@ -1874,6 +1926,9 @@ func Test_ngt_CreateIndex(t *testing.T) { } func Test_ngt_SaveIndex(t *testing.T) { + type args struct { + ctx context.Context + } type fields struct { alen int indexing atomic.Value @@ -1885,6 +1940,7 @@ func Test_ngt_SaveIndex(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -1894,11 +1950,12 @@ func Test_ngt_SaveIndex(t *testing.T) { } type test struct { name string + args args fields fields want want checkFunc func(want, error) error - beforeFunc func() - afterFunc func() + beforeFunc func(args) + afterFunc func(args) } defaultCheckFunc := func(w want, err error) error { if !errors.Is(err, w.err) { @@ -1911,6 +1968,9 @@ func Test_ngt_SaveIndex(t *testing.T) { /* { name: "test_case_1", + args: args { + ctx: nil, + }, fields: fields { alen: 0, indexing: nil, @@ -1922,6 +1982,7 @@ func Test_ngt_SaveIndex(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1936,6 +1997,9 @@ func Test_ngt_SaveIndex(t *testing.T) { func() test { return test { name: "test_case_2", + args: args { + ctx: nil, + }, fields: fields { alen: 0, indexing: nil, @@ -1947,6 +2011,7 @@ func Test_ngt_SaveIndex(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -1962,10 +2027,10 @@ func Test_ngt_SaveIndex(t *testing.T) { t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(t) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(test.args) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(test.args) } if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -1981,12 +2046,13 @@ func Test_ngt_SaveIndex(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - err := n.SaveIndex() + err := n.SaveIndex(test.args.ctx) if err := test.checkFunc(test.want, err); err != nil { tt.Errorf("error = %v", err) } @@ -1997,6 +2063,7 @@ func Test_ngt_SaveIndex(t *testing.T) { func Test_ngt_CreateAndSaveIndex(t *testing.T) { type args struct { + ctx context.Context poolSize uint32 } type fields struct { @@ -2010,6 +2077,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -2038,6 +2106,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { { name: "test_case_1", args: args { + ctx: nil, poolSize: 0, }, fields: fields { @@ -2051,6 +2120,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2066,6 +2136,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { return test { name: "test_case_2", args: args { + ctx: nil, poolSize: 0, }, fields: fields { @@ -2079,6 +2150,7 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2113,12 +2185,13 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - err := n.CreateAndSaveIndex(test.args.poolSize) + err := n.CreateAndSaveIndex(test.args.ctx, test.args.poolSize) if err := test.checkFunc(test.want, err); err != nil { tt.Errorf("error = %v", err) } @@ -2127,7 +2200,10 @@ func Test_ngt_CreateAndSaveIndex(t *testing.T) { } } -func Test_ngt_Close(t *testing.T) { +func Test_ngt_Exists(t *testing.T) { + type args struct { + uuid string + } type fields struct { alen int indexing atomic.Value @@ -2139,21 +2215,31 @@ func Test_ngt_Close(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool } type want struct { + wantOid uint32 + wantOk bool } type test struct { name string + args args fields fields want want - checkFunc func(want) error - beforeFunc func() - afterFunc func() + checkFunc func(want, uint32, bool) error + beforeFunc func(args) + afterFunc func(args) } - defaultCheckFunc := func(w want) error { + defaultCheckFunc := func(w want, gotOid uint32, gotOk bool) error { + if !reflect.DeepEqual(gotOid, w.wantOid) { + return errors.Errorf("got = %v, want %v", gotOid, w.wantOid) + } + if !reflect.DeepEqual(gotOk, w.wantOk) { + return errors.Errorf("got = %v, want %v", gotOk, w.wantOk) + } return nil } tests := []test{ @@ -2161,6 +2247,9 @@ func Test_ngt_Close(t *testing.T) { /* { name: "test_case_1", + args: args { + uuid: "", + }, fields: fields { alen: 0, indexing: nil, @@ -2172,6 +2261,7 @@ func Test_ngt_Close(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2186,6 +2276,9 @@ func Test_ngt_Close(t *testing.T) { func() test { return test { name: "test_case_2", + args: args { + uuid: "", + }, fields: fields { alen: 0, indexing: nil, @@ -2197,6 +2290,7 @@ func Test_ngt_Close(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2212,10 +2306,10 @@ func Test_ngt_Close(t *testing.T) { t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(t) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(test.args) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(test.args) } if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -2231,20 +2325,22 @@ func Test_ngt_Close(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - n.Close() - if err := test.checkFunc(test.want); err != nil { + gotOid, gotOk := n.Exists(test.args.uuid) + if err := test.checkFunc(test.want, gotOid, gotOk); err != nil { tt.Errorf("error = %v", err) } + }) } } -func Test_ngt_Exists(t *testing.T) { +func Test_ngt_insertCache(t *testing.T) { type args struct { uuid string } @@ -2259,29 +2355,30 @@ func Test_ngt_Exists(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool } type want struct { - wantOid uint32 - wantOk bool + want *vcache + want1 bool } type test struct { name string args args fields fields want want - checkFunc func(want, uint32, bool) error + checkFunc func(want, *vcache, bool) error beforeFunc func(args) afterFunc func(args) } - defaultCheckFunc := func(w want, gotOid uint32, gotOk bool) error { - if !reflect.DeepEqual(gotOid, w.wantOid) { - return errors.Errorf("got = %v, want %v", gotOid, w.wantOid) + defaultCheckFunc := func(w want, got *vcache, got1 bool) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got = %v, want %v", got, w.want) } - if !reflect.DeepEqual(gotOk, w.wantOk) { - return errors.Errorf("got = %v, want %v", gotOk, w.wantOk) + if !reflect.DeepEqual(got1, w.want1) { + return errors.Errorf("got = %v, want %v", got1, w.want1) } return nil } @@ -2304,6 +2401,7 @@ func Test_ngt_Exists(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2332,6 +2430,7 @@ func Test_ngt_Exists(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2366,13 +2465,14 @@ func Test_ngt_Exists(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - gotOid, gotOk := n.Exists(test.args.uuid) - if err := test.checkFunc(test.want, gotOid, gotOk); err != nil { + got, got1 := n.insertCache(test.args.uuid) + if err := test.checkFunc(test.want, got, got1); err != nil { tt.Errorf("error = %v", err) } @@ -2380,10 +2480,7 @@ func Test_ngt_Exists(t *testing.T) { } } -func Test_ngt_insertCache(t *testing.T) { - type args struct { - uuid string - } +func Test_ngt_IsIndexing(t *testing.T) { type fields struct { alen int indexing atomic.Value @@ -2395,30 +2492,26 @@ func Test_ngt_insertCache(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool } type want struct { - want *vcache - want1 bool + want bool } type test struct { name string - args args fields fields want want - checkFunc func(want, *vcache, bool) error - beforeFunc func(args) - afterFunc func(args) + checkFunc func(want, bool) error + beforeFunc func() + afterFunc func() } - defaultCheckFunc := func(w want, got *vcache, got1 bool) error { + defaultCheckFunc := func(w want, got bool) error { if !reflect.DeepEqual(got, w.want) { return errors.Errorf("got = %v, want %v", got, w.want) } - if !reflect.DeepEqual(got1, w.want1) { - return errors.Errorf("got = %v, want %v", got1, w.want1) - } return nil } tests := []test{ @@ -2426,9 +2519,6 @@ func Test_ngt_insertCache(t *testing.T) { /* { name: "test_case_1", - args: args { - uuid: "", - }, fields: fields { alen: 0, indexing: nil, @@ -2440,6 +2530,7 @@ func Test_ngt_insertCache(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2454,9 +2545,6 @@ func Test_ngt_insertCache(t *testing.T) { func() test { return test { name: "test_case_2", - args: args { - uuid: "", - }, fields: fields { alen: 0, indexing: nil, @@ -2468,6 +2556,7 @@ func Test_ngt_insertCache(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2483,10 +2572,10 @@ func Test_ngt_insertCache(t *testing.T) { t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(t) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc() } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc() } if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -2502,13 +2591,14 @@ func Test_ngt_insertCache(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - got, got1 := n.insertCache(test.args.uuid) - if err := test.checkFunc(test.want, got, got1); err != nil { + got := n.IsIndexing() + if err := test.checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } @@ -2516,7 +2606,10 @@ func Test_ngt_insertCache(t *testing.T) { } } -func Test_ngt_IsIndexing(t *testing.T) { +func Test_ngt_UUIDs(t *testing.T) { + type args struct { + ctx context.Context + } type fields struct { alen int indexing atomic.Value @@ -2528,24 +2621,26 @@ func Test_ngt_IsIndexing(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool } type want struct { - want bool + wantUuids []string } type test struct { name string + args args fields fields want want - checkFunc func(want, bool) error - beforeFunc func() - afterFunc func() + checkFunc func(want, []string) error + beforeFunc func(args) + afterFunc func(args) } - defaultCheckFunc := func(w want, got bool) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + defaultCheckFunc := func(w want, gotUuids []string) error { + if !reflect.DeepEqual(gotUuids, w.wantUuids) { + return errors.Errorf("got = %v, want %v", gotUuids, w.wantUuids) } return nil } @@ -2554,6 +2649,9 @@ func Test_ngt_IsIndexing(t *testing.T) { /* { name: "test_case_1", + args: args { + ctx: nil, + }, fields: fields { alen: 0, indexing: nil, @@ -2565,6 +2663,7 @@ func Test_ngt_IsIndexing(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2579,6 +2678,9 @@ func Test_ngt_IsIndexing(t *testing.T) { func() test { return test { name: "test_case_2", + args: args { + ctx: nil, + }, fields: fields { alen: 0, indexing: nil, @@ -2590,6 +2692,7 @@ func Test_ngt_IsIndexing(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2605,10 +2708,10 @@ func Test_ngt_IsIndexing(t *testing.T) { t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(t) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(test.args) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(test.args) } if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -2624,13 +2727,14 @@ func Test_ngt_IsIndexing(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - got := n.IsIndexing() - if err := test.checkFunc(test.want, got); err != nil { + gotUuids := n.UUIDs(test.args.ctx) + if err := test.checkFunc(test.want, gotUuids); err != nil { tt.Errorf("error = %v", err) } @@ -2638,10 +2742,7 @@ func Test_ngt_IsIndexing(t *testing.T) { } } -func Test_ngt_UUIDs(t *testing.T) { - type args struct { - ctx context.Context - } +func Test_ngt_UncommittedUUIDs(t *testing.T) { type fields struct { alen int indexing atomic.Value @@ -2653,6 +2754,7 @@ func Test_ngt_UUIDs(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -2662,12 +2764,11 @@ func Test_ngt_UUIDs(t *testing.T) { } type test struct { name string - args args fields fields want want checkFunc func(want, []string) error - beforeFunc func(args) - afterFunc func(args) + beforeFunc func() + afterFunc func() } defaultCheckFunc := func(w want, gotUuids []string) error { if !reflect.DeepEqual(gotUuids, w.wantUuids) { @@ -2680,9 +2781,6 @@ func Test_ngt_UUIDs(t *testing.T) { /* { name: "test_case_1", - args: args { - ctx: nil, - }, fields: fields { alen: 0, indexing: nil, @@ -2694,6 +2792,7 @@ func Test_ngt_UUIDs(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2708,9 +2807,6 @@ func Test_ngt_UUIDs(t *testing.T) { func() test { return test { name: "test_case_2", - args: args { - ctx: nil, - }, fields: fields { alen: 0, indexing: nil, @@ -2722,6 +2818,7 @@ func Test_ngt_UUIDs(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2737,10 +2834,10 @@ func Test_ngt_UUIDs(t *testing.T) { t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(t) if test.beforeFunc != nil { - test.beforeFunc(test.args) + test.beforeFunc() } if test.afterFunc != nil { - defer test.afterFunc(test.args) + defer test.afterFunc() } if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -2756,12 +2853,13 @@ func Test_ngt_UUIDs(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - gotUuids := n.UUIDs(test.args.ctx) + gotUuids := n.UncommittedUUIDs() if err := test.checkFunc(test.want, gotUuids); err != nil { tt.Errorf("error = %v", err) } @@ -2770,7 +2868,7 @@ func Test_ngt_UUIDs(t *testing.T) { } } -func Test_ngt_UncommittedUUIDs(t *testing.T) { +func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { type fields struct { alen int indexing atomic.Value @@ -2782,24 +2880,25 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool } type want struct { - wantUuids []string + want uint64 } type test struct { name string fields fields want want - checkFunc func(want, []string) error + checkFunc func(want, uint64) error beforeFunc func() afterFunc func() } - defaultCheckFunc := func(w want, gotUuids []string) error { - if !reflect.DeepEqual(gotUuids, w.wantUuids) { - return errors.Errorf("got = %v, want %v", gotUuids, w.wantUuids) + defaultCheckFunc := func(w want, got uint64) error { + if !reflect.DeepEqual(got, w.want) { + return errors.Errorf("got = %v, want %v", got, w.want) } return nil } @@ -2819,6 +2918,7 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2844,6 +2944,7 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2878,13 +2979,14 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - gotUuids := n.UncommittedUUIDs() - if err := test.checkFunc(test.want, gotUuids); err != nil { + got := n.NumberOfCreateIndexExecution() + if err := test.checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } @@ -2892,7 +2994,7 @@ func Test_ngt_UncommittedUUIDs(t *testing.T) { } } -func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { +func Test_ngt_Len(t *testing.T) { type fields struct { alen int indexing atomic.Value @@ -2904,6 +3006,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -2941,6 +3044,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -2966,6 +3070,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -3000,12 +3105,13 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - got := n.NumberOfCreateIndexExecution() + got := n.Len() if err := test.checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } @@ -3014,7 +3120,7 @@ func Test_ngt_NumberOfCreateIndexExecution(t *testing.T) { } } -func Test_ngt_Len(t *testing.T) { +func Test_ngt_InsertVCacheLen(t *testing.T) { type fields struct { alen int indexing atomic.Value @@ -3026,6 +3132,7 @@ func Test_ngt_Len(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -3063,6 +3170,7 @@ func Test_ngt_Len(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -3088,6 +3196,7 @@ func Test_ngt_Len(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -3122,12 +3231,13 @@ func Test_ngt_Len(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - got := n.Len() + got := n.InsertVCacheLen() if err := test.checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } @@ -3136,7 +3246,7 @@ func Test_ngt_Len(t *testing.T) { } } -func Test_ngt_InsertVCacheLen(t *testing.T) { +func Test_ngt_DeleteVCacheLen(t *testing.T) { type fields struct { alen int indexing atomic.Value @@ -3148,6 +3258,7 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool @@ -3185,6 +3296,7 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -3210,6 +3322,7 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -3244,12 +3357,13 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - got := n.InsertVCacheLen() + got := n.DeleteVCacheLen() if err := test.checkFunc(test.want, got); err != nil { tt.Errorf("error = %v", err) } @@ -3258,7 +3372,10 @@ func Test_ngt_InsertVCacheLen(t *testing.T) { } } -func Test_ngt_DeleteVCacheLen(t *testing.T) { +func Test_ngt_Close(t *testing.T) { + type args struct { + ctx context.Context + } type fields struct { alen int indexing atomic.Value @@ -3270,24 +3387,26 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { eg errgroup.Group ivc *vcaches dvc *vcaches + path string kvs kvs.BidiMap core core.NGT dcd bool } type want struct { - want uint64 + err error } type test struct { name string + args args fields fields want want - checkFunc func(want, uint64) error - beforeFunc func() - afterFunc func() + checkFunc func(want, error) error + beforeFunc func(args) + afterFunc func(args) } - defaultCheckFunc := func(w want, got uint64) error { - if !reflect.DeepEqual(got, w.want) { - return errors.Errorf("got = %v, want %v", got, w.want) + defaultCheckFunc := func(w want, err error) error { + if !errors.Is(err, w.err) { + return errors.Errorf("got error = %v, want %v", err, w.err) } return nil } @@ -3296,6 +3415,9 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { /* { name: "test_case_1", + args: args { + ctx: nil, + }, fields: fields { alen: 0, indexing: nil, @@ -3307,6 +3429,7 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -3321,6 +3444,9 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { func() test { return test { name: "test_case_2", + args: args { + ctx: nil, + }, fields: fields { alen: 0, indexing: nil, @@ -3332,6 +3458,7 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { eg: nil, ivc: vcaches{}, dvc: vcaches{}, + path: "", kvs: nil, core: nil, dcd: false, @@ -3347,10 +3474,10 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { t.Run(test.name, func(tt *testing.T) { defer goleak.VerifyNone(t) if test.beforeFunc != nil { - test.beforeFunc() + test.beforeFunc(test.args) } if test.afterFunc != nil { - defer test.afterFunc() + defer test.afterFunc(test.args) } if test.checkFunc == nil { test.checkFunc = defaultCheckFunc @@ -3366,13 +3493,14 @@ func Test_ngt_DeleteVCacheLen(t *testing.T) { eg: test.fields.eg, ivc: test.fields.ivc, dvc: test.fields.dvc, + path: test.fields.path, kvs: test.fields.kvs, core: test.fields.core, dcd: test.fields.dcd, } - got := n.DeleteVCacheLen() - if err := test.checkFunc(test.want, got); err != nil { + err := n.Close(test.args.ctx) + if err := test.checkFunc(test.want, err); err != nil { tt.Errorf("error = %v", err) } diff --git a/pkg/agent/ngt/usecase/agentd.go b/pkg/agent/ngt/usecase/agentd.go index 6b9a403a58..a89b55a252 100644 --- a/pkg/agent/ngt/usecase/agentd.go +++ b/pkg/agent/ngt/usecase/agentd.go @@ -174,5 +174,6 @@ func (r *run) Stop(ctx context.Context) error { } func (r *run) PostStop(ctx context.Context) error { + r.ngt.Close(ctx) return nil } From a1459c574ba7278b22e7e186aa25d4ee97d08fcd Mon Sep 17 00:00:00 2001 From: Yusuke Kato Date: Mon, 11 May 2020 15:42:48 +0900 Subject: [PATCH 2/4] Update charts/vald/values.yaml Co-authored-by: Rintaro Okamura --- charts/vald/values.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/vald/values.yaml b/charts/vald/values.yaml index a33ee1be40..da8559b2ec 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -617,7 +617,8 @@ agent: # agent.podManagementPolicy -- pod management policy: OrderedReady or Parallel podManagementPolicy: OrderedReady volumeStore: - # agent.volumeStore.enabled -- enables agent pod's file store functionality when non in-memory mode + # agent.pvc.enabled -- enables PVC. + # It is required to enable if agent pod's file store functionality is enabled with non in-memory mode enabled: false # agent.volumeStore.accessMode -- agent pod storage accessMode accessMode: ReadWriteOnce From a3ef68371491de77f804af61d9032ca16128e49c Mon Sep 17 00:00:00 2001 From: kpango Date: Mon, 11 May 2020 19:00:57 +0900 Subject: [PATCH 3/4] fix Signed-off-by: kpango --- charts/vald/templates/agent/statefulset.yaml | 20 +++++++++++++++----- charts/vald/values.yaml | 10 +++++----- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/charts/vald/templates/agent/statefulset.yaml b/charts/vald/templates/agent/statefulset.yaml index 2bac1ccd9c..503d74d86f 100644 --- a/charts/vald/templates/agent/statefulset.yaml +++ b/charts/vald/templates/agent/statefulset.yaml @@ -75,6 +75,14 @@ spec: volumeMounts: - name: {{ .Values.agent.name }}-config mountPath: /etc/server/ + {{- if not .Values.agent.ngt.enable_in_memory_mode }} + {{- if .Values.agent.ngt.index_path }} + {{- if .Values.agent.persistentVolume.enabled }} + - name: {{ .Values.agent.name }}-pvc + mountPath: {{ .Values.agent.ngt.index_path }} + {{- end }} + {{- end }} + {{- end }} {{- if .Values.agent.volumeMounts }} {{- toYaml .Values.agent.volumeMounts | nindent 12 }} {{- end }} @@ -107,18 +115,20 @@ spec: priorityClassName: {{ .Values.agent.name }}-priority {{- end }} {{- end }} -{{- if .Values.agent.volumeStore }} -{{- if .Values.agent.volumeStore.enabled }} +{{- if not .Values.agent.ngt.enable_in_memory_mode }} +{{- if .Values.agent.ngt.index_path }} +{{- if .Values.agent.persistentVolume.enabled }} volumeClaimTemplates: - metadata: name: {{ .Values.agent.name }}-pvc spec: accessModes: - - {{ .Values.agent.volumeStore.accessMode }} - storageClassName: {{ .Values.agent.volumeStore.storageClass }} + - {{ .Values.agent.persistentVolume.accessMode }} + storageClassName: {{ .Values.agent.persistentVolume.storageClass }} resources: requests: - storage: {{ .Values.agent.volumeStore.size }} + storage: {{ .Values.agent.persistentVolume.size }} +{{- end }} {{- end }} {{- end }} status: diff --git a/charts/vald/values.yaml b/charts/vald/values.yaml index da8559b2ec..fa48e7ec20 100644 --- a/charts/vald/values.yaml +++ b/charts/vald/values.yaml @@ -616,15 +616,15 @@ agent: terminationGracePeriodSeconds: 30 # agent.podManagementPolicy -- pod management policy: OrderedReady or Parallel podManagementPolicy: OrderedReady - volumeStore: - # agent.pvc.enabled -- enables PVC. + persistentVolume: + # agent.persistentVolume.enabled -- enables PVC. # It is required to enable if agent pod's file store functionality is enabled with non in-memory mode enabled: false - # agent.volumeStore.accessMode -- agent pod storage accessMode + # agent.persistentVolume.accessMode -- agent pod storage accessMode accessMode: ReadWriteOnce - # agent.volumeStore.storageClass -- storageClass name for agent pod volume + # agent.persistentVolume.storageClass -- storageClass name for agent pod volume storageClass: vald-sc - # agent.volumeStore.size -- size of agent pod volume + # agent.persistentVolume.size -- size of agent pod volume size: 100Gi podPriority: # agent.podPriority.enabled -- agent pod PriorityClass enabled From aa23c97353d49bf2927cb707994fd0420c34eafe Mon Sep 17 00:00:00 2001 From: vdaas-ci Date: Tue, 12 May 2020 00:59:25 +0000 Subject: [PATCH 4/4] :robot: Update license headers and formatting go codes Signed-off-by: vdaas-ci --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 2f7c67b2f7..57372d7ec3 100755 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( go.uber.org/automaxprocs v1.3.0 go.uber.org/goleak v1.0.0 golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9 - golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5 // indirect + golang.org/x/tools v0.0.0-20200512001501-aaeff5de670a // indirect gonum.org/v1/hdf5 v0.0.0-20200504100616-496fefe91614 gonum.org/v1/netlib v0.0.0-20200317120129-c5a04cffd98a // indirect gonum.org/v1/plot v0.7.0 diff --git a/go.sum b/go.sum index 816797b767..d0740dc003 100644 --- a/go.sum +++ b/go.sum @@ -598,6 +598,8 @@ golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191203134012-c197fd4bf371/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5 h1:MeC2gMlMdkd67dn17MEby3rGXRxZtWeiRXOnISfTQ74= golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512001501-aaeff5de670a h1:vAa2fXRLbiVN3N/xCnodIT36K4QKZQNyQFq3hQJfQ1U= +golang.org/x/tools v0.0.0-20200512001501-aaeff5de670a/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=