Skip to content

Commit 44073cf

Browse files
RafiaSabihrafia sabih
andauthored
Fixes after merge (#12)
Fixes after the merge of V1.10.1 Co-authored-by: rafia sabih <[email protected]>
1 parent 0c7b400 commit 44073cf

4 files changed

Lines changed: 58 additions & 171 deletions

File tree

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ macos: ${SOURCES}
6161
GOOS=darwin GOARCH=amd64 CGO_ENABLED=${CGO_ENABLED} go build -o build/macos/${BINARY} ${BUILD_FLAGS} -ldflags "$(LDFLAGS)" $^
6262

6363
docker: ${DOCKERDIR}/${DOCKERFILE}
64+
6465
echo `(env)`
6566
echo "Tag ${TAG}"
6667
echo "Version ${VERSION}"

pkg/apis/acid.zalan.do/v1/crds.go

Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ var OperatorConfigCRDResourceColumns = []apiextv1.CustomResourceColumnDefinition
110110

111111
var min0 = 0.0
112112
var min1 = 1.0
113+
var minDisable = -1.0
113114
var mapString = "map"
114115
var min1int64 = int64(1)
115-
var minDisable = -1.0
116116

117117
// PostgresCRDResourceValidation to check applied manifest parameters
118118
var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
@@ -344,35 +344,45 @@ var PostgresCRDResourceValidation = apiextv1.CustomResourceValidation{
344344
},
345345
},
346346
},
347+
// "topologySpreadConstraints": {
348+
// Type: "array",
349+
// Nullable: true,
350+
// Items: &apiextv1.JSONSchemaPropsOrArray{
351+
// Schema: &apiextv1.JSONSchemaProps{
352+
// Type: "object",
353+
// XPreserveUnknownFields: util.True(),
354+
// VendorExtensible: spec.VendorExtensible{
355+
// Extensions: spec.Extensions{
356+
// "x-kubernetes-list-map-keys": []interface{}{
357+
// "topologyKey",
358+
// "whenUnsatisfiable",
359+
// },
360+
// },
361+
// "x-kubernetes-list-type": "map",
362+
// "x-kubernetes-patch-merge-key": "topologyKey",
363+
// "x-kubernetes-patch-strategy": "merge",
364+
// },
365+
// },
366+
// SchemaProps: spec.SchemaProps{
367+
// Description: "TopologySpreadConstraints describes how a group of pods ought to spread across topology domains. Scheduler will schedule pods in a way which abides by the constraints. All topologySpreadConstraints are ANDed.",
368+
// Type: []string{"array"},
369+
// Items: &spec.SchemaOrArray{
370+
// Schema: &spec.Schema{
371+
// SchemaProps: spec.SchemaProps{
372+
// Default: map[string]interface{}{},
373+
// Ref: ref("k8s.io/api/core/v1.TopologySpreadConstraint"),
374+
// },
375+
// },
376+
// },
377+
// },
378+
// },
347379
"topologySpreadConstraints": {
348380
Type: "array",
349381
Nullable: true,
350382
Items: &apiextv1.JSONSchemaPropsOrArray{
351383
Schema: &apiextv1.JSONSchemaProps{
352384
Type: "object",
353385
XPreserveUnknownFields: util.True(),
354-
VendorExtensible: spec.VendorExtensible{
355-
Extensions: spec.Extensions{
356-
"x-kubernetes-list-map-keys": []interface{}{
357-
"topologyKey",
358-
"whenUnsatisfiable",
359-
},
360-
"x-kubernetes-list-type": "map",
361-
"x-kubernetes-patch-merge-key": "topologyKey",
362-
"x-kubernetes-patch-strategy": "merge",
363-
},
364-
},
365-
SchemaProps: spec.SchemaProps{
366-
Description: "TopologySpreadConstraints describes how a group of pods ought to spread across topology domains. Scheduler will schedule pods in a way which abides by the constraints. All topologySpreadConstraints are ANDed.",
367-
Type: []string{"array"},
368-
Items: &spec.SchemaOrArray{
369-
Schema: &spec.Schema{
370-
SchemaProps: spec.SchemaProps{
371-
Default: map[string]interface{}{},
372-
Ref: ref("k8s.io/api/core/v1.TopologySpreadConstraint"),
373-
},
374-
},
375-
376386
},
377387
},
378388
},

pkg/apis/acid.zalan.do/v1/postgresql_type.go

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -302,39 +302,3 @@ type Configuration struct {
302302
type TDE struct {
303303
Enable bool `json:"enable"`
304304
}
305-
306-
type Backup struct {
307-
Pgbackrest *Pgbackrest `json:"pgbackrest"`
308-
}
309-
310-
type Pgbackrest struct {
311-
Image string `json:"image"`
312-
Global map[string]string `json:"global"`
313-
Repos []Repo `json:"repos"`
314-
Restore Restore `json:"restore"`
315-
Configuration Configuration `json:"configuration"`
316-
Resources *Resources `json:"resources,omitempty"`
317-
}
318-
319-
type Repo struct {
320-
Name string `json:"name"`
321-
Storage string `json:"storage"`
322-
Resource string `json:"resource"`
323-
Endpoint string `json:"endpoint"`
324-
Region string `json:"region"`
325-
Schedule map[string]string `json:"schedule"`
326-
}
327-
328-
type Restore struct {
329-
ID string `json:"id"`
330-
Repo string `json:"repo"`
331-
Options []string `json:"options"`
332-
}
333-
334-
type Configuration struct {
335-
Secret string `json:"secret"`
336-
}
337-
338-
type TDE struct {
339-
Enable bool `json:"enable"`
340-
}

pkg/cluster/k8sres.go

Lines changed: 24 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,7 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
12971297
if spec.TDE != nil && spec.TDE.Enable {
12981298
enableTDE = true
12991299
}
1300+
13001301
spiloConfiguration, err := generateSpiloJSONConfiguration(&spec.PostgresqlParam, &spec.Patroni, &c.OpConfig, enableTDE, c.logger)
13011302
if err != nil {
13021303
return nil, fmt.Errorf("could not generate Spilo JSON configuration: %v", err)
@@ -1342,39 +1343,33 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
13421343
keyName = "SSL_CA_FILE"
13431344
default:
13441345
panic(fmt.Sprintf("TLS env key unknown %s", k))
1345-
// this is combined with the FSGroup in the section above
1346-
// to give read access to the postgres user
1347-
defaultMode := int32(0644)
1348-
mountPath := "/tls"
1349-
additionalVolumes = append(additionalVolumes, acidv1.AdditionalVolume{
1350-
Name: spec.TLS.SecretName,
1351-
MountPath: mountPath,
1352-
VolumeSource: v1.VolumeSource{
1353-
Secret: &v1.SecretVolumeSource{
1354-
SecretName: spec.TLS.SecretName,
1355-
DefaultMode: &defaultMode,
1356-
},
1357-
},
1358-
})
1359-
1360-
// use the same filenames as Secret resources by default
1361-
certFile := ensurePath(spec.TLS.CertificateFile, mountPath, "tls.crt")
1362-
privateKeyFile := ensurePath(spec.TLS.PrivateKeyFile, mountPath, "tls.key")
1363-
spiloEnvVars = appendEnvVars(
1364-
spiloEnvVars,
1365-
v1.EnvVar{Name: "SSL_CERTIFICATE_FILE", Value: certFile},
1366-
v1.EnvVar{Name: "SSL_PRIVATE_KEY_FILE", Value: privateKeyFile},
1367-
)
1368-
1369-
if spec.TLS.CAFile != "" {
1370-
// support scenario when the ca.crt resides in a different secret, diff path
1371-
mountPathCA := mountPath
1372-
if spec.TLS.CASecretName != "" {
1373-
mountPathCA = mountPath + "ca"
13741346
}
1347+
// this is combined with the FSGroup in the section above
1348+
// to give read access to the postgres user
1349+
defaultMode := int32(0644)
1350+
mountPath := "/tls"
1351+
additionalVolumes = append(additionalVolumes, acidv1.AdditionalVolume{
1352+
Name: spec.TLS.SecretName,
1353+
MountPath: mountPath,
1354+
VolumeSource: v1.VolumeSource{
1355+
Secret: &v1.SecretVolumeSource{
1356+
SecretName: spec.TLS.SecretName,
1357+
DefaultMode: &defaultMode,
1358+
},
1359+
},
1360+
})
13751361

1362+
// use the same filenames as Secret resources by default
1363+
certFile := ensurePath(spec.TLS.CertificateFile, mountPath, "tls.crt")
1364+
privateKeyFile := ensurePath(spec.TLS.PrivateKeyFile, mountPath, "tls.key")
1365+
spiloEnvVars = appendEnvVars(
1366+
spiloEnvVars,
1367+
v1.EnvVar{Name: "SSL_CERTIFICATE_FILE", Value: certFile},
1368+
v1.EnvVar{Name: "SSL_PRIVATE_KEY_FILE", Value: privateKeyFile},
1369+
)
13761370
return keyName
13771371
}
1372+
13781373
tlsEnv, tlsVolumes := generateTlsMounts(spec, getSpiloTLSEnv)
13791374
for _, env := range tlsEnv {
13801375
spiloEnvVars = appendEnvVars(spiloEnvVars, env)
@@ -1544,89 +1539,6 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
15441539
resources = *resourceRequirements
15451540
}
15461541

1547-
if c.Postgresql.Spec.Backup != nil && c.Postgresql.Spec.Backup.Pgbackrest != nil {
1548-
1549-
pgbackrestRestoreEnvVars := appendEnvVars(
1550-
spiloEnvVars,
1551-
v1.EnvVar{
1552-
Name: "RESTORE_ENABLE",
1553-
ValueFrom: &v1.EnvVarSource{
1554-
ConfigMapKeyRef: &v1.ConfigMapKeySelector{
1555-
LocalObjectReference: v1.LocalObjectReference{
1556-
Name: c.getPgbackrestRestoreConfigmapName(),
1557-
},
1558-
Key: "restore_enable",
1559-
},
1560-
},
1561-
},
1562-
v1.EnvVar{
1563-
Name: "RESTORE_BASEBACKUP",
1564-
ValueFrom: &v1.EnvVarSource{
1565-
ConfigMapKeyRef: &v1.ConfigMapKeySelector{
1566-
LocalObjectReference: v1.LocalObjectReference{
1567-
Name: c.getPgbackrestRestoreConfigmapName(),
1568-
},
1569-
Key: "restore_basebackup",
1570-
},
1571-
},
1572-
},
1573-
v1.EnvVar{
1574-
Name: "RESTORE_METHOD",
1575-
ValueFrom: &v1.EnvVarSource{
1576-
ConfigMapKeyRef: &v1.ConfigMapKeySelector{
1577-
LocalObjectReference: v1.LocalObjectReference{
1578-
Name: c.getPgbackrestRestoreConfigmapName(),
1579-
},
1580-
Key: "restore_method",
1581-
},
1582-
},
1583-
},
1584-
v1.EnvVar{
1585-
Name: "RESTORE_COMMAND",
1586-
ValueFrom: &v1.EnvVarSource{
1587-
ConfigMapKeyRef: &v1.ConfigMapKeySelector{
1588-
LocalObjectReference: v1.LocalObjectReference{
1589-
Name: c.getPgbackrestRestoreConfigmapName(),
1590-
},
1591-
Key: "restore_command",
1592-
},
1593-
},
1594-
},
1595-
v1.EnvVar{
1596-
Name: "SELECTOR",
1597-
Value: fmt.Sprintf("cluster-name=%s,spilo-role=master", c.Name),
1598-
},
1599-
v1.EnvVar{
1600-
Name: "MODE",
1601-
Value: "pgbackrest",
1602-
},
1603-
)
1604-
var cpuLimit, memLimit, cpuReq, memReq string
1605-
if spec.Backup.Pgbackrest.Resources != nil {
1606-
cpuLimit = spec.Backup.Pgbackrest.Resources.ResourceLimits.CPU
1607-
memLimit = spec.Backup.Pgbackrest.Resources.ResourceLimits.Memory
1608-
cpuReq = spec.Backup.Pgbackrest.Resources.ResourceRequests.CPU
1609-
memReq = spec.Backup.Pgbackrest.Resources.ResourceRequests.Memory
1610-
resources = v1.ResourceRequirements{
1611-
Limits: v1.ResourceList{
1612-
"cpu": resource.MustParse(cpuLimit),
1613-
"memory": resource.MustParse(memLimit),
1614-
},
1615-
Requests: v1.ResourceList{
1616-
"cpu": resource.MustParse(cpuReq),
1617-
"memory": resource.MustParse(memReq),
1618-
},
1619-
}
1620-
} else {
1621-
defaultResources := makeDefaultResources(&c.OpConfig)
1622-
resourceRequirements, err := c.generateResourceRequirements(
1623-
spec.Resources, defaultResources, constants.PostgresContainerName)
1624-
if err != nil {
1625-
return nil, fmt.Errorf("could not generate resource requirements: %v", err)
1626-
}
1627-
resources = *resourceRequirements
1628-
}
1629-
16301542
initContainers = append(initContainers, v1.Container{
16311543
Name: "pgbackrest-restore",
16321544
Image: spec.Backup.Pgbackrest.Image,

0 commit comments

Comments
 (0)