From 2c3f8e964b9c6e9db86e7dd1af78adda4732c1fb Mon Sep 17 00:00:00 2001 From: Ivan Sokoryan Date: Tue, 18 Jun 2024 08:31:23 +0500 Subject: [PATCH 1/4] changed --- cmd/main.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/main.go b/cmd/main.go index 0b48ac863..85c73a199 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -20,6 +20,8 @@ var ( outOfCluster bool version string config spec.ControllerConfig + kubeQPS int + kubeBurst int ) func mustParseDuration(d string) time.Duration { @@ -35,6 +37,8 @@ func init() { flag.BoolVar(&outOfCluster, "outofcluster", false, "Whether the operator runs in- our outside of the Kubernetes cluster.") flag.BoolVar(&config.NoDatabaseAccess, "nodatabaseaccess", false, "Disable all access to the database from the operator side.") flag.BoolVar(&config.NoTeamsAPI, "noteamsapi", false, "Disable all access to the teams API") + flag.IntVar(&kubeQPS, "kubeqps", 5, "Kubernetes api requests per second.") + flag.IntVar(&kubeBurst, "kubeburst", 10, "Kubernetes api requests burst limit.") flag.Parse() config.EnableJsonLogging = os.Getenv("ENABLE_JSON_LOGGING") == "true" @@ -83,6 +87,9 @@ func main() { log.Fatalf("couldn't get REST config: %v", err) } + config.RestConfig.QPS = float32(kubeQPS) + config.RestConfig.Burst = kubeBurst + c := controller.NewController(&config, "") c.Run(stop, wg) From 4407dcea2f05f2700df75205d858b1124d7b949e Mon Sep 17 00:00:00 2001 From: Ivan Sokoryan Date: Mon, 8 Jul 2024 20:39:25 +0500 Subject: [PATCH 2/4] changed --- charts/postgres-operator/crds/operatorconfigurations.yaml | 4 ++++ cmd/main.go | 7 ------- pkg/apis/acid.zalan.do/v1/crds.go | 6 ++++++ pkg/apis/acid.zalan.do/v1/operator_configuration_type.go | 2 ++ pkg/controller/controller.go | 4 ++++ pkg/controller/operator_config.go | 2 ++ pkg/util/config/config.go | 2 ++ 7 files changed, 20 insertions(+), 7 deletions(-) diff --git a/charts/postgres-operator/crds/operatorconfigurations.yaml b/charts/postgres-operator/crds/operatorconfigurations.yaml index bf4ae34b1..b1ae9470c 100644 --- a/charts/postgres-operator/crds/operatorconfigurations.yaml +++ b/charts/postgres-operator/crds/operatorconfigurations.yaml @@ -368,6 +368,10 @@ spec: type: string watched_namespace: type: string + kube_qps: + type: integer + kube_burst: + type: integer postgres_pod_resources: type: object properties: diff --git a/cmd/main.go b/cmd/main.go index 85c73a199..0b48ac863 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -20,8 +20,6 @@ var ( outOfCluster bool version string config spec.ControllerConfig - kubeQPS int - kubeBurst int ) func mustParseDuration(d string) time.Duration { @@ -37,8 +35,6 @@ func init() { flag.BoolVar(&outOfCluster, "outofcluster", false, "Whether the operator runs in- our outside of the Kubernetes cluster.") flag.BoolVar(&config.NoDatabaseAccess, "nodatabaseaccess", false, "Disable all access to the database from the operator side.") flag.BoolVar(&config.NoTeamsAPI, "noteamsapi", false, "Disable all access to the teams API") - flag.IntVar(&kubeQPS, "kubeqps", 5, "Kubernetes api requests per second.") - flag.IntVar(&kubeBurst, "kubeburst", 10, "Kubernetes api requests burst limit.") flag.Parse() config.EnableJsonLogging = os.Getenv("ENABLE_JSON_LOGGING") == "true" @@ -87,9 +83,6 @@ func main() { log.Fatalf("couldn't get REST config: %v", err) } - config.RestConfig.QPS = float32(kubeQPS) - config.RestConfig.Burst = kubeBurst - c := controller.NewController(&config, "") c.Run(stop, wg) diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 9e65869e7..4f8ae99f0 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -1558,6 +1558,12 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{ "watched_namespace": { Type: "string", }, + "kube_qps": { + Type: "integer", + }, + "kube_burst": { + Type: "integer", + }, }, }, "patroni": { diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index 48fd0a13c..ba2f69c79 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -107,6 +107,8 @@ type KubernetesMetaConfiguration struct { EnableReadinessProbe bool `json:"enable_readiness_probe,omitempty"` EnableCrossNamespaceSecret bool `json:"enable_cross_namespace_secret,omitempty"` EnableFinalizers *bool `json:"enable_finalizers,omitempty"` + KubeQPS int `json:"kube_qps,omitempty"` + KubeBurst int `json:"kube_burst,omitempty"` } // PostgresPodResourcesDefaults defines the spec of default resources diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index e46b9ee44..5d1f94265 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -186,6 +186,10 @@ func (c *Controller) modifyConfigFromEnvironment() { if c.config.NoTeamsAPI { c.opConfig.EnableTeamsAPI = false } + + c.config.RestConfig.QPS = float32(c.opConfig.KubeQPS) + c.config.RestConfig.Burst = c.opConfig.KubeBurst + scalyrAPIKey := os.Getenv("SCALYR_API_KEY") if scalyrAPIKey != "" { c.opConfig.ScalyrAPIKey = scalyrAPIKey diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 88f1d73c0..7cc247411 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -130,6 +130,8 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.PodAntiAffinityTopologyKey = util.Coalesce(fromCRD.Kubernetes.PodAntiAffinityTopologyKey, "kubernetes.io/hostname") result.PodAntiAffinityPreferredDuringScheduling = fromCRD.Kubernetes.PodAntiAffinityPreferredDuringScheduling result.PodToleration = fromCRD.Kubernetes.PodToleration + result.KubeQPS = util.CoalesceInt(fromCRD.Kubernetes.KubeQPS, 5) + result.KubeBurst = util.CoalesceInt(fromCRD.Kubernetes.KubeBurst, 10) // Postgres Pod resources result.DefaultCPURequest = fromCRD.PostgresPodResources.DefaultCPURequest diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index 829c1d19e..da70fcb1d 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -253,6 +253,8 @@ type Config struct { EnableSecretsDeletion *bool `name:"enable_secrets_deletion" default:"true"` EnablePersistentVolumeClaimDeletion *bool `name:"enable_persistent_volume_claim_deletion" default:"true"` PersistentVolumeClaimRetentionPolicy map[string]string `name:"persistent_volume_claim_retention_policy" default:"when_deleted:retain,when_scaled:retain"` + KubeQPS int `name:"kube_qps" default:"5"` + KubeBurst int `name:"kube_burst" default:"10"` } // MustMarshal marshals the config or panics From 7c57ddf672e873cef30cabe4ed53c93078faac7c Mon Sep 17 00:00:00 2001 From: Ivan Sokoryan Date: Tue, 9 Jul 2024 11:23:14 +0500 Subject: [PATCH 3/4] revert-changes --- charts/postgres-operator/crds/operatorconfigurations.yaml | 4 ---- cmd/main.go | 5 +++++ pkg/apis/acid.zalan.do/v1/crds.go | 6 ------ pkg/apis/acid.zalan.do/v1/operator_configuration_type.go | 2 -- pkg/controller/controller.go | 4 ---- pkg/controller/operator_config.go | 2 -- pkg/spec/types.go | 3 +++ pkg/util/config/config.go | 2 -- 8 files changed, 8 insertions(+), 20 deletions(-) diff --git a/charts/postgres-operator/crds/operatorconfigurations.yaml b/charts/postgres-operator/crds/operatorconfigurations.yaml index b1ae9470c..bf4ae34b1 100644 --- a/charts/postgres-operator/crds/operatorconfigurations.yaml +++ b/charts/postgres-operator/crds/operatorconfigurations.yaml @@ -368,10 +368,6 @@ spec: type: string watched_namespace: type: string - kube_qps: - type: integer - kube_burst: - type: integer postgres_pod_resources: type: object properties: diff --git a/cmd/main.go b/cmd/main.go index 0b48ac863..0e7b2eb53 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -35,6 +35,8 @@ func init() { flag.BoolVar(&outOfCluster, "outofcluster", false, "Whether the operator runs in- our outside of the Kubernetes cluster.") flag.BoolVar(&config.NoDatabaseAccess, "nodatabaseaccess", false, "Disable all access to the database from the operator side.") flag.BoolVar(&config.NoTeamsAPI, "noteamsapi", false, "Disable all access to the teams API") + flag.IntVar(&config.KubeQPS, "kubeqps", 5, "Kubernetes api requests per second.") + flag.IntVar(&config.KubeBurst, "kubeburst", 10, "Kubernetes api requests burst limit.") flag.Parse() config.EnableJsonLogging = os.Getenv("ENABLE_JSON_LOGGING") == "true" @@ -83,6 +85,9 @@ func main() { log.Fatalf("couldn't get REST config: %v", err) } + config.RestConfig.QPS = float32(config.KubeQPS) + config.RestConfig.Burst = config.KubeBurst + c := controller.NewController(&config, "") c.Run(stop, wg) diff --git a/pkg/apis/acid.zalan.do/v1/crds.go b/pkg/apis/acid.zalan.do/v1/crds.go index 4f8ae99f0..9e65869e7 100644 --- a/pkg/apis/acid.zalan.do/v1/crds.go +++ b/pkg/apis/acid.zalan.do/v1/crds.go @@ -1558,12 +1558,6 @@ var OperatorConfigCRDResourceValidation = apiextv1.CustomResourceValidation{ "watched_namespace": { Type: "string", }, - "kube_qps": { - Type: "integer", - }, - "kube_burst": { - Type: "integer", - }, }, }, "patroni": { diff --git a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go index ba2f69c79..48fd0a13c 100644 --- a/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go +++ b/pkg/apis/acid.zalan.do/v1/operator_configuration_type.go @@ -107,8 +107,6 @@ type KubernetesMetaConfiguration struct { EnableReadinessProbe bool `json:"enable_readiness_probe,omitempty"` EnableCrossNamespaceSecret bool `json:"enable_cross_namespace_secret,omitempty"` EnableFinalizers *bool `json:"enable_finalizers,omitempty"` - KubeQPS int `json:"kube_qps,omitempty"` - KubeBurst int `json:"kube_burst,omitempty"` } // PostgresPodResourcesDefaults defines the spec of default resources diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 5d1f94265..e46b9ee44 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -186,10 +186,6 @@ func (c *Controller) modifyConfigFromEnvironment() { if c.config.NoTeamsAPI { c.opConfig.EnableTeamsAPI = false } - - c.config.RestConfig.QPS = float32(c.opConfig.KubeQPS) - c.config.RestConfig.Burst = c.opConfig.KubeBurst - scalyrAPIKey := os.Getenv("SCALYR_API_KEY") if scalyrAPIKey != "" { c.opConfig.ScalyrAPIKey = scalyrAPIKey diff --git a/pkg/controller/operator_config.go b/pkg/controller/operator_config.go index 7cc247411..88f1d73c0 100644 --- a/pkg/controller/operator_config.go +++ b/pkg/controller/operator_config.go @@ -130,8 +130,6 @@ func (c *Controller) importConfigurationFromCRD(fromCRD *acidv1.OperatorConfigur result.PodAntiAffinityTopologyKey = util.Coalesce(fromCRD.Kubernetes.PodAntiAffinityTopologyKey, "kubernetes.io/hostname") result.PodAntiAffinityPreferredDuringScheduling = fromCRD.Kubernetes.PodAntiAffinityPreferredDuringScheduling result.PodToleration = fromCRD.Kubernetes.PodToleration - result.KubeQPS = util.CoalesceInt(fromCRD.Kubernetes.KubeQPS, 5) - result.KubeBurst = util.CoalesceInt(fromCRD.Kubernetes.KubeBurst, 10) // Postgres Pod resources result.DefaultCPURequest = fromCRD.PostgresPodResources.DefaultCPURequest diff --git a/pkg/spec/types.go b/pkg/spec/types.go index cfa293e14..d727aee42 100644 --- a/pkg/spec/types.go +++ b/pkg/spec/types.go @@ -122,6 +122,9 @@ type ControllerConfig struct { IgnoredAnnotations []string EnableJsonLogging bool + + KubeQPS int + KubeBurst int } // cached value for the GetOperatorNamespace diff --git a/pkg/util/config/config.go b/pkg/util/config/config.go index da70fcb1d..829c1d19e 100644 --- a/pkg/util/config/config.go +++ b/pkg/util/config/config.go @@ -253,8 +253,6 @@ type Config struct { EnableSecretsDeletion *bool `name:"enable_secrets_deletion" default:"true"` EnablePersistentVolumeClaimDeletion *bool `name:"enable_persistent_volume_claim_deletion" default:"true"` PersistentVolumeClaimRetentionPolicy map[string]string `name:"persistent_volume_claim_retention_policy" default:"when_deleted:retain,when_scaled:retain"` - KubeQPS int `name:"kube_qps" default:"5"` - KubeBurst int `name:"kube_burst" default:"10"` } // MustMarshal marshals the config or panics From 648cd569c6794449b32dfe0ce6d2927dd504e704 Mon Sep 17 00:00:00 2001 From: Felix Kunde Date: Thu, 19 Dec 2024 12:01:35 +0100 Subject: [PATCH 4/4] increase qps and burst slightly --- cmd/main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 0e7b2eb53..adbf0cce5 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -35,8 +35,8 @@ func init() { flag.BoolVar(&outOfCluster, "outofcluster", false, "Whether the operator runs in- our outside of the Kubernetes cluster.") flag.BoolVar(&config.NoDatabaseAccess, "nodatabaseaccess", false, "Disable all access to the database from the operator side.") flag.BoolVar(&config.NoTeamsAPI, "noteamsapi", false, "Disable all access to the teams API") - flag.IntVar(&config.KubeQPS, "kubeqps", 5, "Kubernetes api requests per second.") - flag.IntVar(&config.KubeBurst, "kubeburst", 10, "Kubernetes api requests burst limit.") + flag.IntVar(&config.KubeQPS, "kubeqps", 10, "Kubernetes api requests per second.") + flag.IntVar(&config.KubeBurst, "kubeburst", 20, "Kubernetes api requests burst limit.") flag.Parse() config.EnableJsonLogging = os.Getenv("ENABLE_JSON_LOGGING") == "true"