ClickHouseOperatorConfiguration watch.namespaces.include is overwritten by env WATCH_NAMESPACE in OLM installation
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- go, kubernetes
調査の方向性
pkg/chop/config_manager.go から始めて Postprocess() を追跡し、次に pkg/apis/clickhouse.altinity.com/v1/type_configuration_chop.go の applyEnvVarParams() を調査します。WATCH_NAMESPACE と spec.watch.namespaces.include の意図された優先順位を特定し、最終的な設定で明示的に構成された CR の値が保持されるか、環境変数の優先順位が文書化されていることを確認します。
索引モデルが issue の本文から書いたものです。
説明
Description
When ClickHouse Operator is installed via OLM, the generated CSV contains the following environment variable:
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
As a result, the operator pod starts with:
WATCH_NAMESPACE=openshift-operators
I created a ClickHouseOperatorConfiguration resource to enable watch-all mode:
apiVersion: clickhouse.altinity.com/v1
kind: ClickHouseOperatorConfiguration
metadata:
name: watch-all-namespaces
namespace: openshift-operators
spec:
watch:
namespaces:
include:
- ".*"
According to the default operator configuration template, [".*"] should force watch-all mode:
Observed behavior
The operator successfully discovers and loads the ClickHouseOperatorConfiguration resource:
I0615 12:13:42.047018 1 config_manager.go:150] getAllCRBasedConfigs():Looking for ClickHouseOperatorConfigurations in namespace 'openshift-operators'.
I0615 12:13:43.086423 1 config_manager.go:183] getAllCRBasedConfigs():Append ClickHouseOperatorConfigurations 'openshift-operators/watch-all-namespaces'.
The CR-based configuration contains the expected value:
watch:
namespaces:
include:
- .*
The merged configuration also contains the expected value:
Unified CHOP config - with secret data fetched (but not post-processed yet)
runtime:
configFilePath: /etc/clickhouse-operator/config.yaml
configFolderPath: /etc/clickhouse-operator
configCRNamespace: openshift-operators
configCRName: watch-all-namespaces
configCRSources:
- namespace: openshift-operators
name: watch-all-namespaces
namespace: ""
watch:
namespaces:
include:
- .*
However, after post-processing, the final configuration changes to:
Final CHOP config
runtime:
configFilePath: /etc/clickhouse-operator/config.yaml
configFolderPath: /etc/clickhouse-operator
configCRNamespace: openshift-operators
configCRName: watch-all-namespaces
configCRSources:
- namespace: openshift-operators
name: watch-all-namespaces
namespace: openshift-operators
watch:
namespaces:
include:
- openshift-operators
As a result, ClickHouseInstallation resources created in other namespaces are not reconciled.
Investigation
The operator calls Postprocess() between the "Unified CHOP config" and "Final CHOP config" stages:
https://github.com/Altinity/clickhouse-operator/blob/release-0.27.1/pkg/chop/config_manager.go#L129
log.V(1).Info("Unified CHOP config - with secret data fetched (but not post-processed yet):")
log.V(1).Info("\n" + cm.config.String(true))
cm.Postprocess()
log.V(1).Info("Final CHOP config:")
log.V(1).Info("\n" + cm.config.String(true))
Postprocess() invokes applyEnvVarParams():
func (c *OperatorConfig) applyEnvVarParams() {
if ns := os.Getenv(deployment.WATCH_NAMESPACE); len(ns) > 0 {
// We have WATCH_NAMESPACE explicitly specified
c.Watch.Namespaces.Include = types.NewStrings([]string{ns})
}
if nss := os.Getenv(deployment.WATCH_NAMESPACES); len(nss) > 0 {
// We have WATCH_NAMESPACES explicitly specified
if namespaces := c.splitNamespaces(nss); len(namespaces) > 0 {
c.Watch.Namespaces.Include = types.NewStrings(namespaces)
}
}
if nss := os.Getenv(deployment.WATCH_NAMESPACES_EXCLUDE); len(nss) > 0 {
// We have WATCH_NAMESPACES_EXCLUDE explicitly specified
if namespaces := c.splitNamespaces(nss); len(namespaces) > 0 {
c.Watch.Namespaces.Exclude = types.NewStrings(namespaces)
}
}
}
This appears to overwrite the value previously loaded from ClickHouseOperatorConfiguration.
Expected behavior
If spec.watch.namespaces.include is explicitly configured in ClickHouseOperatorConfiguration, it should remain unchanged during post-processing.
Alternatively, if WATCH_NAMESPACE is expected to have higher priority in OLM deployments, this behavior should be documented explicitly.
Question
Is this expected behavior for OLM installations, or is this a configuration precedence issue?
Environment
- RedHat OpenShift cluster version 4.20.19
- Operator installed from OLM Community Operators
- Altinity® Kubernetes Operator for ClickHouse version 0.27.1
- 主要言語
- Go
- スター
- 2.6k
- フォーク
- 584
- 平均マージ
- 4日 5時間
- マージ済み PR(30日)
- 16
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Altinity/clickhouse-operator のほかの issue
-
Counter metrics are missing the conventional _total suffix対応中かも @mehrdadbn9 が 29 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Altinity/clickhouse-operator#2093 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
ClickHouseBackup CR provides no way to configure pod labels/attributes and other fields対応中かも @Slach が 2 日前に担当しました。 オープン
Altinity/clickhouse-operator#2141 · コメント 1 件 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
Altinity/clickhouse-operator#2140 ·
メンテナーはふだん 2 日以内に返信
-
Metrics exporter publishes NaN for per CPU, disk and network metrics on ClickHouse 26.8対応中かも @Slach が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
Altinity/clickhouse-operator#2135 · 担当者 1 名 ·
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
Altinity/clickhouse-operator#2129 ·
メンテナーはふだん 2 日以内に返信
Altinity/clickhouse-operator の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
router-for-me/CLIProxyAPI#7330 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
bug os:ios
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
hajimehoshi/ebiten#4039 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 9 日以内に返信