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
151 changes: 3 additions & 148 deletions apis/parameters/v1alpha1/parametersdefinition_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ limitations under the License.
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -81,35 +80,10 @@ type ParametersDefinitionSpec struct {
// If `reloadAction` is not set or the modified parameters are not listed in `dynamicParameters`,
// dynamic reloading will not be triggered.
//
// Example:
// ```yaml
// dynamicReloadAction:
// tplScriptTrigger:
// namespace: kb-system
// scriptConfigMapRef: mysql-reload-script
// sync: true
// ```
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 1.2.0"
// +optional
ReloadAction *ReloadAction `json:"reloadAction,omitempty"`

// TODO: migrate DownwardAPITriggeredActions to ComponentDefinition.spec.lifecycleActions
// Specifies a list of actions to execute specified commands based on Pod labels.
//
// It utilizes the K8s Downward API to mount label information as a volume into the pod.
// The 'config-manager' sidecar container watches for changes in the role label and dynamically invoke
// registered commands (usually execute some SQL statements) when a change is detected.
//
// It is designed for scenarios where:
//
// - Replicas with different roles have different configurations, such as Redis primary & secondary replicas.
// - After a role switch (e.g., from secondary to primary), some changes in configuration are needed
// to reflect the new role.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 1.1.0"
// +optional
DownwardAPIChangeTriggeredActions []DownwardAPIChangeTriggeredAction `json:"downwardAPIChangeTriggeredActions,omitempty"`

// Specifies the policy when parameter be removed.
//
// +optional
Expand All @@ -123,6 +97,7 @@ type ParametersDefinitionSpec struct {
// This flag allows for more efficient handling of configuration changes by potentially eliminating
// an unnecessary reload step.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 1.2.0"
// +optional
MergeReloadAndRestart *bool `json:"mergeReloadAndRestart,omitempty"`

Expand All @@ -136,6 +111,7 @@ type ParametersDefinitionSpec struct {
// The "all" option is for certain engines that require static parameters to be set
// via SQL statements before they can take effect on restart.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 1.2.0"
// +optional
ReloadStaticParamsBeforeRestart *bool `json:"reloadStaticParamsBeforeRestart,omitempty"`

Expand Down Expand Up @@ -206,23 +182,11 @@ type ParametersDefinitionStatus struct {
//
// Only one of the mechanisms can be specified at a time.
type ReloadAction struct {
// Used to trigger a reload by sending a specific Unix signal to the process.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 1.1.0"
// +optional
UnixSignalTrigger *UnixSignalTrigger `json:"unixSignalTrigger,omitempty"`

// Allows to execute a custom shell script to reload the process.
//
// +optional
ShellTrigger *ShellTrigger `json:"shellTrigger,omitempty"`

// Enables reloading process using a Go template script.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 1.1.0"
// +optional
TPLScriptTrigger *TPLScriptTrigger `json:"tplScriptTrigger"`

// Automatically perform the reload when specified conditions are met.
//
// +optional
Expand All @@ -240,19 +204,6 @@ type ReloadAction struct {
TargetPodSelector *metav1.LabelSelector `json:"targetPodSelector,omitempty"`
}

// UnixSignalTrigger is used to trigger a reload by sending a specific Unix signal to the process.
type UnixSignalTrigger struct {
// Specifies a valid Unix signal to be sent.
//
// +kubebuilder:validation:Required
Signal SignalType `json:"signal"`

// Identifies the name of the process to which the Unix signal will be sent.
//
// +kubebuilder:validation:Required
ProcessName string `json:"processName"`
}

// ToolsSetup prepares the tools for dynamic reloads used in ShellTrigger from a specified container image.
//
// Example:
Expand Down Expand Up @@ -375,41 +326,6 @@ type ImageMapping struct {
Image string `json:"image"`
}

// DownwardAPIChangeTriggeredAction defines an action that triggers specific commands in response to changes in Pod labels.
// For example, a command might be executed when the 'role' label of the Pod is updated.
type DownwardAPIChangeTriggeredAction struct {
// Specifies the name of the field. It must be a string of maximum length 63.
// The name should match the regex pattern `^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=63
// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
Name string `json:"name"`

// Specifies the mount point of the Downward API volume.
//
// +kubebuilder:validation:Required
// +kubebuilder:validation:MaxLength=128
MountPoint string `json:"mountPoint"`

// Represents a list of files under the Downward API volume.
//
// +kubebuilder:validation:Required
Items []corev1.DownwardAPIVolumeFile `json:"items"`

// Specifies the command to be triggered when changes are detected in Downward API volume files.
// It relies on the inotify mechanism in the config-manager sidecar to monitor file changes.
//
// +optional
Command []string `json:"command,omitempty"`

// ScriptConfig object specifies a ConfigMap that contains script files that should be mounted inside the pod.
// The scripts are mounted as volumes and can be referenced and executed by the DownwardAction to perform specific tasks or configurations.
//
// +optional
ScriptConfig *ScriptConfig `json:"scriptConfig,omitempty"`
}

type ScriptConfig struct {
// Specifies the reference to the ConfigMap containing the scripts.
//
Expand Down Expand Up @@ -441,49 +357,6 @@ type ShellTrigger struct {
// +optional
Sync *bool `json:"sync,omitempty"`

// Controls whether parameter updates are processed individually or collectively in a batch:
//
// - 'True': Processes all changes in one batch reload.
// - 'False': Processes each change individually.
//
// Defaults to 'False' if unspecified.
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 1.1.0"
// +optional
BatchReload *bool `json:"batchReload,omitempty"`

// Specifies a Go template string for formatting batch input data.
// It's used when `batchReload` is 'True' to format data passed into STDIN of the script.
// The template accesses key-value pairs of updated parameters via the '$' variable.
// This allows for custom formatting of the input data.
//
// Example template:
//
// ```yaml
// batchParamsFormatterTemplate: |-
// {{- range $pKey, $pValue := $ }}
// {{ printf "%s:%s" $pKey $pValue }}
// {{- end }}
// ```
//
// This example generates batch input data in a key:value format, sorted by keys.
// ```
// key1:value1
// key2:value2
// key3:value3
// ```
//
// If not specified, the default format is key=value, sorted by keys, for each updated parameter.
// ```
// key1=value1
// key2=value2
// key3=value3
// ```
//
// +kubebuilder:deprecatedversion:warning="This field has been deprecated since 1.1.0"
// +optional
BatchParamsFormatterTemplate string `json:"batchParamsFormatterTemplate,omitempty"`

// Specifies the tools container image used by ShellTrigger for dynamic reload.
// If the dynamic reload action is triggered by a ShellTrigger, this field is required.
// This image must contain all necessary tools for executing the ShellTrigger scripts.
Expand All @@ -502,24 +375,6 @@ type ShellTrigger struct {
ScriptConfig *ScriptConfig `json:"scriptConfig,omitempty"`
}

// TPLScriptTrigger Enables reloading process using a Go template script.
type TPLScriptTrigger struct {
// Specifies the ConfigMap that contains the script to be executed for reload.
//
ScriptConfig `json:",inline"`

// Determines whether parameter updates should be synchronized with the "config-manager".
// Specifies the controller's reload strategy:
//
// - If set to 'True', the controller executes the reload action in synchronous mode,
// pausing execution until the reload completes.
// - If set to 'False', the controller executes the reload action in asynchronous mode,
// updating the ConfigMap without waiting for the reload process to finish.
//
// +optional
Sync *bool `json:"sync,omitempty"`
}

// AutoTrigger automatically perform the reload when specified conditions are met.
type AutoTrigger struct {
// The name of the process.
Expand Down
76 changes: 0 additions & 76 deletions apis/parameters/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,6 @@ limitations under the License.

package v1alpha1

// DynamicParameterSelectedPolicy determines how to select the parameters of dynamic reload actions
//
// +enum
// +kubebuilder:validation:Enum={all,dynamic}
type DynamicParameterSelectedPolicy string

const (
SelectedAllParameters DynamicParameterSelectedPolicy = "all"
SelectedDynamicParameters DynamicParameterSelectedPolicy = "dynamic"
)

// CfgFileFormat defines formatter of configuration files.
// +enum
// +kubebuilder:validation:Enum={xml,ini,yaml,json,hcl,dotenv,toml,properties,redis,props-plus,props-ultra}
Expand All @@ -46,58 +35,6 @@ const (
PropertiesUltra CfgFileFormat = "props-ultra"
)

// DynamicReloadType defines reload method.
// +enum
type DynamicReloadType string

const (
UnixSignalType DynamicReloadType = "signal" // deprecated since 1.1.0
SQLType DynamicReloadType = "sql"
ShellType DynamicReloadType = "exec"
HTTPType DynamicReloadType = "http"
TPLScriptType DynamicReloadType = "tpl"
AutoType DynamicReloadType = "auto"
)

// SignalType defines which signals are valid.
// +enum
// +kubebuilder:validation:Enum={SIGHUP,SIGINT,SIGQUIT,SIGILL,SIGTRAP,SIGABRT,SIGBUS,SIGFPE,SIGKILL,SIGUSR1,SIGSEGV,SIGUSR2,SIGPIPE,SIGALRM,SIGTERM,SIGSTKFLT,SIGCHLD,SIGCONT,SIGSTOP,SIGTSTP,SIGTTIN,SIGTTOU,SIGURG,SIGXCPU,SIGXFSZ,SIGVTALRM,SIGPROF,SIGWINCH,SIGIO,SIGPWR,SIGSYS}
type SignalType string

const (
SIGHUP SignalType = "SIGHUP"
SIGINT SignalType = "SIGINT"
SIGQUIT SignalType = "SIGQUIT"
SIGILL SignalType = "SIGILL"
SIGTRAP SignalType = "SIGTRAP"
SIGABRT SignalType = "SIGABRT"
SIGBUS SignalType = "SIGBUS"
SIGFPE SignalType = "SIGFPE"
SIGKILL SignalType = "SIGKILL"
SIGUSR1 SignalType = "SIGUSR1"
SIGSEGV SignalType = "SIGSEGV"
SIGUSR2 SignalType = "SIGUSR2"
SIGPIPE SignalType = "SIGPIPE"
SIGALRM SignalType = "SIGALRM"
SIGTERM SignalType = "SIGTERM"
SIGSTKFLT SignalType = "SIGSTKFLT"
SIGCHLD SignalType = "SIGCHLD"
SIGCONT SignalType = "SIGCONT"
SIGSTOP SignalType = "SIGSTOP"
SIGTSTP SignalType = "SIGTSTP"
SIGTTIN SignalType = "SIGTTIN"
SIGTTOU SignalType = "SIGTTOU"
SIGURG SignalType = "SIGURG"
SIGXCPU SignalType = "SIGXCPU"
SIGXFSZ SignalType = "SIGXFSZ"
SIGVTALRM SignalType = "SIGVTALRM"
SIGPROF SignalType = "SIGPROF"
SIGWINCH SignalType = "SIGWINCH"
SIGIO SignalType = "SIGIO"
SIGPWR SignalType = "SIGPWR"
SIGSYS SignalType = "SIGSYS"
)

// ParametersDescPhase defines the ParametersDescription CR .status.phase
// +enum
// +kubebuilder:validation:Enum={Available,Unavailable, Deleting}
Expand Down Expand Up @@ -165,19 +102,6 @@ type ParametersInFile struct {
Parameters map[string]*string `json:"parameters,omitempty"`
}

// ReloadPolicy defines the policy of reconfiguring.
// +enum
// +kubebuilder:validation:Enum={none,restart,asyncReload,syncReload,dynamicReloadBeginRestart}
type ReloadPolicy string

const (
NonePolicy ReloadPolicy = "none"
RestartPolicy ReloadPolicy = "restart"
AsyncDynamicReloadPolicy ReloadPolicy = "asyncReload"
SyncDynamicReloadPolicy ReloadPolicy = "syncReload"
DynamicReloadAndRestartPolicy ReloadPolicy = "dynamicReloadBeginRestart"
)

type ComponentParameters map[string]*string

// MergedPolicy defines how to merge external imported templates into component templates.
Expand Down
Loading
Loading