From 3edde71d3be002e615e6dd378a8e661a264be009 Mon Sep 17 00:00:00 2001 From: Tvion Date: Wed, 8 Jul 2026 17:21:45 +0500 Subject: [PATCH 01/10] fix: formatting --- .github/linters/.jscpd.json | 14 +++++++------- operator/pkg/reconciler/patroni.go | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/linters/.jscpd.json b/.github/linters/.jscpd.json index 2ccd8d44..68717927 100644 --- a/.github/linters/.jscpd.json +++ b/.github/linters/.jscpd.json @@ -1,9 +1,9 @@ { - "threshold": 2, - "ignore": [ - "**/.git/**", - "**/charts/*/templates/*/*.yaml", - "**/charts/*/templates/*/*/*.yaml", - "**/docs/examples/**" - ] + "threshold": 2, + "ignore": [ + "**/.git/**", + "**/charts/*/templates/*/*.yaml", + "**/charts/*/templates/*/*/*.yaml", + "**/docs/examples/**" + ] } diff --git a/operator/pkg/reconciler/patroni.go b/operator/pkg/reconciler/patroni.go index e3c0d401..adc30c8e 100644 --- a/operator/pkg/reconciler/patroni.go +++ b/operator/pkg/reconciler/patroni.go @@ -267,7 +267,7 @@ func (r *PatroniReconciler) Reconcile() error { return err } if localeVersion != newLocaleVersion || cr.Spec.Patroni.ForceCollationVersionUpgrade { - logger.Warn(fmt.Sprintf("New os locale version is %s, but previous was %s. A collation version mismatch occured in databases. Run locale fix script", newLocaleVersion, localeVersion)) + logger.Warn(fmt.Sprintf("New os locale version is %s, but previous was %s. A collation version mismatch occurred in databases. Run locale fix script", newLocaleVersion, localeVersion)) err = r.runLocaleFixScript(pgVersion, newLocaleVersion, cr.Spec.Patroni.ForceCollationVersionUpgrade) if err != nil { return err @@ -685,7 +685,7 @@ func fixBrokenIndexes(pgClient *pgClient.PostgresClient, db string, brokenIndNam if len(remainingIndexes) > 0 { logger.Error(fmt.Sprintf("Broken indexes %v still present in db: %s", remainingIndexes, db)) - return fmt.Errorf("Broken indexes still present in db: %s", db) + return fmt.Errorf("broken indexes still present in db: %s", db) } logger.Info(fmt.Sprintf("Broken indexes fixed for db: %s", db)) From 226a19a400e518ba25993b7725028c8baee2bb3c Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 14:05:42 +0500 Subject: [PATCH 02/10] refactor: operator formatting --- operator/pkg/client/client.go | 2 +- operator/pkg/deployment/backup.go | 46 +++++++++---------- operator/pkg/deployment/monitoring.go | 8 ++-- operator/pkg/deployment/tests.go | 6 +-- operator/pkg/helper/patroni_core_helper.go | 2 +- operator/pkg/queryexporter/query_exporter.go | 4 +- operator/pkg/reconciler/backup_daemon.go | 16 +++---- .../replication_controller.go | 8 ++-- operator/pkg/util/util.go | 4 +- 9 files changed, 48 insertions(+), 48 deletions(-) diff --git a/operator/pkg/client/client.go b/operator/pkg/client/client.go index f945673f..8bd9d61f 100644 --- a/operator/pkg/client/client.go +++ b/operator/pkg/client/client.go @@ -34,7 +34,7 @@ import ( ) const ( - pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" + pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" ) var ( diff --git a/operator/pkg/deployment/backup.go b/operator/pkg/deployment/backup.go index 2f7dd1be..f49c8e71 100644 --- a/operator/pkg/deployment/backup.go +++ b/operator/pkg/deployment/backup.go @@ -78,7 +78,7 @@ func NewBackupDaemonDeployment(backupDaemon *netcrackerv1.BackupDaemon, pgCluste Name: "postgres-credentials", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: "postgres-credentials", + SecretName: "postgres-credentials", DefaultMode: ptr.To[int32](0400), }, }, @@ -87,7 +87,7 @@ func NewBackupDaemonDeployment(backupDaemon *netcrackerv1.BackupDaemon, pgCluste Name: "replicator-credentials", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: "replicator-credentials", + SecretName: "replicator-credentials", DefaultMode: ptr.To[int32](0400), }, }, @@ -297,28 +297,28 @@ func NewBackupDaemonDeployment(backupDaemon *netcrackerv1.BackupDaemon, pgCluste }, } } -// Add postgres-credentials volume regardless of storage type + // Add postgres-credentials volume regardless of storage type deployment.Spec.Template.Spec.Volumes = append( - deployment.Spec.Template.Spec.Volumes, - corev1.Volume{ - Name: "postgres-credentials", - VolumeSource: corev1.VolumeSource{ - Secret: &corev1.SecretVolumeSource{ - SecretName: GetRootSecretName(pgClusterName), - DefaultMode: ptr.To[int32](0400), - }, - }, - }, - corev1.Volume{ - Name: "replicator-credentials", - VolumeSource: corev1.VolumeSource{ - Secret: &corev1.SecretVolumeSource{ - SecretName: "replicator-credentials", - DefaultMode: ptr.To[int32](0400), - }, - }, - }, - ) + deployment.Spec.Template.Spec.Volumes, + corev1.Volume{ + Name: "postgres-credentials", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: GetRootSecretName(pgClusterName), + DefaultMode: ptr.To[int32](0400), + }, + }, + }, + corev1.Volume{ + Name: "replicator-credentials", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: "replicator-credentials", + DefaultMode: ptr.To[int32](0400), + }, + }, + }, + ) if backupDaemon.S3AliasesUsed { deployment.Spec.Template.Spec.Containers[0].Env = append( diff --git a/operator/pkg/deployment/monitoring.go b/operator/pkg/deployment/monitoring.go index 39c84199..813891d6 100644 --- a/operator/pkg/deployment/monitoring.go +++ b/operator/pkg/deployment/monitoring.go @@ -175,17 +175,17 @@ func NewMonitoringDeployment(metricCollector *netcrackerv1.MetricCollector, pgcl { MountPath: util.SecretsBasePath + "monitoring-user-credentials", Name: "monitoring-user-credentials", - ReadOnly: true, + ReadOnly: true, }, { MountPath: util.SecretsBasePath + "influx-db-admin-credentials", Name: "influx-db-admin-credentials", - ReadOnly: true, + ReadOnly: true, }, { MountPath: util.SecretsBasePath + "postgres-credentials", Name: "postgres-credentials", - ReadOnly: true, + ReadOnly: true, }, }, Resources: *metricCollector.Resources, @@ -222,7 +222,7 @@ func NewMonitoringDeployment(metricCollector *netcrackerv1.MetricCollector, pgcl }, }, } - + if metricCollector.PriorityClassName != "" { deployment.Spec.Template.Spec.PriorityClassName = metricCollector.PriorityClassName } diff --git a/operator/pkg/deployment/tests.go b/operator/pkg/deployment/tests.go index 0a128d9c..3315f188 100644 --- a/operator/pkg/deployment/tests.go +++ b/operator/pkg/deployment/tests.go @@ -75,7 +75,7 @@ func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniCl }, }, }, - InitContainers: []corev1.Container{}, + InitContainers: []corev1.Container{}, Containers: []corev1.Container{ { Name: name, @@ -190,7 +190,7 @@ func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.Patro Spec: corev1.PodSpec{ ServiceAccountName: cr.Spec.ServiceAccountName, Affinity: &testsSpec.Affinity, - Volumes: []corev1.Volume{ + Volumes: []corev1.Volume{ { Name: "postgres-credentials", VolumeSource: corev1.VolumeSource{ @@ -200,7 +200,7 @@ func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.Patro }, }, }, - InitContainers: []corev1.Container{}, + InitContainers: []corev1.Container{}, Containers: []corev1.Container{ { Name: name, diff --git a/operator/pkg/helper/patroni_core_helper.go b/operator/pkg/helper/patroni_core_helper.go index 9de7bff5..902a4f28 100644 --- a/operator/pkg/helper/patroni_core_helper.go +++ b/operator/pkg/helper/patroni_core_helper.go @@ -44,7 +44,7 @@ import ( var ( pHelper *PatroniHelper = nil - + secretFilePath = "/var/run/secrets/postgresql/" replicatorPasswordPath = secretFilePath + "replicator-credentials/" ) diff --git a/operator/pkg/queryexporter/query_exporter.go b/operator/pkg/queryexporter/query_exporter.go index 1f554746..ace8d754 100644 --- a/operator/pkg/queryexporter/query_exporter.go +++ b/operator/pkg/queryexporter/query_exporter.go @@ -33,8 +33,8 @@ import ( const ( CMName = "query-exporter-config" - - pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" + + pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" ) var ( diff --git a/operator/pkg/reconciler/backup_daemon.go b/operator/pkg/reconciler/backup_daemon.go index 1a5c43ac..b6339631 100644 --- a/operator/pkg/reconciler/backup_daemon.go +++ b/operator/pkg/reconciler/backup_daemon.go @@ -37,11 +37,11 @@ import ( ) const ( - extCMName = "postgres-external" - awsCredentialsSecretName = "aws-credentials" - awsCredentialsMountPath = "/var/run/secrets/postgresql/aws-credentials" + extCMName = "postgres-external" + awsCredentialsSecretName = "aws-credentials" + awsCredentialsMountPath = "/var/run/secrets/postgresql/aws-credentials" s3StorageCredentialsSecretName = "s3-storage-credentials" - s3StorageCredentialsMountPath = "/var/run/secrets/postgresql/s3-storage-credentials" + s3StorageCredentialsMountPath = "/var/run/secrets/postgresql/s3-storage-credentials" ) type BackupDaemonReconciler struct { @@ -173,7 +173,7 @@ func (r *BackupDaemonReconciler) Reconcile() error { Name: "aws-credentials", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: awsCredentialsSecretName, + SecretName: awsCredentialsSecretName, DefaultMode: ptr.To[int32](0400), }, }, @@ -182,7 +182,7 @@ func (r *BackupDaemonReconciler) Reconcile() error { append(backupDaemonDeployment.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{ Name: "aws-credentials", MountPath: awsCredentialsMountPath, - ReadOnly: true, + ReadOnly: true, }) backupDaemonDeployment.Spec.Template.Spec.Containers[0].Env = append(backupDaemonDeployment.Spec.Template.Spec.Containers[0].Env, r.getAWSEnv(cr.Spec.ExternalDataBase)...) @@ -197,14 +197,14 @@ func (r *BackupDaemonReconciler) Reconcile() error { append(backupDaemonDeployment.Spec.Template.Spec.Containers[0].VolumeMounts, corev1.VolumeMount{ Name: "s3-credentials", MountPath: s3StorageCredentialsMountPath, - ReadOnly: true, + ReadOnly: true, }) backupDaemonDeployment.Spec.Template.Spec.Volumes = append(backupDaemonDeployment.Spec.Template.Spec.Volumes, corev1.Volume{ Name: "s3-credentials", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: s3StorageCredentialsSecretName, + SecretName: s3StorageCredentialsSecretName, DefaultMode: ptr.To[int32](0400), }, }, diff --git a/operator/pkg/replicationcontroller/replication_controller.go b/operator/pkg/replicationcontroller/replication_controller.go index d4f227a1..941a4c48 100644 --- a/operator/pkg/replicationcontroller/replication_controller.go +++ b/operator/pkg/replicationcontroller/replication_controller.go @@ -58,7 +58,7 @@ func NewRCDeployment(cr v1.PatroniServices, sa, clusterName string, pgPort int) Spec: corev1.PodSpec{ ServiceAccountName: sa, Affinity: &spec.Affinity, - Volumes: []corev1.Volume{ + Volumes: []corev1.Volume{ { Name: "postgres-credentials", VolumeSource: corev1.VolumeSource{ @@ -78,7 +78,7 @@ func NewRCDeployment(cr v1.PatroniServices, sa, clusterName string, pgPort int) }, }, }, - InitContainers: []corev1.Container{}, + InitContainers: []corev1.Container{}, Containers: []corev1.Container{ { Name: deploymentName, @@ -122,12 +122,12 @@ func NewRCDeployment(cr v1.PatroniServices, sa, clusterName string, pgPort int) { MountPath: "/var/run/secrets/postgresql/replicator-api-creds", Name: "replicator-api-creds", - ReadOnly: true, + ReadOnly: true, }, { MountPath: "/var/run/secrets/postgresql/postgres-credentials", Name: "postgres-credentials", - ReadOnly: true, + ReadOnly: true, }, }, Ports: []corev1.ContainerPort{ diff --git a/operator/pkg/util/util.go b/operator/pkg/util/util.go index 82a7e768..94a5a836 100644 --- a/operator/pkg/util/util.go +++ b/operator/pkg/util/util.go @@ -56,7 +56,7 @@ import ( const ( TokenFilePath = "/var/run/secrets/kubernetes.io/serviceaccount/token" ClusterName = "patroni" - + SecretsBasePath = "/var/run/secrets/postgresql/" PgUserCredsPath = SecretsBasePath + "postgres-credentials/" ) @@ -488,4 +488,4 @@ func ReadSecretFile(path string, defaultVal string) string { return defaultVal } return value -} \ No newline at end of file +} From 979297c0721b54c3039b75e91811f8f7d8786389 Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 14:07:57 +0500 Subject: [PATCH 03/10] refactor: operator formatting --- operator/pkg/deployment/backup.go | 44 ++++++++++++------------ operator/pkg/reconciler/backup_daemon.go | 4 +-- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/operator/pkg/deployment/backup.go b/operator/pkg/deployment/backup.go index bd032bb5..1eca856a 100644 --- a/operator/pkg/deployment/backup.go +++ b/operator/pkg/deployment/backup.go @@ -78,7 +78,7 @@ func NewBackupDaemonDeployment(backupDaemon *netcrackerv1.BackupDaemon, pgCluste Name: "postgres-credentials", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: "postgres-credentials", + SecretName: "postgres-credentials", DefaultMode: ptr.To[int32](420), }, }, @@ -87,7 +87,7 @@ func NewBackupDaemonDeployment(backupDaemon *netcrackerv1.BackupDaemon, pgCluste Name: "replicator-credentials", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: "replicator-credentials", + SecretName: "replicator-credentials", DefaultMode: ptr.To[int32](420), }, }, @@ -299,26 +299,26 @@ func NewBackupDaemonDeployment(backupDaemon *netcrackerv1.BackupDaemon, pgCluste } // Add postgres-credentials volume regardless of storage type deployment.Spec.Template.Spec.Volumes = append( - deployment.Spec.Template.Spec.Volumes, - corev1.Volume{ - Name: "postgres-credentials", - VolumeSource: corev1.VolumeSource{ - Secret: &corev1.SecretVolumeSource{ - SecretName: GetRootSecretName(pgClusterName), - DefaultMode: ptr.To[int32](420), - }, - }, - }, - corev1.Volume{ - Name: "replicator-credentials", - VolumeSource: corev1.VolumeSource{ - Secret: &corev1.SecretVolumeSource{ - SecretName: "replicator-credentials", - DefaultMode: ptr.To[int32](420), - }, - }, - }, - ) + deployment.Spec.Template.Spec.Volumes, + corev1.Volume{ + Name: "postgres-credentials", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: GetRootSecretName(pgClusterName), + DefaultMode: ptr.To[int32](420), + }, + }, + }, + corev1.Volume{ + Name: "replicator-credentials", + VolumeSource: corev1.VolumeSource{ + Secret: &corev1.SecretVolumeSource{ + SecretName: "replicator-credentials", + DefaultMode: ptr.To[int32](420), + }, + }, + }, + ) if backupDaemon.S3AliasesUsed { deployment.Spec.Template.Spec.Containers[0].Env = append( diff --git a/operator/pkg/reconciler/backup_daemon.go b/operator/pkg/reconciler/backup_daemon.go index fc5831e3..8e5ac705 100644 --- a/operator/pkg/reconciler/backup_daemon.go +++ b/operator/pkg/reconciler/backup_daemon.go @@ -173,7 +173,7 @@ func (r *BackupDaemonReconciler) Reconcile() error { Name: "aws-credentials", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: awsCredentialsSecretName, + SecretName: awsCredentialsSecretName, DefaultMode: ptr.To[int32](420), }, }, @@ -204,7 +204,7 @@ func (r *BackupDaemonReconciler) Reconcile() error { Name: "s3-credentials", VolumeSource: corev1.VolumeSource{ Secret: &corev1.SecretVolumeSource{ - SecretName: s3StorageCredentialsSecretName, + SecretName: s3StorageCredentialsSecretName, DefaultMode: ptr.To[int32](420), }, }, From 6e4b6c7d7a6c7536f34d445ec0fb9470570aab3c Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 14:12:21 +0500 Subject: [PATCH 04/10] refactor: services formatting --- services/dbaas-adapter/adapter/main.go | 2 +- .../monitoring-agent/collector/pkg/initiate/initiate.go | 2 +- .../monitoring-agent/collector/pkg/postgres/client.go | 1 - services/monitoring-agent/collector/pkg/util/util.go | 4 ++-- services/pgbackrest-sidecar/pkg/utils/utils.go | 5 ++--- .../cmd/pgskipper-replication-controller/main.go | 8 ++++---- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/services/dbaas-adapter/adapter/main.go b/services/dbaas-adapter/adapter/main.go index c477782a..d25415e8 100644 --- a/services/dbaas-adapter/adapter/main.go +++ b/services/dbaas-adapter/adapter/main.go @@ -43,7 +43,7 @@ const ( secretsBasePath = "/var/run/secrets/postgresql/" - pgUserCredsPath = secretsBasePath + "postgres-credentials/" + pgUserCredsPath = secretsBasePath + "postgres-credentials/" adapterCredsPath = secretsBasePath + "dbaas-adapter-credentials/" registrationCredsPath = secretsBasePath + "dbaas-aggregator-registration-credentials/" ) diff --git a/services/monitoring-agent/collector/pkg/initiate/initiate.go b/services/monitoring-agent/collector/pkg/initiate/initiate.go index 73b1c3df..45a5b5e9 100644 --- a/services/monitoring-agent/collector/pkg/initiate/initiate.go +++ b/services/monitoring-agent/collector/pkg/initiate/initiate.go @@ -28,7 +28,7 @@ import ( const ( monitoringUserCredsPath = util.SecretsBasePath + "monitoring-user-credentials/" - pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" + pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" ) var ( diff --git a/services/monitoring-agent/collector/pkg/postgres/client.go b/services/monitoring-agent/collector/pkg/postgres/client.go index 5c19f20c..921a38a0 100644 --- a/services/monitoring-agent/collector/pkg/postgres/client.go +++ b/services/monitoring-agent/collector/pkg/postgres/client.go @@ -28,7 +28,6 @@ import ( const ( pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" - ) var logger = util.GetLogger() diff --git a/services/monitoring-agent/collector/pkg/util/util.go b/services/monitoring-agent/collector/pkg/util/util.go index 1207a02d..929addf4 100644 --- a/services/monitoring-agent/collector/pkg/util/util.go +++ b/services/monitoring-agent/collector/pkg/util/util.go @@ -61,7 +61,7 @@ var ( const ( SecretsBasePath = "/var/run/secrets/postgresql/" - certificatesFolder = "/certs" + certificatesFolder = "/certs" metricCollectorCredentialsFolder = SecretsBasePath + "monitoring-user-credentials/" ) @@ -105,7 +105,7 @@ func ReadSecretFile(path string, defaultVal string) string { } value := strings.TrimSpace(string(data[:])) - + if value == "" { Log.Info(fmt.Sprintf("Secret file %s is empty, using default value", path)) return defaultVal diff --git a/services/pgbackrest-sidecar/pkg/utils/utils.go b/services/pgbackrest-sidecar/pkg/utils/utils.go index b3fadc26..0a765cab 100644 --- a/services/pgbackrest-sidecar/pkg/utils/utils.go +++ b/services/pgbackrest-sidecar/pkg/utils/utils.go @@ -21,7 +21,6 @@ import ( "os" "os/exec" "strings" - "go.uber.org/zap" "go.uber.org/zap/zapcore" @@ -99,10 +98,10 @@ func ReadSecretFile(path, defaultVal string) string { } value := strings.TrimSpace(string(data[:])) - + if value == "" { logger.Info(fmt.Sprintf("Secret file %s is empty, using default value", path)) return defaultVal } return value -} \ No newline at end of file +} diff --git a/services/replication-controller/cmd/pgskipper-replication-controller/main.go b/services/replication-controller/cmd/pgskipper-replication-controller/main.go index 696623f7..801d2e0d 100644 --- a/services/replication-controller/cmd/pgskipper-replication-controller/main.go +++ b/services/replication-controller/cmd/pgskipper-replication-controller/main.go @@ -37,11 +37,11 @@ const ( usersPath = "/users" httpsPort = 8443 - + secretsBasePath = "/var/run/secrets/postgresql/" - - pgUserCredsPath = secretsBasePath + "postgres-credentials/" - apiUserCredsPath = secretsBasePath + "logical-repl-credentials/" + + pgUserCredsPath = secretsBasePath + "postgres-credentials/" + apiUserCredsPath = secretsBasePath + "logical-repl-credentials/" ) var ( From 6b78727eccd70dfa549dd3ea8fcc27514d8c9e74 Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 14:36:22 +0500 Subject: [PATCH 05/10] refactor: fix linter --- operator/pkg/deployment/backup.go | 5 ++--- operator/pkg/helper/patroni_core_helper.go | 6 +++--- operator/pkg/helper/resource_management.go | 2 +- operator/pkg/queryexporter/query_exporter.go | 9 --------- services/backup-daemon/maintenance/recovery/utils_oc.py | 2 +- services/dbaas-adapter/adapter/basic/basic.go | 2 +- services/dbaas-adapter/adapter/main.go | 2 +- 7 files changed, 9 insertions(+), 19 deletions(-) diff --git a/operator/pkg/deployment/backup.go b/operator/pkg/deployment/backup.go index 1eca856a..92a6b0b3 100644 --- a/operator/pkg/deployment/backup.go +++ b/operator/pkg/deployment/backup.go @@ -19,7 +19,6 @@ import ( netcrackerv1 "github.com/Netcracker/pgskipper-operator/api/apps/v1" "github.com/Netcracker/pgskipper-operator/pkg/storage" - "github.com/Netcracker/pgskipper-operator/pkg/util" opUtils "github.com/Netcracker/pgskipper-operator/pkg/util" "github.com/Netcracker/qubership-credential-manager/pkg/utils" appsv1 "k8s.io/api/apps/v1" @@ -224,11 +223,11 @@ func NewBackupDaemonDeployment(backupDaemon *netcrackerv1.BackupDaemon, pgCluste Name: "backup-data", }, { - MountPath: util.SecretsBasePath + "postgres-credentials", + MountPath: opUtils.SecretsBasePath + "postgres-credentials", Name: "postgres-credentials", }, { - MountPath: util.SecretsBasePath + "replicator-credentials", + MountPath: opUtils.SecretsBasePath + "replicator-credentials", Name: "replicator-credentials", }, }, diff --git a/operator/pkg/helper/patroni_core_helper.go b/operator/pkg/helper/patroni_core_helper.go index 902a4f28..538c3aae 100644 --- a/operator/pkg/helper/patroni_core_helper.go +++ b/operator/pkg/helper/patroni_core_helper.go @@ -19,6 +19,7 @@ import ( "context" genericerror "errors" "fmt" + "slices" "strconv" "strings" "time" @@ -38,7 +39,6 @@ import ( "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "k8s.io/client-go/tools/remotecommand" - "k8s.io/utils/strings/slices" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -201,7 +201,7 @@ func (ph *PatroniHelper) isExpectedReplicationCount(pgHost string, count int) bo } pids = append(pids, pid) } - logger.Debug(fmt.Sprintf("Pids with streaming state: %d Lenght: %d. Expected %d", pids, len(pids), count)) + logger.Debug(fmt.Sprintf("Pids with streaming state: %d Length: %d. Expected %d", pids, len(pids), count)) return len(pids) >= count } return false @@ -631,7 +631,7 @@ func (ph *PatroniHelper) StoreDataToCM(key string, value string) { if err == nil { deploymentInfoCM.Data[key] = strings.TrimSpace(value) } else { - logger.Warn("Cant to find config map deployment-info for update. Creating new one", zap.Error(err)) + logger.Warn("Can't to find config map deployment-info for update. Creating new one", zap.Error(err)) deploymentInfoCM = &v1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Name: "deployment-info", diff --git a/operator/pkg/helper/resource_management.go b/operator/pkg/helper/resource_management.go index 1516dfbd..c4428cc9 100644 --- a/operator/pkg/helper/resource_management.go +++ b/operator/pkg/helper/resource_management.go @@ -708,7 +708,7 @@ func (rm *ResourceManager) UpdatePatroniConfigMaps(clusterName string) error { if err != nil { return err } - cmap.ObjectMeta.OwnerReferences = rm.GetOwnerReferences() + cmap.OwnerReferences = rm.GetOwnerReferences() _, err = rm.CreateOrUpdateManagedConfigMap(cmap) return err }) diff --git a/operator/pkg/queryexporter/query_exporter.go b/operator/pkg/queryexporter/query_exporter.go index ace8d754..ac1fae14 100644 --- a/operator/pkg/queryexporter/query_exporter.go +++ b/operator/pkg/queryexporter/query_exporter.go @@ -183,15 +183,6 @@ func getEnvVariables(spec v1.QueryExporter) []corev1.EnvVar { } } -func getSecretFieldEnv(fieldName string) *corev1.EnvVarSource { - return &corev1.EnvVarSource{ - SecretKeyRef: &corev1.SecretKeySelector{ - LocalObjectReference: corev1.LocalObjectReference{Name: expSec}, - Key: fieldName, - }, - } -} - func UpdatePreloadLibraries(cr *patroniv1.PatroniCore) { helper.UpdatePreloadLibraries(cr, preloadLibraries) } diff --git a/services/backup-daemon/maintenance/recovery/utils_oc.py b/services/backup-daemon/maintenance/recovery/utils_oc.py index c15b06e4..e8df6abf 100644 --- a/services/backup-daemon/maintenance/recovery/utils_oc.py +++ b/services/backup-daemon/maintenance/recovery/utils_oc.py @@ -403,7 +403,7 @@ def oc_exec(self, pod_id, command): process = subprocess.Popen("{} exec {} -- {}".format(self.oc, pod_id, command), shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) if process.wait() != 0: - raise Exception("Error occured during execution. " + raise Exception("Error occurred during execution. " "Return code: {}, stderr: {}, stdout: {}" .format(process.returncode, process.stderr.read(), process.stdout.read())) return process.stdout.read().decode() diff --git a/services/dbaas-adapter/adapter/basic/basic.go b/services/dbaas-adapter/adapter/basic/basic.go index 893f4360..62a052d0 100644 --- a/services/dbaas-adapter/adapter/basic/basic.go +++ b/services/dbaas-adapter/adapter/basic/basic.go @@ -1573,7 +1573,7 @@ func (sa ServiceAdapter) getSchemasFromDB(dbName string) ([]string, error) { var schema string err := rows.Scan(&schema) if err != nil { - sa.log.Error("cant scan schema name", zap.Error(err)) + sa.log.Error("can't scan schema name", zap.Error(err)) return result, err } result = append(result, schema) diff --git a/services/dbaas-adapter/adapter/main.go b/services/dbaas-adapter/adapter/main.go index d25415e8..19297a5a 100644 --- a/services/dbaas-adapter/adapter/main.go +++ b/services/dbaas-adapter/adapter/main.go @@ -246,7 +246,7 @@ func main() { *selfAddress = strings.ReplaceAll(*selfAddress, "8080", "8443") logger.Info(fmt.Sprintf("replacing self address with https, %s", *selfAddress)) } - logger.Info(fmt.Sprintf("self address set for registring in aggregator, %s", *selfAddress)) + logger.Info(fmt.Sprintf("self address set for registering in aggregator, %s", *selfAddress)) log.Fatal(fiber2.RunFiberServer(*servePort, func(app *fiber.App, ctx context.Context) error { fiber2.BuildFiberDBaaSAdapterHandlers( app, From e95b41b9a667500abb2bb704e0a067a26f32598c Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 15:01:54 +0500 Subject: [PATCH 06/10] refactor: fix linter --- operator/pkg/helper/patroni_core_helper.go | 2 +- operator/pkg/helper/resource_management.go | 2 +- services/dbaas-adapter/adapter/basic/basic.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/operator/pkg/helper/patroni_core_helper.go b/operator/pkg/helper/patroni_core_helper.go index 538c3aae..1406e0b8 100644 --- a/operator/pkg/helper/patroni_core_helper.go +++ b/operator/pkg/helper/patroni_core_helper.go @@ -603,7 +603,7 @@ func (ph *PatroniHelper) IsPatroniClusterHealthy(config *ClusterStatus) bool { logger.Info("Check Is Patroni Cluster Healthy") cr, err := ph.GetPatroniCoreCR() if err != nil { - logger.Info(fmt.Sprintf("While getting PatroniCore CR an error occured: %v", err)) + logger.Info(fmt.Sprintf("While getting PatroniCore CR an error occurred: %v", err)) return false } expectedMembersNum := cr.Spec.Patroni.Replicas diff --git a/operator/pkg/helper/resource_management.go b/operator/pkg/helper/resource_management.go index c4428cc9..2b2185c0 100644 --- a/operator/pkg/helper/resource_management.go +++ b/operator/pkg/helper/resource_management.go @@ -901,7 +901,7 @@ func (rm *ResourceManager) UpdatePatroniReplicas(replicas int32, clusterName str return err } } - logger.Info(fmt.Sprintf("%s cluster statefulsets have scaled to %v successfuly", clusterName, replicas)) + logger.Info(fmt.Sprintf("%s cluster statefulsets have scaled to %v successfully", clusterName, replicas)) return nil } diff --git a/services/dbaas-adapter/adapter/basic/basic.go b/services/dbaas-adapter/adapter/basic/basic.go index 62a052d0..1bf377c0 100644 --- a/services/dbaas-adapter/adapter/basic/basic.go +++ b/services/dbaas-adapter/adapter/basic/basic.go @@ -346,7 +346,7 @@ func (sa ServiceAdapter) CreateDatabase(ctx context.Context, requestOnCreateDb d fmt.Printf("Successfully granted ALL privilege on public schema to %s\n", adminUser) } - // explicitely providing create grants for PG15 + // explicitly providing create grants for PG15 err = sa.grantCreateOnSchema(ctx, dbName, defaultSchema, adminUser) if err != nil { logger.Error(fmt.Sprintf("Couldn't create User %s", username), zap.Error(err)) From 13462ec685e68f697fdf124501fcda3fb1b14c7c Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 15:25:13 +0500 Subject: [PATCH 07/10] refactor: fix linter --- .github/workflows/super-linter.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/super-linter.yaml b/.github/workflows/super-linter.yaml index 3dc07bf9..2599d77e 100644 --- a/.github/workflows/super-linter.yaml +++ b/.github/workflows/super-linter.yaml @@ -22,8 +22,6 @@ on: default: false required: false description: "Lint all codebase" -permissions: - contents: read jobs: run-lint: From c25e9ea03f18ee76ef10eaff11ba79098e19de1d Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 15:54:55 +0500 Subject: [PATCH 08/10] refactor: fix linter --- operator/pkg/client/client.go | 8 -------- services/backup-daemon/Dockerfile | 1 + services/backup-daemon/maintenance/recovery/utils_oc.py | 9 ++++----- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/operator/pkg/client/client.go b/operator/pkg/client/client.go index 8bd9d61f..fbafbe49 100644 --- a/operator/pkg/client/client.go +++ b/operator/pkg/client/client.go @@ -20,7 +20,6 @@ import ( "fmt" "net" "net/url" - "os" "strings" "time" @@ -238,13 +237,6 @@ func (adapter postgresAdapter) executeHealthQuery() error { return err } -func getEnv(key, fallback string) string { - if value, ok := os.LookupEnv(key); ok { - return value - } - return fallback -} - func EscapeString(str string) string { return strings.ReplaceAll(str, "'", "''") } diff --git a/services/backup-daemon/Dockerfile b/services/backup-daemon/Dockerfile index 1736ffd3..712dd2c6 100644 --- a/services/backup-daemon/Dockerfile +++ b/services/backup-daemon/Dockerfile @@ -1,3 +1,4 @@ +# checkov:skip=CKV_DOCKER_3: Backward compatibility FROM --platform=$BUILDPLATFORM golang:1.26-alpine3.23 AS builder ENV GO111MODULE=on diff --git a/services/backup-daemon/maintenance/recovery/utils_oc.py b/services/backup-daemon/maintenance/recovery/utils_oc.py index e8df6abf..0c6e7337 100644 --- a/services/backup-daemon/maintenance/recovery/utils_oc.py +++ b/services/backup-daemon/maintenance/recovery/utils_oc.py @@ -204,7 +204,7 @@ def get_deployment_replicas_count(self, dc_name, type="dc"): def get_stateful_set_replicas_count(self, stateful_set_name): stateful_set = self.get_stateful_set(stateful_set_name) return int(stateful_set.get("spec").get("replicas")) - + def get_stateful_set_names_by_label(self, s: str) -> list[str]: sel = dict(p.strip().split("=", 1) for p in s.split(",")) items = self.get_entities("statefulset") @@ -481,16 +481,15 @@ def __init__(self): def login(self, oc_url, username, password, project, skip_tls_verify=False): log.info("Log in as {} to {}".format(username, oc_url)) - # Configuration for Kubernetes client os_config = client.Configuration() os_config.verify_ssl = not skip_tls_verify os_config.assert_hostname = False os_config.host = oc_url - + openshift_token = get_api_token(oc_url, b"admin", b"admin") os_config.api_key = {"authorization": "Bearer " + openshift_token} - + self._api_client = client.ApiClient(configuration=os_config) log.info("Will use namespace {}".format(project)) @@ -1119,4 +1118,4 @@ def return_liveness_readiness_probes_for_stateful_set(self, stateful_set_name, p stateful_set = self.oc.get_stateful_set(stateful_set_name) stateful_set["spec"]["template"]["spec"]["containers"][0]["readinessProbe"] = probe stateful_set["spec"]["template"]["spec"]["containers"][0]["livenessProbe"] = probe - self.oc.apply_object(stateful_set) \ No newline at end of file + self.oc.apply_object(stateful_set) From 57920de99220ac76a526dbeceb73a6684b7507c4 Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 15:57:24 +0500 Subject: [PATCH 09/10] refactor: fix linter --- .github/workflows/super-linter.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/super-linter.yaml b/.github/workflows/super-linter.yaml index 2599d77e..44e1839a 100644 --- a/.github/workflows/super-linter.yaml +++ b/.github/workflows/super-linter.yaml @@ -22,10 +22,22 @@ on: default: false required: false description: "Lint all codebase" +permissions: {} jobs: run-lint: runs-on: ubuntu-latest + permissions: + # contents permission to clone the repository + contents: read + packages: read + # issues and pull-requests permissions to write results as pull + # request comments. Omit them if you don't need summary comments + issues: write + pull-requests: write + # To report GitHub Actions status checks. Omit if you don't need + # to update commit status + statuses: write steps: - name: Checkout code uses: actions/checkout@v4 From 92f1621a1b79efc2beebae715c5890b90be87aab Mon Sep 17 00:00:00 2001 From: Tvion Date: Tue, 14 Jul 2026 16:14:07 +0500 Subject: [PATCH 10/10] refactor: fix linter --- .github/workflows/super-linter.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/super-linter.yaml b/.github/workflows/super-linter.yaml index 44e1839a..fd070393 100644 --- a/.github/workflows/super-linter.yaml +++ b/.github/workflows/super-linter.yaml @@ -12,9 +12,9 @@ name: Lint Code Base on: - pull_request: - branches: - - '**' + # pull_request: + # branches: + # - '**' workflow_dispatch: inputs: full_scan: