Skip to content

Commit 3afdb70

Browse files
Jonathan S. Katzjkatz
authored andcommitted
Remove the "ContainerResources" configuration
This is now replaced with the one-off settings that are available in the PostgreSQL Operator. It is still possible to achieve similar behavior by modifying the various Job / Pod templates that are deployed in the "pgo-config" ConfigMap. However, this helps the Operator to do things in a more Kubernetes standard way.
1 parent 9a900ed commit 3afdb70

File tree

37 files changed

+109
-361
lines changed

37 files changed

+109
-361
lines changed

apis/crunchydata.com/v1/common.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,6 @@ func (s PgStorageSpec) GetSupplementalGroups() []int64 {
122122
return supplementalGroups
123123
}
124124

125-
// PgContainerResource ...
126-
// swagger:ignore
127-
type PgContainerResources struct {
128-
RequestsMemory string `json:"requestsmemory"`
129-
RequestsCPU string `json:"requestscpu"`
130-
LimitsMemory string `json:"limitsmemory"`
131-
LimitsCPU string `json:"limitscpu"`
132-
}
133-
134125
// CompletedStatus -
135126
const CompletedStatus = "completed"
136127

apis/crunchydata.com/v1/zz_generated.deepcopy.go

Lines changed: 0 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apiserver/clusterservice/clusterimpl.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -730,14 +730,6 @@ func CreateCluster(request *msgs.CreateClusterRequest, ns, pgouser string) msgs.
730730
}
731731
}
732732

733-
if request.ContainerResources != "" {
734-
if apiserver.IsValidContainerResource(request.ContainerResources) == false {
735-
resp.Status.Code = msgs.Error
736-
resp.Status.Msg = request.ContainerResources + " ContainerResource config was not found "
737-
return resp
738-
}
739-
}
740-
741733
// if a value is provided in the request for PodAntiAffinity, then ensure is valid. If
742734
// it is, then set the user label for pod anti-affinity to the request value
743735
// (which in turn becomes a *Label* which is important for anti-affinity).

