Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
# ignore go generate code files
pkg/testutil/k8s/mocks/*_mocks.go
pkg/configuration/proto/mocks/*_mocks.go
pkg/configuration/container/mocks/*_mocks.go
# pkg/configuration/proto/*.pb.go

# ignore go mock temporary files
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ endif
.PHONY: test-go-generate
test-go-generate: ## Run go generate against test code.
$(GO) generate -x ./pkg/testutil/k8s/mocks/...
$(GO) generate -x ./pkg/configuration/container/mocks/...
$(GO) generate -x ./pkg/configuration/proto/mocks/...

.PHONY: fmt
Expand Down
2 changes: 0 additions & 2 deletions apis/parameters/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ type ReloadPolicy string
const (
NonePolicy ReloadPolicy = "none"
RestartPolicy ReloadPolicy = "restart"
RestartContainerPolicy ReloadPolicy = "restartContainer"
RollingPolicy ReloadPolicy = "rolling"
AsyncDynamicReloadPolicy ReloadPolicy = "asyncReload"
SyncDynamicReloadPolicy ReloadPolicy = "syncReload"
DynamicReloadAndRestartPolicy ReloadPolicy = "dynamicReloadBeginRestart"
Expand Down
5 changes: 1 addition & 4 deletions cmd/reloader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,21 @@ Usage:
reloader [flags]

Flags:
--container-runtime string the config set cri runtime type. (default "auto")
--debug the config set debug.
--disable-runtime the config set disable runtime.
-h, --help help for reloader
--log-level string the config set log level. enum: [error, info, debug] (default "info")
--notify-type notifyType the config describe how to process notification messages. (default signal)
--pod-ip string the config set pod ip address. (default "127.0.0.1")
--process string the config describe what is db program.
--regex string the config set filter config file.
--runtime-endpoint string the config set cri runtime endpoint.
--signal string the config describe reload unix signal. (default "SIGHUP")
--tcp int the config set service port. (default 9901)
--volume-dir stringArray the config map volume directory to watch for updates; may be used multiple times.

```

```shell
./bin/reloader --disable-runtime --log-level debug --process mysqld --signal SIGHUP --volume-dir /opt/mysql --volume-dir /etc/mysql
./bin/reloader --log-level debug --process mysqld --signal SIGHUP --volume-dir /opt/mysql --volume-dir /etc/mysql

```

Expand Down
2 changes: 1 addition & 1 deletion cmd/reloader/app/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func run(ctx context.Context, opt *VolumeWatcherOpts) error {

func checkAndCreateService(ctx context.Context, opt *VolumeWatcherOpts, handler cfgcore.ConfigHandler) error {
serviceOpt := opt.ServiceOpt
if !serviceOpt.ContainerRuntimeEnable && !serviceOpt.RemoteOnlineUpdateEnable {
if !serviceOpt.RemoteOnlineUpdateEnable {
return nil
}
if err := startGRPCService(opt, ctx, handler); err != nil {
Expand Down
60 changes: 2 additions & 58 deletions cmd/reloader/app/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/spf13/pflag"

appsv1beta1 "github.com/apecloud/kubeblocks/apis/apps/v1beta1"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/container"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
viper "github.com/apecloud/kubeblocks/pkg/viperx"
)
Expand Down Expand Up @@ -89,12 +88,8 @@ type ReconfigureServiceOptions struct {

// EnableRemoteOnlineUpdate enables remote online update
RemoteOnlineUpdateEnable bool
// EnableContainerRuntime enables container runtime
ContainerRuntimeEnable bool

DebugMode bool
ContainerRuntime cfgutil.CRIType
RuntimeEndpoint string
DebugMode bool
}

type VolumeWatcherOpts struct {
Expand All @@ -115,9 +110,7 @@ func NewVolumeWatcherOpts() *VolumeWatcherOpts {
ServiceOpt: ReconfigureServiceOptions{
GrpcPort: configManagerDefaultPort,
PodIP: viper.GetString(configPodIPEnvName),
ContainerRuntime: cfgutil.AutoType,
DebugMode: false,
ContainerRuntimeEnable: false,
RemoteOnlineUpdateEnable: false,
},
LogLevel: "info",
Expand All @@ -129,42 +122,6 @@ func InstallFlags(flags *pflag.FlagSet, opt *VolumeWatcherOpts) {
"volume-dir",
opt.VolumeDirs,
"the config map volume directory to be watched for updates; may be used multiple times.")

// flags.Var(&opt.NotifyHandType,
// "notify-type",
// "the config describes how to process notification messages.",
// )
//
// for signal handle
// flags.StringVar(&opt.ProcessName,
// "process",
// opt.ProcessName,
// "the config describes what db program is.")
// flags.StringVar((*string)(&opt.Signal),
// "signal",
// string(opt.Signal),
// "the config describes the reload unix signal.")
//
// for exec handle
// flags.StringVar(&opt.Command,
// "command",
// opt.Command,
// "the config describes reload command. ")
//
// for exec tpl scripts
// flags.StringVar(&opt.TPLConfig,
// "tpl-config",
// opt.TPLConfig,
// "the config describes reload behaviors by tpl script.")
// flags.StringVar(&opt.BackupPath,
// "backup-path",
// opt.BackupPath,
// "the config describes backup path.")
// flags.StringVar(&opt.FileRegex,
// "regex",
// opt.FileRegex,
// "the config sets filter config file.")

flags.StringVar(&opt.LogLevel,
"log-level",
opt.LogLevel,
Expand All @@ -181,23 +138,10 @@ func InstallFlags(flags *pflag.FlagSet, opt *VolumeWatcherOpts) {
"debug",
opt.ServiceOpt.DebugMode,
"the config sets debug mode.")
flags.StringVar((*string)(&opt.ServiceOpt.ContainerRuntime),
"container-runtime",
string(opt.ServiceOpt.ContainerRuntime),
"the config sets cri runtime type.")
flags.StringVar(&opt.ServiceOpt.RuntimeEndpoint,
"runtime-endpoint",
opt.ServiceOpt.RuntimeEndpoint,
"the config sets cri runtime endpoint.")

flags.BoolVar(&opt.ServiceOpt.ContainerRuntimeEnable,
"cri-enable",
opt.ServiceOpt.ContainerRuntimeEnable,
"the config sets enable cri.")

flags.BoolVar(&opt.ServiceOpt.RemoteOnlineUpdateEnable,
"operator-update-enable",
opt.ServiceOpt.ContainerRuntimeEnable,
opt.ServiceOpt.RemoteOnlineUpdateEnable,
"the config sets enable operator update parameter.")

// for multi handler
Expand Down
44 changes: 2 additions & 42 deletions cmd/reloader/app/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,68 +25,28 @@ import (
"go.uber.org/zap"

cfgcm "github.com/apecloud/kubeblocks/pkg/configuration/config_manager"
cfgutil "github.com/apecloud/kubeblocks/pkg/configuration/container"
cfgcore "github.com/apecloud/kubeblocks/pkg/configuration/core"
cfgproto "github.com/apecloud/kubeblocks/pkg/configuration/proto"
viper "github.com/apecloud/kubeblocks/pkg/viperx"
)

type reconfigureProxy struct {
cfgproto.ReconfigureServer
updater cfgcm.DynamicUpdater

ctx context.Context
opt ReconfigureServiceOptions
killer cfgutil.ContainerKiller
ctx context.Context
opt ReconfigureServiceOptions

logger *zap.SugaredLogger
}

var stopContainerSignal = viper.GetString(cfgutil.KillContainerSignalEnvName)

func (r *reconfigureProxy) Init(handler cfgcm.ConfigHandler) error {
if err := r.initOnlineUpdater(handler); err != nil {
r.logger.Errorf("init online updater failed: %+v", err)
return err
}
if err := r.initContainerKiller(); err != nil {
r.logger.Errorf("init container killer failed: %+v", err)
return err
}
return nil
}

func (r *reconfigureProxy) initContainerKiller() error {
if !r.opt.ContainerRuntimeEnable {
r.logger.Info("container killer is disabled.")
return nil
}

killer, err := cfgutil.NewContainerKiller(r.opt.ContainerRuntime, r.opt.RuntimeEndpoint, r.logger)
if err != nil {
return cfgcore.WrapError(err, "failed to create container killer")
}
if err := killer.Init(r.ctx); err != nil {
return cfgcore.WrapError(err, "failed to init killer")
}
r.killer = killer
return nil
}

func (r *reconfigureProxy) StopContainer(ctx context.Context, request *cfgproto.StopContainerRequest) (*cfgproto.StopContainerResponse, error) {
if r.killer == nil {
return nil, cfgcore.MakeError("container killing process is not initialized.")
}
ds := request.GetContainerIDs()
if len(ds) == 0 {
return &cfgproto.StopContainerResponse{ErrMessage: "no match for any container with containerId."}, nil
}
if err := r.killer.Kill(ctx, ds, stopContainerSignal, nil); err != nil {
return nil, err
}
return &cfgproto.StopContainerResponse{}, nil
}

func (r *reconfigureProxy) OnlineUpgradeParams(ctx context.Context, request *cfgproto.OnlineUpgradeParamsRequest) (*cfgproto.OnlineUpgradeParamsResponse, error) {
if r.updater == nil {
return nil, cfgcore.MakeError("online updating process is not initialized.")
Expand Down
61 changes: 0 additions & 61 deletions controllers/parameters/parallel_upgrade_policy.go

This file was deleted.

Loading