Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add read replica rotator #2241

Merged
merged 32 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
3767c8b
Implement sample read replica rotation logic
ykadowak Nov 10, 2023
1e4a070
Add external-snapshotter in go.mod
ykadowak Nov 16, 2023
82c4d11
Add readreplica initial implementation
ykadowak Nov 16, 2023
875ce3b
Add service implementation of readreplica rotator
ykadowak Nov 20, 2023
9336760
Add readreplica rotate config
ykadowak Nov 20, 2023
747cf92
Refactor to read labels
ykadowak Nov 21, 2023
57812e2
replace id to _MY_TARGET_REPLICA_ID_
ykadowak Nov 22, 2023
4a48422
Add snapshot k8s client
ykadowak Nov 22, 2023
45cc8e4
Format
ykadowak Nov 22, 2023
bb14dab
Fix snapshot client initialization
ykadowak Nov 22, 2023
162a786
Add Apache License to main.go
ykadowak Nov 22, 2023
9a93754
Use GetConfigOrDie
ykadowak Nov 22, 2023
eed7522
Use internal/k8s client
ykadowak Nov 22, 2023
1fdd3d2
Refactor
ykadowak Nov 22, 2023
b6f93f2
Use controller-runtime for CRUD in readreplica
ykadowak Nov 24, 2023
b6d4580
Remove snapshot client and use controller-runtime
ykadowak Nov 24, 2023
945fe76
Move LabelSelector into internal/k8s
ykadowak Nov 24, 2023
79f7de5
Report error to span
ykadowak Nov 24, 2023
1c982ca
Merge branch 'main' into feature/example/readreplica
ykadowak Nov 24, 2023
167e704
Update go modules
ykadowak Nov 24, 2023
b4051ae
Remove old example
ykadowak Nov 24, 2023
2a5d358
Refactor
ykadowak Nov 24, 2023
7b3f428
Disable exhaustruct for now
ykadowak Nov 24, 2023
55e9b6a
Fix predeclared
ykadowak Nov 24, 2023
bebb04c
Fix stylecheck
ykadowak Nov 24, 2023
3e6f179
nolint:gomnd
ykadowak Nov 24, 2023
f212824
Add test template
ykadowak Nov 24, 2023
b5897c2
Add test for getNewBaseName
ykadowak Nov 24, 2023
613e5c9
fix misspelling
ykadowak Nov 27, 2023
3db2715
Apply format
ykadowak Nov 27, 2023
bb3e72a
Merge branch 'main' into reature/readreplica/rotator
ykadowak Nov 28, 2023
0d57414
Fix camel case
ykadowak Nov 28, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions cmd/index/job/readreplica/rotate/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
//
// 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 main

import (
"context"

"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/info"
"github.com/vdaas/vald/internal/log"
"github.com/vdaas/vald/internal/runner"
"github.com/vdaas/vald/internal/safety"
"github.com/vdaas/vald/pkg/index/job/readreplica/rotate/config"
"github.com/vdaas/vald/pkg/index/job/readreplica/rotate/usecase"
)

const (
maxVersion = "v0.0.10"
minVersion = "v0.0.0"
name = "readreplica rotate job"
)

func main() {
if err := safety.RecoverFunc(func() error {
return runner.Do(
context.Background(),
runner.WithName(name),
runner.WithVersion(info.Version, maxVersion, minVersion),
runner.WithConfigLoader(func(path string) (interface{}, *config.GlobalConfig, error) {
cfg, err := config.NewConfig(path)
if err != nil {
return nil, nil, errors.Wrap(err, "failed to load "+name+"'s configuration")
}
return cfg, &cfg.GlobalConfig, nil
}),
runner.WithDaemonInitializer(func(cfg interface{}) (runner.Runner, error) {
c, ok := cfg.(*config.Data)
if !ok {
return nil, errors.ErrInvalidConfig
}
return usecase.New(c)
}),
)
})(); err != nil {
log.Fatal(err, info.Get())
return
}
}
108 changes: 108 additions & 0 deletions cmd/index/job/readreplica/rotate/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
#
# Copyright (C) 2019-2023 vdaas.org vald team <[email protected]>
#
# 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.
#

---
version: v0.0.0
time_zone: JST
logging:
format: raw
level: info
logger: glg
server_config:
servers:
- name: grpc
host: 0.0.0.0
port: 8081
grpc:
bidirectional_stream_concurrency: 20
connection_timeout: ""
header_table_size: 0
initial_conn_window_size: 0
initial_window_size: 0
interceptors: []
keepalive:
max_conn_age: ""
max_conn_age_grace: ""
max_conn_idle: ""
time: ""
timeout: ""
max_header_list_size: 0
max_receive_message_size: 0
max_send_message_size: 0
read_buffer_size: 0
write_buffer_size: 0
mode: GRPC
probe_wait_time: 3s
restart: true
health_check_servers:
- name: readiness
host: 0.0.0.0
port: 3001
http:
handler_timeout: ""
idle_timeout: ""
read_header_timeout: ""
read_timeout: ""
shutdown_duration: 0s
write_timeout: ""
mode: ""
probe_wait_time: 3s
metrics_servers:
startup_strategy:
- grpc
- readiness
full_shutdown_duration: 600s
tls:
ca: /path/to/ca
cert: /path/to/cert
enabled: false
key: /path/to/key
rotator:
agent_namespace: "default"
read_replica_label_key: "vald-readreplica-id"
read_replica_id: "_MY_TARGET_REPLICA_ID_"
volume_name: "vald-agent-ngt-readreplica-pvc"
observability:
enabled: false
otlp:
collector_endpoint: "opentelemetry-collector-collector.default.svc.cluster.local:4317"
trace_batch_timeout: "1s"
trace_export_timeout: "1m"
trace_max_export_batch_size: 1024
trace_max_queue_size: 256
metrics_export_interval: "1s"
metrics_export_timeout: "1m"
attribute:
namespace: "_MY_POD_NAMESPACE_"
pod_name: "_MY_POD_NAME_"
node_name: "_MY_NODE_NAME_"
service_name: "vald-index-correction"
metrics:
enable_cgo: true
enable_goroutine: true
enable_memory: true
enable_version_info: true
version_info_labels:
- vald_version
- server_name
- git_commit
- build_time
- go_version
- go_os
- go_arch
- ngt_version
trace:
enabled: true
Loading
Loading