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/.github/workflows/super-linter.yaml b/.github/workflows/super-linter.yaml index 3dc07bf9..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: @@ -22,12 +22,22 @@ on: default: false required: false description: "Lint all codebase" -permissions: - contents: read +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 diff --git a/operator/pkg/client/client.go b/operator/pkg/client/client.go index f945673f..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" @@ -34,7 +33,7 @@ import ( ) const ( - pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" + pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/" ) var ( @@ -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/operator/pkg/deployment/backup.go b/operator/pkg/deployment/backup.go index a122b899..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" @@ -78,7 +77,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 +86,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), }, }, @@ -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", }, }, @@ -297,28 +296,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](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/deployment/monitoring.go b/operator/pkg/deployment/monitoring.go index 8622e959..df6090f4 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..1406e0b8 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,13 +39,12 @@ 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" ) var ( pHelper *PatroniHelper = nil - + secretFilePath = "/var/run/secrets/postgresql/" replicatorPasswordPath = secretFilePath + "replicator-credentials/" ) @@ -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 @@ -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 @@ -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..2b2185c0 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 }) @@ -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/operator/pkg/queryexporter/query_exporter.go b/operator/pkg/queryexporter/query_exporter.go index 1f554746..ac1fae14 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 ( @@ -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/operator/pkg/reconciler/backup_daemon.go b/operator/pkg/reconciler/backup_daemon.go index 1603f3be..8e5ac705 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](420), }, }, @@ -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](420), }, }, 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)) diff --git a/operator/pkg/replicationcontroller/replication_controller.go b/operator/pkg/replicationcontroller/replication_controller.go index cfbae6a7..63535cd7 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 +} 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 c15b06e4..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") @@ -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() @@ -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) diff --git a/services/dbaas-adapter/adapter/basic/basic.go b/services/dbaas-adapter/adapter/basic/basic.go index 893f4360..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)) @@ -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 c477782a..19297a5a 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/" ) @@ -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, 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 (