apiserver/clusterservice/scaleservice.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ func ScaleClusterHandler(w http.ResponseWriter, r *http.Request) {
6060
// in: "path"
6161
// type: "int"
6262
// required: true
63-
// - name: "resources-config"
64-
// description: "The name of a container resource configuration in pgo.yaml that holds CPU and memory requests and limits."
65-
// in: "path"
66-
// type: "string"
67-
// required: false
6863
// - name: "storage-config"
6964
// description: "The service type to use in the replica Service. If not set, the default in pgo.yaml will be used."
7065
// in: "path"

apiserver/loadservice/loadimpl.go

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,20 @@ import (
3838
)
3939

4040
type loadJobTemplateFields struct {
41-
Name string
42-
PGOImagePrefix string
43-
PGOImageTag string
44-
DbHost string
45-
DbDatabase string
46-
DbUser string
47-
DbPass string
48-
DbPort string
49-
TableToLoad string
50-
FilePath string
51-
FileType string
52-
PVCName string
53-
SecurityContext string
54-
ContainerResources string
55-
PGUserSecret string
56-
}
57-
58-
type containerResourcesTemplateFields struct {
59-
RequestsMemory, RequestsCPU string
60-
LimitsMemory, LimitsCPU string
41+
Name string
42+
PGOImagePrefix string
43+
PGOImageTag string
44+
DbHost string
45+
DbDatabase string
46+
DbUser string
47+
DbPass string
48+
DbPort string
49+
TableToLoad string
50+
FilePath string
51+
FileType string
52+
PVCName string
53+
SecurityContext string
54+
PGUserSecret string
6155
}
6256

6357
// LoadConfig ...
@@ -107,7 +101,6 @@ func Load(request *msgs.LoadRequest, ns, pgouser string) msgs.LoadResponse {
107101
LoadConfigTemplate.FileType = LoadCfg.FileType
108102
LoadConfigTemplate.PVCName = LoadCfg.PVCName
109103
LoadConfigTemplate.SecurityContext = operutil.GetPodSecurityContext(supplementalGroups)
110-
LoadConfigTemplate.ContainerResources = ""
111104

112105
clusterList := crv1.PgclusterList{}
113106
if len(request.Args) == 0 && request.Selector == "" {

apiserver/root.go

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ import (
3333
"github.com/crunchydata/postgres-operator/tlsutil"
3434
log "github.com/sirupsen/logrus"
3535
v1 "k8s.io/api/core/v1"
36-
"k8s.io/apimachinery/pkg/api/resource"
3736
"k8s.io/client-go/kubernetes"
3837
"k8s.io/client-go/rest"
3938
)
@@ -84,11 +83,6 @@ type CredentialDetail struct {
8483

8584
var Pgo config.PgoConfig
8685

87-
type containerResourcesTemplateFields struct {
88-
RequestsMemory, RequestsCPU string
89-
LimitsMemory, LimitsCPU string
90-
}
91-
9286
func Initialize() {
9387

9488
PgoNamespace = os.Getenv("PGO_OPERATOR_NAMESPACE")
@@ -185,12 +179,6 @@ func initConfig() {
185179
log.Error("Storage Settings are not defined correctly, can't continue")
186180
os.Exit(2)
187181
}
188-
189-
if !validContainerResourcesSettings() {
190-
log.Error("Container Resources settings are not defined correctly, can't continue")
191-
os.Exit(2)
192-
}
193-
194182
}
195183

196184
func BasicAuthCheck(username, password string) bool {
@@ -347,17 +335,6 @@ func Authn(perm string, w http.ResponseWriter, r *http.Request) (string, error)
347335

348336
}
349337

350-
func validContainerResourcesSettings() bool {
351-
log.Infof("ContainerResources has %d definitions", len(Pgo.ContainerResources))
352-
353-
//validate any Container Resources in pgo.yaml for correct formats
354-
if !IsValidContainerResourceValues() {
355-
return false
356-
}
357-
358-
return true
359-
}
360-
361338
func validStorageSettings() bool {
362339
log.Infof("Storage has %d definitions", len(Pgo.Storage))
363340

@@ -387,11 +364,6 @@ func validStorageSettings() bool {
387364

388365
}
389366

390-
func IsValidContainerResource(name string) bool {
391-
_, ok := Pgo.ContainerResources[name]
392-
return ok
393-
}
394-
395367
func IsValidStorageName(name string) bool {
396368
_, ok := Pgo.Storage[name]
397369
return ok
@@ -408,37 +380,6 @@ func ValidateNodeLabel(nodeLabel string) error {
408380
return nil
409381
}
410382

411-
func IsValidContainerResourceValues() bool {
412-
413-
var err error
414-
415-
for k, v := range Pgo.ContainerResources {
416-
log.Infof("Container Resources %s [%v]", k, v)
417-
resources, _ := Pgo.GetContainerResource(k)
418-
_, err = resource.ParseQuantity(resources.RequestsMemory)
419-
if err != nil {
420-
log.Errorf("%s.RequestsMemory value invalid format", k)
421-
return false
422-
}
423-
_, err = resource.ParseQuantity(resources.RequestsCPU)
424-
if err != nil {
425-
log.Errorf("%s.RequestsCPU value invalid format", k)
426-
return false
427-
}
428-
_, err = resource.ParseQuantity(resources.LimitsMemory)
429-
if err != nil {
430-
log.Errorf("%s.LimitsMemory value invalid format", k)
431-
return false
432-
}
433-
_, err = resource.ParseQuantity(resources.LimitsCPU)
434-
if err != nil {
435-
log.Errorf("%s.LimitsCPU value invalid format", k)
436-
return false
437-
}
438-
}
439-
return true
440-
}
441-
442383
func validateWithKube() {
443384
log.Debug("validateWithKube called")
444385

apiservermsgs/clustermsgs.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ type CreateClusterRequest struct {
6969
CustomConfig string
7070
StorageConfig string
7171
ReplicaStorageConfig string
72-
ContainerResources string
7372
// Version of API client
7473
// required: true
7574
ClientVersion string

conf/postgres-operator/pgbadger.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"initialDelaySeconds": 20,
1414
"periodSeconds": 10
1515
},
16-
{{.ContainerResources }}
1716
"env": [ {
1817
"name": "BADGER_TARGET",
1918
"value": "{{.BadgerTarget}}"

conf/postgres-operator/pgdump-job.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
"readOnly": false
4343
}
4444
],
45-
{{.ContainerResources}}
4645
"env": [
4746
{
4847
"name": "PGDUMP_HOST",

conf/postgres-operator/pgo.load-template.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@
3232
"name": "pgdata",
3333
"readOnly": true
3434
}],
35-
36-
{{.ContainerResources }}
37-
3835
"env": [{
3936
"name": "TABLE_TO_LOAD",
4037
"value": "{{.TableToLoad}}"

0 commit comments

Comments
 (0)