Skip to content
Merged
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
43 changes: 43 additions & 0 deletions pkg/apis/cpo.opensource.cybertec.at/v1/crds.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,49 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
"ttl": {
Type: "integer",
},
"log": {
Type: "object",
Properties: map[string]apiextv1.JSONSchemaProps{
"type": {
Type: "string",
Enum: []apiextv1.JSON{
{Raw: []byte(`"plain"`)},
{Raw: []byte(`"json"`)},
},
},
"level": {
Type: "string",
Enum: []apiextv1.JSON{
{Raw: []byte(`"DEBUG"`)},
{Raw: []byte(`"INFO"`)},
{Raw: []byte(`"WARNING"`)},
{Raw: []byte(`"ERROR"`)},
{Raw: []byte(`"CRITICAL"`)},
},
},
"traceback_level": {
Type: "string",
Enum: []apiextv1.JSON{
{Raw: []byte(`"DEBUG"`)},
{Raw: []byte(`"INFO"`)},
{Raw: []byte(`"WARNING"`)},
{Raw: []byte(`"ERROR"`)},
{Raw: []byte(`"CRITICAL"`)},
},
},
"static_fields": {
Type: "object",
AdditionalProperties: &apiextv1.JSONSchemaPropsOrBool{
Schema: &apiextv1.JSONSchemaProps{
Type: "string",
},
},
},
"deduplicate_heartbeat_logs": {
Type: "boolean",
},
},
},
},
},
"podAnnotations": {
Expand Down
9 changes: 9 additions & 0 deletions pkg/apis/cpo.opensource.cybertec.at/v1/postgresql_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ type Patroni struct {
SynchronousNodeCount uint32 `json:"synchronous_node_count,omitempty" defaults:"1"`
Multisite *Multisite `json:"multisite,omitempty"`
FailsafeMode *bool `json:"failsafe_mode,omitempty"`
Log *PatroniLog `json:"log,omitempty"`
}

// StandbyDescription contains remote primary config or s3/gs wal path
Expand Down Expand Up @@ -342,3 +343,11 @@ type EtcdConfig struct {
Protocol *string `json:"protocol,omitempty"`
CertSecretName *string `json:"certSecretName,omitempty"`
}

type PatroniLog struct {
Type string `json:"type,omitempty"`
Level string `json:"level,omitempty"`
TracebackLevel string `json:"traceback_level,omitempty"`
StaticFields map[string]string `json:"static_fields,omitempty"`
DeduplicateHeartbeatLogs *bool `json:"deduplicate_heartbeat_logs,omitempty"`
}
29 changes: 29 additions & 0 deletions pkg/cluster/k8sres.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,22 @@ type pgBootstrap struct {
type spiloConfiguration struct {
PgLocalConfiguration map[string]interface{} `json:"postgresql"`
Bootstrap pgBootstrap `json:"bootstrap"`
Log *spiloLogConfiguration `json:"log,omitempty"`
}

type TDEConfig struct {
Enabled bool
KeyBits string
}

type spiloLogConfiguration struct {
Type string `json:"type,omitempty"`
Level string `json:"level,omitempty"`
TracebackLevel string `json:"traceback_level,omitempty"`
StaticFields map[string]string `json:"static_fields,omitempty"`
DeduplicateHeartbeatLogs *bool `json:"deduplicate_heartbeat_logs,omitempty"`
}

func (c *Cluster) statefulSetName() string {
return c.Name
}
Expand Down Expand Up @@ -468,6 +477,26 @@ PatroniInitDBParams:
config.PgLocalConfiguration[patroniPGHBAConfParameterName] = patroni.PgHba
}

if patroni.Log != nil {
logConfig := &spiloLogConfiguration{}
if patroni.Log.Type != "" {
logConfig.Type = patroni.Log.Type
}
if patroni.Log.Level != "" {
logConfig.Level = patroni.Log.Level
}
if patroni.Log.TracebackLevel != "" {
logConfig.TracebackLevel = patroni.Log.TracebackLevel
}
if patroni.Log.StaticFields != nil {
logConfig.StaticFields = patroni.Log.StaticFields
}
if patroni.Log.DeduplicateHeartbeatLogs != nil {
logConfig.DeduplicateHeartbeatLogs = patroni.Log.DeduplicateHeartbeatLogs
}
config.Log = logConfig
}

res, err := json.Marshal(config)
return string(res), err
}
Expand Down
Loading