Skip to content

Commit

Permalink
update deps
Browse files Browse the repository at this point in the history
Signed-off-by: Rudro-25 <[email protected]>
  • Loading branch information
Rudro-25 committed Sep 24, 2024
1 parent 5182394 commit 5912e49
Show file tree
Hide file tree
Showing 10 changed files with 150 additions and 82 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ require (
k8s.io/klog/v2 v2.130.1
kmodules.xyz/client-go v0.30.13
kmodules.xyz/custom-resources v0.30.0
kubedb.dev/apimachinery v0.47.1-0.20240924090635-38154e492f4e
kubedb.dev/apimachinery v0.47.1-0.20240924051141-f0421dd9f647
sigs.k8s.io/controller-runtime v0.18.4
xorm.io/xorm v1.3.6
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -802,8 +802,8 @@ kmodules.xyz/monitoring-agent-api v0.29.0 h1:gpFl6OZrlMLb/ySMHdREI9EwGtnJ91oZBn9
kmodules.xyz/monitoring-agent-api v0.29.0/go.mod h1:iNbvaMTgVFOI5q2LJtGK91j4Dmjv4ZRiRdasGmWLKQI=
kmodules.xyz/offshoot-api v0.30.0 h1:dq9F93pu4Q8rL9oTcCk+vGGy8vpS7RNt0GSwx7Bvhec=
kmodules.xyz/offshoot-api v0.30.0/go.mod h1:o9VoA3ImZMDBp3lpLb8+kc2d/KBxioRwCpaKDfLIyDw=
kubedb.dev/apimachinery v0.47.1-0.20240924090635-38154e492f4e h1:Js68QYtwGJh06liBeFfSWfLRqdqeFEBzzBgcNve1HUM=
kubedb.dev/apimachinery v0.47.1-0.20240924090635-38154e492f4e/go.mod h1:iD6XKg9Blvfd9iYEO0N9GKiSz6r+yzEPZnfkYdESNG4=
kubedb.dev/apimachinery v0.47.1-0.20240924051141-f0421dd9f647 h1:yRqO/MkRwf4FxE/LktLz6fgkHn58FSxiNrR4NAMDxdQ=
kubedb.dev/apimachinery v0.47.1-0.20240924051141-f0421dd9f647/go.mod h1:iD6XKg9Blvfd9iYEO0N9GKiSz6r+yzEPZnfkYdESNG4=
kubeops.dev/petset v0.0.5-0.20240603165102-e2d9decb8abe h1:uWyps3VIDFwGuL0yQa0eMGaLg4ofVwpy59U14Trxnz8=
kubeops.dev/petset v0.0.5-0.20240603165102-e2d9decb8abe/go.mod h1:A15vh0r979NsvL65DTIZKWsa/NoX9VapHBAEw1ZsdYI=
lukechampine.com/uint128 v1.1.1/go.mod h1:c4eWIwlEGaxC/+H1VguhU4PHXNWDCDMUlWdIWl2j1gk=
Expand Down
4 changes: 0 additions & 4 deletions vendor/kubedb.dev/apimachinery/apis/kubedb/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,10 +576,6 @@ const (
PgBouncerConfigMountPath = "/etc/config"
PgBouncerSecretMountPath = "/var/run/pgbouncer/secret"
PgBouncerServingCertMountPath = "/var/run/pgbouncer/tls/serving"
PgBouncerConfigSectionDatabases = "databases"
PgBouncerConfigSectionPeers = "peers"
PgBouncerConfigSectionPgbouncer = "pgbouncer"
PgBouncerConfigSectionUsers = "users"

// =========================== Pgpool Constants ============================
EnvPostgresUsername = "POSTGRES_USERNAME"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 47 additions & 46 deletions vendor/kubedb.dev/apimachinery/apis/kubedb/v1/pgbouncer_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ limitations under the License.
package v1

import (
"context"
"fmt"
"strconv"

"kubedb.dev/apimachinery/apis"
catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1"
Expand All @@ -31,7 +29,6 @@ import (
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/types"
kmapi "kmodules.xyz/client-go/api/v1"
"kmodules.xyz/client-go/apiextensions"
core_util "kmodules.xyz/client-go/core/v1"
Expand Down Expand Up @@ -130,19 +127,8 @@ func (p PgBouncer) GetBackendSecretName() string {
return meta_util.NameWithSuffix(p.OffshootName(), "backend")
}

func (p PgBouncer) IsPgBouncerFinalConfigSecretExist() bool {
secret, err := p.GetPgBouncerFinalConfigSecret()
return (secret != nil && err == nil)
}

func (p PgBouncer) GetPgBouncerFinalConfigSecret() (*core.Secret, error) {
var secret core.Secret
err := DefaultClient.Get(context.TODO(), types.NamespacedName{Name: p.PgBouncerFinalConfigSecretName(), Namespace: p.GetNamespace()}, &secret)
return &secret, err
}

func (p PgBouncer) PgBouncerFinalConfigSecretName() string {
return meta_util.NameWithSuffix(p.ServiceName(), "final-config")
func (p PgBouncer) ConfigSecretName() string {
return meta_util.NameWithSuffix(p.ServiceName(), "config")
}

type pgbouncerApp struct {
Expand Down Expand Up @@ -214,6 +200,8 @@ func (p *PgBouncer) SetDefaults(pgBouncerVersion *catalog.PgBouncerVersion, uses
p.Spec.DeletionPolicy = DeletionPolicyDelete
}

p.setConnectionPoolConfigDefaults()

if p.Spec.TLS != nil {
if p.Spec.SSLMode == "" {
p.Spec.SSLMode = PgBouncerSSLModeVerifyFull
Expand Down Expand Up @@ -285,7 +273,7 @@ func (p *PgBouncer) GetPersistentSecrets() []string {
var secrets []string
secrets = append(secrets, p.GetAuthSecretName())
secrets = append(secrets, p.GetBackendSecretName())
secrets = append(secrets, p.PgBouncerFinalConfigSecretName())
secrets = append(secrets, p.ConfigSecretName())

return secrets
}
Expand Down Expand Up @@ -320,6 +308,48 @@ func (p *PgBouncer) SetHealthCheckerDefaults() {
}
}

func (p *PgBouncer) setConnectionPoolConfigDefaults() {
if p.Spec.ConnectionPool == nil {
p.Spec.ConnectionPool = &ConnectionPoolConfig{}
}
if p.Spec.ConnectionPool.Port == nil {
p.Spec.ConnectionPool.Port = pointer.Int32P(5432)
}
if p.Spec.ConnectionPool.PoolMode == "" {
p.Spec.ConnectionPool.PoolMode = kubedb.PgBouncerDefaultPoolMode
}
if p.Spec.ConnectionPool.MaxClientConnections == nil {
p.Spec.ConnectionPool.MaxClientConnections = pointer.Int64P(100)
}
if p.Spec.ConnectionPool.DefaultPoolSize == nil {
p.Spec.ConnectionPool.DefaultPoolSize = pointer.Int64P(20)
}
if p.Spec.ConnectionPool.MinPoolSize == nil {
p.Spec.ConnectionPool.MinPoolSize = pointer.Int64P(0)
}
if p.Spec.ConnectionPool.ReservePoolSize == nil {
p.Spec.ConnectionPool.ReservePoolSize = pointer.Int64P(0)
}
if p.Spec.ConnectionPool.ReservePoolTimeoutSeconds == nil {
p.Spec.ConnectionPool.ReservePoolTimeoutSeconds = pointer.Int64P(5)
}
if p.Spec.ConnectionPool.MaxDBConnections == nil {
p.Spec.ConnectionPool.MaxDBConnections = pointer.Int64P(0)
}
if p.Spec.ConnectionPool.MaxUserConnections == nil {
p.Spec.ConnectionPool.MaxUserConnections = pointer.Int64P(0)
}
if p.Spec.ConnectionPool.StatsPeriodSeconds == nil {
p.Spec.ConnectionPool.StatsPeriodSeconds = pointer.Int64P(60)
}
if p.Spec.ConnectionPool.AuthType == "" {
p.Spec.ConnectionPool.AuthType = PgBouncerClientAuthModeMD5
}
if p.Spec.ConnectionPool.IgnoreStartupParameters == "" {
p.Spec.ConnectionPool.IgnoreStartupParameters = kubedb.PgBouncerDefaultIgnoreStartupParameters
}
}

func (p *PgBouncer) SetSecurityContext(pgBouncerVersion *catalog.PgBouncerVersion) {
container := core_util.GetContainerByName(p.Spec.PodTemplate.Spec.Containers, kubedb.PgBouncerContainerName)
if container == nil {
Expand Down Expand Up @@ -375,32 +405,3 @@ func (p *PgBouncer) SetSecurityContext(pgBouncerVersion *catalog.PgBouncerVersio
core_util.UpsertContainer(p.Spec.PodTemplate.Spec.Containers, *container)
}
}

func PgBouncerConfigSections() *[]string {
sections := []string{
kubedb.PgBouncerConfigSectionDatabases, kubedb.PgBouncerConfigSectionPeers,
kubedb.PgBouncerConfigSectionPgbouncer, kubedb.PgBouncerConfigSectionUsers,
}
return &sections
}

func PgBouncerDefaultConfig() string {
defaultConfig := "[pgbouncer]\n" +
"\n" +
"listen_port = " + strconv.Itoa(kubedb.PgBouncerDatabasePort) + "\n" +
"pool_mode = " + kubedb.PgBouncerDefaultPoolMode + "\n" +
"max_client_conn = 100\n" +
"default_pool_size = 20\n" +
"min_pool_size = 1\n" +
"reserve_pool_size = 1\n" +
"reserve_pool_timeout = 5\n" +
"max_db_connections = 1\n" +
"max_user_connections = 2\n" +
"stats_period = 60\n" +
"auth_type = " + string(PgBouncerClientAuthModeMD5) + "\n" +
"ignore_startup_parameters = " + "extra_float_digits, " + kubedb.PgBouncerDefaultIgnoreStartupParameters + "\n" +
"logfile = /tmp/pgbouncer.log\n" +
"pidfile = /tmp/pgbouncer.pid\n" +
"listen_addr = *"
return defaultConfig
}
14 changes: 13 additions & 1 deletion vendor/kubedb.dev/apimachinery/apis/kubedb/v1/pgbouncer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ type PgBouncerSpec struct {
PodTemplate ofstv2.PodTemplateSpec `json:"podTemplate,omitempty"`

// Database to proxy by connection pooling.
Database Database `json:"database"`
Database Database `json:"database,omitempty"`

// ConnectionPoolConfig defines Connection pool configuration.
// +optional
Expand Down Expand Up @@ -136,42 +136,54 @@ type Database struct {

type ConnectionPoolConfig struct {
// Port is the port number on which PgBouncer listens to clients. Default: 5432.
// +kubebuilder:default=5432
// +optional
Port *int32 `json:"port,omitempty"`
// PoolMode is the pooling mechanism type. Default: session.
// +kubebuilder:default="session"
// +optional
PoolMode string `json:"poolMode,omitempty"`
// MaxClientConnections is the maximum number of allowed client connections. Default: 100.
// +kubebuilder:default=100
// +optional
MaxClientConnections *int64 `json:"maxClientConnections,omitempty"`
// DefaultPoolSize specifies how many server connections to allow per user/database pair. Default: 20.
// +kubebuilder:default=20
// +optional
DefaultPoolSize *int64 `json:"defaultPoolSize,omitempty"`
// MinPoolSize is used to add more server connections to pool if below this number. Default: 0 (disabled).
// +kubebuilder:default=0
// +optional
MinPoolSize *int64 `json:"minPoolSize,omitempty"`
// ReservePoolSize specifies how many additional connections to allow to a pool. 0 disables. Default: 0 (disabled).
// +kubebuilder:default=0
// +optional
ReservePoolSize *int64 `json:"reservePoolSize,omitempty"`
// ReservePoolTimeoutSeconds is the number of seconds in which if a client has not been serviced,
// pgbouncer enables use of additional connections from reserve pool. 0 disables. Default: 5.0.
// +kubebuilder:default=5
// +optional
ReservePoolTimeoutSeconds *int64 `json:"reservePoolTimeoutSeconds,omitempty"`
// MaxDBConnections is the maximum number of connections allowed per-database. Default: 0 (unlimited).
// +kubebuilder:default=0
// +optional
MaxDBConnections *int64 `json:"maxDBConnections,omitempty"`
// MaxUserConnections is the maximum number of users allowed per-database. Default: 0 (unlimited).
// +kubebuilder:default=0
// +optional
MaxUserConnections *int64 `json:"maxUserConnections,omitempty"`
// StatsPeriodSeconds sets how often the averages shown in various SHOW commands are updated
// and how often aggregated statistics are written to the log. Default: 60
// +kubebuilder:default=60
// +optional
StatsPeriodSeconds *int64 `json:"statsPeriodSeconds,omitempty"`
// AuthType specifies how to authenticate users. Default: md5 (md5+plain text).
// +kubebuilder:default=md5
// +optional
AuthType PgBouncerClientAuthMode `json:"authType,omitempty"`
// IgnoreStartupParameters specifies comma-separated startup parameters that
// pgbouncer knows are handled by admin and it can ignore them. Default: empty
// +kubebuilder:default="empty"
// +optional
IgnoreStartupParameters string `json:"ignoreStartupParameters,omitempty"`
// AdminUsers specifies an array of users who can act as PgBouncer administrators.
Expand Down
13 changes: 12 additions & 1 deletion vendor/kubedb.dev/apimachinery/crds/kubedb.com_pgbouncers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,40 +72,52 @@ spec:
connectionPool:
properties:
authType:
default: md5
enum:
- md5
- scram-sha-256
- cert
type: string
defaultPoolSize:
default: 20
format: int64
type: integer
ignoreStartupParameters:
default: empty
type: string
maxClientConnections:
default: 100
format: int64
type: integer
maxDBConnections:
default: 0
format: int64
type: integer
maxUserConnections:
default: 0
format: int64
type: integer
minPoolSize:
default: 0
format: int64
type: integer
poolMode:
default: session
type: string
port:
default: 5432
format: int32
type: integer
reservePoolSize:
default: 0
format: int64
type: integer
reservePoolTimeoutSeconds:
default: 5
format: int64
type: integer
statsPeriodSeconds:
default: 60
format: int64
type: integer
type: object
Expand Down Expand Up @@ -3614,7 +3626,6 @@ spec:
version:
type: string
required:
- database
- version
type: object
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,6 @@ spec:
- Always
type: string
configuration:
properties:
pgbouncer:
properties:
applyConfig:
additionalProperties:
type: string
type: object
configSecret:
properties:
name:
default: ""
type: string
type: object
x-kubernetes-map-type: atomic
removeCustomConfig:
type: boolean
type: object
required:
- pgbouncer
type: object
horizontalScaling:
properties:
Expand Down Expand Up @@ -196,7 +177,6 @@ spec:
- HorizontalScaling
- VerticalScaling
- UpdateVersion
- Reconfigure
type: string
updateVersion:
properties:
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ kmodules.xyz/offshoot-api/api/v1
kmodules.xyz/offshoot-api/api/v1/conversion
kmodules.xyz/offshoot-api/api/v2
kmodules.xyz/offshoot-api/util
# kubedb.dev/apimachinery v0.47.1-0.20240924090635-38154e492f4e
# kubedb.dev/apimachinery v0.47.1-0.20240924051141-f0421dd9f647
## explicit; go 1.22.1
kubedb.dev/apimachinery/apis
kubedb.dev/apimachinery/apis/catalog
Expand Down
Loading

0 comments on commit 5912e49

Please sign in to comment.