Skip to content
Open
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
14 changes: 7 additions & 7 deletions .github/linters/.jscpd.json
Original file line number Diff line number Diff line change
@@ -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/**"
]
}
20 changes: 15 additions & 5 deletions .github/workflows/super-linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,32 @@
name: Lint Code Base

on:
pull_request:
branches:
- '**'
# pull_request:
# branches:
# - '**'
workflow_dispatch:
inputs:
full_scan:
type: boolean
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
Expand Down
10 changes: 1 addition & 9 deletions operator/pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"net"
"net/url"
"os"
"strings"
"time"

Expand All @@ -34,7 +33,7 @@ import (
)

const (
pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/"
pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/"
)

var (
Expand Down Expand Up @@ -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, "'", "''")
}
51 changes: 25 additions & 26 deletions operator/pkg/deployment/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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),
},
},
Expand All @@ -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),
},
},
Expand Down Expand Up @@ -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",
},
},
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions operator/pkg/deployment/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -222,7 +222,7 @@ func NewMonitoringDeployment(metricCollector *netcrackerv1.MetricCollector, pgcl
},
},
}

if metricCollector.PriorityClassName != "" {
deployment.Spec.Template.Spec.PriorityClassName = metricCollector.PriorityClassName
}
Expand Down
6 changes: 3 additions & 3 deletions operator/pkg/deployment/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func NewIntegrationTestsPod(cr *v1.PatroniServices, cluster *patroniv1.PatroniCl
},
},
},
InitContainers: []corev1.Container{},
InitContainers: []corev1.Container{},
Containers: []corev1.Container{
{
Name: name,
Expand Down Expand Up @@ -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{
Expand All @@ -200,7 +200,7 @@ func NewCoreIntegrationTests(cr *patroniv1.PatroniCore, cluster *patroniv1.Patro
},
},
},
InitContainers: []corev1.Container{},
InitContainers: []corev1.Container{},
Containers: []corev1.Container{
{
Name: name,
Expand Down
10 changes: 5 additions & 5 deletions operator/pkg/helper/patroni_core_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
genericerror "errors"
"fmt"
"slices"
"strconv"
"strings"
"time"
Expand All @@ -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/"
)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions operator/pkg/helper/resource_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down Expand Up @@ -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
}

Expand Down
13 changes: 2 additions & 11 deletions operator/pkg/queryexporter/query_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ import (

const (
CMName = "query-exporter-config"
pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/"

pgUserCredsPath = util.SecretsBasePath + "postgres-credentials/"
)

var (
Expand Down Expand Up @@ -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)
}
Expand Down
16 changes: 8 additions & 8 deletions operator/pkg/reconciler/backup_daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
},
},
Expand All @@ -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)...)
Expand All @@ -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),
},
},
Expand Down
4 changes: 2 additions & 2 deletions operator/pkg/reconciler/patroni.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
Loading
Loading