8000 Restart operator on operator configuration change by alex-zaitsev · Pull Request #1960 · Altinity/clickhouse-operator · GitHub
[go: up one dir, main page]

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
5 changes: 5 additions & 0 deletions cmd/operator/app/thread_chi.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ func initClickHouse(ctx context.Context) {
chop.New(kubeClient, chopClient, chopConfigFile)
log.V(1).F().Info("Config parsed:")
log.Info("\n" + chop.Config().String(true))
if chop.Config().RestartOnOperatorConfigurationChange() {
log.Info("Auto-restart on ClickHouseOperatorConfiguration change is enabled")
} else {
log.Info("Auto-restart on ClickHouseOperatorConfiguration change is disabled")
}

// Log namespace deny list configuration
if chop.Config().Watch.Namespaces.Exclude.Len() > 0 {
Expand Down
4 changes: 4 additions & 0 deletions config/config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ watch:
include: [dev, test]
exclude: []

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
################################################
Expand Down
4 changes: 4 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ watch:
# Regexp is applicable.
namespaces: []

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
################################################
Expand Down
4 changes: 4 additions & 0 deletions deploy/builder/templates-config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ watch:
# Regexp is applicable.
namespaces: [${WATCH_NAMESPACES}]

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down
11 changes: 10 additions & 1 deletion deploy/helm/clickhouse-operator/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,16 @@
"type": "object",
"properties": {
"namespaces": {
"type": "array"
"type": ["array", "object"]
},
"configuration": {
"type": "object",
"properties": {
"onChange": {
"type": "string",
"enum": ["none", "restart"]
}
}
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions deploy/helm/clickhouse-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ configs:
# IMPORTANT
# Regexp is applicable.
namespaces: []

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart
clickhouse:
configuration:
################################################
Expand Down
14 changes: 14 additions & 0 deletions deploy/operator/clickhouse-operator-install-ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3283,6 +3283,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down Expand Up @@ -5072,6 +5082,10 @@ data:
# IMPORTANT
# Regexp is applicable.
namespaces: [{{ namespace }}]

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
Expand Down
16 changes: 14 additions & 2 deletions deploy/operator/clickhouse-operator-install-bundle-v1beta1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3250,6 +3250,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down Expand Up @@ -4722,7 +4732,6 @@ metadata:
namespace: kube-system
labels:
clickhouse.altinity.com/chop: 0.27.0

# Template Parameters:
#
# NAMESPACE=kube-system
Expand Down Expand Up @@ -4975,7 +4984,6 @@ subjects:
- kind: ServiceAccount
name: clickhouse-operator
namespace: kube-system

# Template Parameters:
#
# NAMESPACE=kube-system
Expand Down Expand Up @@ -5272,6 +5280,10 @@ data:
# Regexp is applicable.
namespaces: []

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
################################################
Expand Down
14 changes: 14 additions & 0 deletions deploy/operator/clickhouse-operator-install-bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3276,6 +3276,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down Expand Up @@ -5331,6 +5341,10 @@ data:
# IMPORTANT
# Regexp is applicable.
namespaces: []

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3250,6 +3250,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down Expand Up @@ -4722,7 +4732,6 @@ metadata:
namespace: ${OPERATOR_NAMESPACE}
labels:
clickhouse.altinity.com/chop: 0.27.0

# Template Parameters:
#
# NAMESPACE=${OPERATOR_NAMESPACE}
Expand Down Expand Up @@ -5019,6 +5028,10 @@ data:
# Regexp is applicable.
namespaces: []

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
################################################
Expand Down
14 changes: 14 additions & 0 deletions deploy/operator/clickhouse-operator-install-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3276,6 +3276,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down Expand Up @@ -5065,6 +5075,10 @@ data:
# IMPORTANT
# Regexp is applicable.
namespaces: []

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
Expand Down
14 changes: 14 additions & 0 deletions deploy/operator/clickhouse-operator-install-tf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3283,6 +3283,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down Expand Up @@ -5072,6 +5082,10 @@ data:
# IMPORTANT
# Regexp is applicable.
namespaces: [${namespace}]

# Behavior when ClickHouseOperatorConfiguration changes: none | restart
configuration:
onChange: restart

clickhouse:
configuration:
Expand Down
10 changes: 10 additions & 0 deletions deploy/operator/parts/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8224,6 +8224,16 @@ spec:
type: object
description: "List of namespaces where clickhouse-operator watches for events."
x-kubernetes-preserve-unknown-fields: true
configuration:
type: object
description: "Behavior when ClickHouseOperatorConfiguration resources change"
properties:
onChange:
type: string
enum:
- none
- restart
description: "none — ignore; restart — exit process so the operator pod restarts"
clickhouse:
type: object
description: "Clickhouse related parameters used by clickhouse-operator"
Expand Down
15 changes: 15 additions & 0 deletions pkg/apis/clickhouse.altinity.com/v1/type_configuration_chop.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ type OperatorConfigRuntime struct {
type OperatorConfigWatch struct {
// Namespaces where operator watches for events
Namespaces OperatorConfigWatchNamespaces `json:"namespaces" yaml:"namespaces"`

// Configuration specifies behavior related to ClickHouseOperatorConfiguration watches
Configuration OperatorConfigWatchConfiguration `json:"configuration,omitempty" yaml:"configuration,omitempty"`
}

// OperatorConfigWatchConfiguration specifies behavior when operator-wide configuration changes.
type OperatorConfigWatchConfiguration struct {
// OnChange controls reaction to ClickHouseOperatorConfiguration changes: "none" or "restart".
OnChange string `json:"onChange,omitempty" yaml:"onChange,omitempty"`
}

type OperatorConfigWatchNamespaces struct {
Expand Down Expand Up @@ -1407,6 +1416,12 @@ func (c *OperatorConfig) copyWithHiddenCredentials() *OperatorConfig {
return conf
}

// RestartOnOperatorConfigurationChange reports whether the operator process should exit when
// ClickHouseOperatorConfiguration changes (so the pod restarts).
func (c *OperatorConfig) RestartOnOperatorConfigurationChange() bool {
return strings.ToLower(c.Watch.Configuration.OnChange) == "restart"
}

// IsNamespaceWatched returns whether specified namespace is in a list of watched
// TODO unify with GetInformerNamespace
func (c *OperatorConfig) IsNamespaceWatched(namespace string) bool {
Expand Down
Loading
Loading
0