From 69375ddfb9dcb7f51cb2c2154486c16c913324f8 Mon Sep 17 00:00:00 2001 From: andrewlecuyer <43458182+andrewlecuyer@users.noreply.github.com> Date: Tue, 26 Feb 2019 10:35:38 -0600 Subject: [PATCH] Updated "postgres-operator" Dependency (3.5.1) & PGO-OSB Version Number (1.2.2) (#15) * Updated PGO dependency to v3.5.1 and updated PGO-OSB version numbers to v1.2.2 * Update PGO API calls due to changes recently added to PGO for multi-namespace support --- Gopkg.lock | 6 +- Gopkg.toml | 2 +- README.adoc | 3 +- centos7/Dockerfile.pgo-osb.centos7 | 4 +- deploy/deployment.yaml | 2 +- pgocmd/commands.go | 12 +-- .../postgres-operator/apis/cr/v1/backup.go | 11 +- .../postgres-operator/apis/cr/v1/cluster.go | 6 +- .../postgres-operator/apis/cr/v1/deepcopy.go | 16 ++- .../postgres-operator/apis/cr/v1/policy.go | 13 +-- .../postgres-operator/apis/cr/v1/replica.go | 5 +- .../postgres-operator/apis/cr/v1/task.go | 10 +- .../postgres-operator/apis/cr/v1/upgrade.go | 6 +- .../apiservermsgs/backrestmsgs.go | 6 +- .../apiservermsgs/clustermsgs.go | 1 + .../postgres-operator/apiservermsgs/common.go | 4 +- .../apiservermsgs/failovermsgs.go | 1 + .../apiservermsgs/pgbouncermsgs.go | 2 + .../apiservermsgs/pgdumpmsgs.go | 51 +++++++++ .../apiservermsgs/pgpoolmsgs.go | 3 + .../apiservermsgs/policymsgs.go | 2 +- .../apiservermsgs/schedulemsgs.go | 3 + .../apiservermsgs/usermsgs.go | 1 + .../postgres-operator/config/pgoconfig.go | 47 ++------ .../postgres-operator/kubeapi/deployment.go | 2 +- .../postgres-operator/kubeapi/pgreplica.go | 2 +- .../postgres-operator/kubeapi/pgtask.go | 3 +- .../postgres-operator/kubeapi/pod.go | 2 +- .../postgres-operator/pgo/api/backrest.go | 4 +- .../postgres-operator/pgo/api/backup.go | 9 +- .../postgres-operator/pgo/api/cluster.go | 18 ++-- .../postgres-operator/pgo/api/config.go | 4 +- .../postgres-operator/pgo/api/df.go | 4 +- .../postgres-operator/pgo/api/failover.go | 4 +- .../postgres-operator/pgo/api/pgdump.go | 102 ++++++++++++++++++ .../postgres-operator/pgo/api/policy.go | 8 +- .../postgres-operator/pgo/api/pvc.go | 4 +- .../postgres-operator/pgo/api/restoreDump.go | 62 +++++++++++ .../postgres-operator/pgo/api/scale.go | 4 +- .../postgres-operator/pgo/api/scaledown.go | 8 +- .../postgres-operator/pgo/api/status.go | 4 +- .../postgres-operator/pgo/api/test.go | 4 +- .../postgres-operator/pgo/api/upgrade.go | 8 +- .../postgres-operator/pgo/api/user.go | 8 +- .../postgres-operator/pgo/api/workflow.go | 4 +- .../postgres-operator/util/labels.go | 26 +++++ .../postgres-operator/util/policy.go | 5 +- .../postgres-operator/util/util.go | 12 ++- 48 files changed, 393 insertions(+), 135 deletions(-) create mode 100644 vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgdumpmsgs.go create mode 100644 vendor/github.com/crunchydata/postgres-operator/pgo/api/pgdump.go create mode 100644 vendor/github.com/crunchydata/postgres-operator/pgo/api/restoreDump.go diff --git a/Gopkg.lock b/Gopkg.lock index cb3816e..688f694 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -34,7 +34,7 @@ revision = "3a771d992973f24aa725d07868b467d1ddfceafb" [[projects]] - digest = "1:07c0d6383c2be0cfca23c938996395707acc223ccafd96bc24616750f1242327" + digest = "1:916339df5e9cd79a01ac02d064005d40e4e934727877b35061acc3ba3a44f264" name = "github.com/crunchydata/postgres-operator" packages = [ "apis/cr/v1", @@ -45,8 +45,8 @@ "util", ] pruneopts = "NUT" - revision = "89fef9fc325c0645a604fba7c7b41448663bcdda" - version = "3.5.0" + revision = "62ec8adddfc892df984bb389e3f14886f1ebf2f6" + version = "3.5.1" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index 8c7cea0..5ac437f 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -47,7 +47,7 @@ [[constraint]] name = "github.com/crunchydata/postgres-operator" - version = "3.5.0" + version = "3.5.1" [[override]] name = "github.com/spf13/cobra" diff --git a/README.adoc b/README.adoc index 7f7a4f1..e15ea35 100644 --- a/README.adoc +++ b/README.adoc @@ -1,6 +1,6 @@ image::crunchy_logo.png[Crunchy Data Logo] -Latest Release: v1.2.1, {docdate} +Latest Release: v1.2.2, {docdate} == General @@ -30,6 +30,7 @@ See the following: == Compatibility + * pgo-osb 1.2.2 works with Postgres Operator 3.5.1 * pgo-osb 1.2.1 works with Postgres Operator 3.5.0 * pgo-osb 1.2.0 works with Postgres Operator 3.4.0 * pgo-osb 1.1.0 works with Postgres Operator 3.3.0 diff --git a/centos7/Dockerfile.pgo-osb.centos7 b/centos7/Dockerfile.pgo-osb.centos7 index aff7f73..25b69d8 100644 --- a/centos7/Dockerfile.pgo-osb.centos7 +++ b/centos7/Dockerfile.pgo-osb.centos7 @@ -1,8 +1,8 @@ FROM centos:7 LABEL Vendor="Crunchy Data Solutions" \ - Version="1.2.1" \ - Release="1.2.1" \ + Version="1.2.2" \ + Release="1.2.2" \ summary="Crunchy Data pgo-osb open service broker " \ description="Crunchy Data PostgreSQL Operator - pgo-osb " diff --git a/deploy/deployment.yaml b/deploy/deployment.yaml index 98d9f8e..2ff540d 100644 --- a/deploy/deployment.yaml +++ b/deploy/deployment.yaml @@ -38,7 +38,7 @@ spec: - --CO_APISERVER_URL - "https://postgres-operator:8443" - --CO_APISERVER_VERSION - - "3.5.0" + - "3.5.1" - --insecure - "true" - --logtostderr diff --git a/pgocmd/commands.go b/pgocmd/commands.go index 5c6ed60..8613464 100644 --- a/pgocmd/commands.go +++ b/pgocmd/commands.go @@ -20,13 +20,14 @@ import ( "crypto/x509" "errors" "fmt" - msgs "github.com/crunchydata/postgres-operator/apiservermsgs" - api "github.com/crunchydata/postgres-operator/pgo/api" "io/ioutil" "log" "net/http" "os" "strconv" + + msgs "github.com/crunchydata/postgres-operator/apiservermsgs" + api "github.com/crunchydata/postgres-operator/pgo/api" ) const INSTANCE_LABEL_KEY = "pgo-osb-instance" @@ -48,7 +49,7 @@ func GetClusterCredentials(APIServerURL, basicAuthUsername, basicAuthPassword, c } ccpImageTag := "" - response, err := api.ShowCluster(httpclient, clusterName, selector, ccpImageTag, SessionCredentials) + response, err := api.ShowCluster(httpclient, clusterName, selector, ccpImageTag, SessionCredentials, "") if response.Status.Code == msgs.Ok { for _, result := range response.Results { @@ -91,7 +92,6 @@ func DeleteCluster(APIServerURL, basicAuthUsername, basicAuthPassword, clientVer clusterName := "all" deleteData := false deleteBackups := false - deleteConfigMaps := false log.Print("deleting cluster " + selector + " with delete-data " + strconv.FormatBool(deleteData)) httpclient, SessionCredentials, err := GetCredentials(basicAuthUsername, basicAuthPassword, APIServerURL) @@ -99,7 +99,7 @@ func DeleteCluster(APIServerURL, basicAuthUsername, basicAuthPassword, clientVer return err } - response, err := api.DeleteCluster(httpclient, clusterName, selector, SessionCredentials, deleteData, deleteBackups, deleteConfigMaps) + response, err := api.DeleteCluster(httpclient, clusterName, selector, SessionCredentials, deleteData, deleteBackups, "") if response.Status.Code == msgs.Ok { for _, result := range response.Results { @@ -228,7 +228,7 @@ func showUser(BasicAuthUsername, BasicAuthPassword, APIServerURL, clientVersion, if err != nil { return userDetail } - response, err := api.ShowUser(httpclient, clusterName, selector, expired, SessionCredentials) + response, err := api.ShowUser(httpclient, clusterName, selector, expired, SessionCredentials, "") if response.Status.Code != msgs.Ok { log.Println(response.Status.Msg) diff --git a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/backup.go b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/backup.go index 384fa43..646c620 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/backup.go +++ b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/backup.go @@ -22,8 +22,15 @@ import ( // PgbackupResourcePlural ... const PgbackupResourcePlural = "pgbackups" +// Backup job processing states - used by pgdump +const PgBackupJobSubmitted = "Backup Job Submitted" +const PgBackupJobInProgress = "Backup Job In Progress" +const PgBackupJobCompleted = "Backup Job Completed" +const PgBackupJobError = "Backup Job Error" + // PgbackupSpec ... type PgbackupSpec struct { + Namespace string `json:"namespace"` Name string `json:"name"` StorageSpec PgStorageSpec `json:"storagespec"` CCPImageTag string `json:"ccpimagetag"` @@ -65,7 +72,7 @@ type PgbackupState string const ( // PgbackupStateCreated ... - PgbackupStateCreated PgbackupState = "Created" + PgbackupStateCreated PgbackupState = "pgbackup Created" // PgbackupStateProcessed ... - PgbackupStateProcessed PgbackupState = "Processed" + PgbackupStateProcessed PgbackupState = "pgbackup Processed" ) diff --git a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/cluster.go b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/cluster.go index 7359bd7..9d4970d 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/cluster.go +++ b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/cluster.go @@ -33,9 +33,11 @@ type Pgcluster struct { // PgclusterSpec ... type PgclusterSpec struct { + Namespace string `json:"namespace"` Name string `json:"name"` ClusterName string `json:"clustername"` Policies string `json:"policies"` + CCPImage string `json:"ccpimage"` CCPImageTag string `json:"ccpimagetag"` Port string `json:"port"` NodeName string `json:"nodename"` @@ -81,7 +83,7 @@ type PgclusterState string const ( // PgclusterStateCreated ... - PgclusterStateCreated PgclusterState = "Created" + PgclusterStateCreated PgclusterState = "pgcluster Created" // PgclusterStateProcessed ... - PgclusterStateProcessed PgclusterState = "Processed" + PgclusterStateProcessed PgclusterState = "pgcluster Processed" ) diff --git a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/deepcopy.go b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/deepcopy.go index d0be232..6a26f54 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/deepcopy.go +++ b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/deepcopy.go @@ -8,6 +8,7 @@ func (in *Pgbackup) DeepCopyInto(out *Pgbackup) { out.TypeMeta = in.TypeMeta out.ObjectMeta = in.ObjectMeta out.Spec = PgbackupSpec{ + Namespace: in.Spec.Namespace, Name: in.Spec.Name, StorageSpec: in.Spec.StorageSpec, CCPImageTag: in.Spec.CCPImageTag, @@ -53,11 +54,13 @@ func (in *Pgupgrade) DeepCopyInto(out *Pgupgrade) { out.Status = in.Status out.Spec = PgupgradeSpec{ + Namespace: in.Spec.Namespace, Name: in.Spec.Name, ResourceType: in.Spec.ResourceType, UpgradeType: in.Spec.UpgradeType, UpgradeStatus: in.Spec.UpgradeStatus, StorageSpec: in.Spec.StorageSpec, + CCPImage: in.Spec.CCPImage, CCPImageTag: in.Spec.CCPImageTag, OldDatabaseName: in.Spec.OldDatabaseName, NewDatabaseName: in.Spec.NewDatabaseName, @@ -100,6 +103,7 @@ func (in *Pgreplica) DeepCopyInto(out *Pgreplica) { out.ObjectMeta = in.ObjectMeta out.Status = in.Status out.Spec = PgreplicaSpec{ + Namespace: in.Spec.Namespace, Name: in.Spec.Name, ClusterName: in.Spec.ClusterName, ReplicaStorage: in.Spec.ReplicaStorage, @@ -140,9 +144,11 @@ func (in *Pgcluster) DeepCopyInto(out *Pgcluster) { out.ObjectMeta = in.ObjectMeta out.Status = in.Status out.Spec = PgclusterSpec{ + Namespace: in.Spec.Namespace, Name: in.Spec.Name, ClusterName: in.Spec.ClusterName, Policies: in.Spec.Policies, + CCPImage: in.Spec.CCPImage, CCPImageTag: in.Spec.CCPImageTag, Port: in.Spec.Port, NodeName: in.Spec.NodeName, @@ -198,10 +204,11 @@ func (in *Pgpolicy) DeepCopyInto(out *Pgpolicy) { out.TypeMeta = in.TypeMeta out.ObjectMeta = in.ObjectMeta out.Spec = PgpolicySpec{ - Name: in.Spec.Name, - URL: in.Spec.URL, - SQL: in.Spec.SQL, - Status: in.Spec.Status, + Namespace: in.Spec.Namespace, + Name: in.Spec.Name, + URL: in.Spec.URL, + SQL: in.Spec.SQL, + Status: in.Spec.Status, } out.Status = in.Status } @@ -236,6 +243,7 @@ func (in *Pgtask) DeepCopyInto(out *Pgtask) { out.TypeMeta = in.TypeMeta out.ObjectMeta = in.ObjectMeta out.Spec = PgtaskSpec{ + Namespace: in.Spec.Namespace, Name: in.Spec.Name, StorageSpec: in.Spec.StorageSpec, TaskType: in.Spec.TaskType, diff --git a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/policy.go b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/policy.go index 3c7478d..509e3bb 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/policy.go +++ b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/policy.go @@ -24,10 +24,11 @@ const PgpolicyResourcePlural = "pgpolicies" // PgpolicySpec ... type PgpolicySpec struct { - Name string `json:"name"` - URL string `json:"url"` - SQL string `json:"sql"` - Status string `json:"status"` + Namespace string `json:"namespace"` + Name string `json:"name"` + URL string `json:"url"` + SQL string `json:"sql"` + Status string `json:"status"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -60,7 +61,7 @@ type PgpolicyState string const ( // PgpolicyStateCreated ... - PgpolicyStateCreated PgpolicyState = "Created" + PgpolicyStateCreated PgpolicyState = "pgpolicy Created" // PgpolicyStateProcessed ... - PgpolicyStateProcessed PgpolicyState = "Processed" + PgpolicyStateProcessed PgpolicyState = "pgpolicy Processed" ) diff --git a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/replica.go b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/replica.go index 247cf81..a9ae014 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/replica.go +++ b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/replica.go @@ -33,6 +33,7 @@ type Pgreplica struct { // PgreplicaSpec ... type PgreplicaSpec struct { + Namespace string `json:"namespace"` Name string `json:"name"` ClusterName string `json:"clustername"` ReplicaStorage PgStorageSpec `json:"replicastorage"` @@ -61,7 +62,7 @@ type PgreplicaState string const ( // PgreplicaStateCreated ... - PgreplicaStateCreated PgreplicaState = "Created" + PgreplicaStateCreated PgreplicaState = "pgreplica Created" // PgreplicaStateProcessed ... - PgreplicaStateProcessed PgreplicaState = "Processed" + PgreplicaStateProcessed PgreplicaState = "pgreplica Processed" ) diff --git a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/task.go b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/task.go index d0b8fe3..bf81c19 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/task.go +++ b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/task.go @@ -51,8 +51,14 @@ const PgtaskBackrestInfo = "info" const PgtaskBackrestRestore = "restore" const PgtaskBackrestStanzaCreate = "stanza-create" +const PgtaskpgDump = "pgdump" +const PgtaskpgDumpBackup = "pgdumpbackup" +const PgtaskpgDumpInfo = "pgdumpinfo" +const PgtaskpgRestore = "pgrestore" + // PgtaskSpec ... type PgtaskSpec struct { + Namespace string `json:"namespace"` Name string `json:"name"` StorageSpec PgStorageSpec `json:"storagespec"` TaskType string `json:"tasktype"` @@ -91,7 +97,7 @@ type PgtaskState string const ( // PgtaskStateCreated ... - PgtaskStateCreated PgtaskState = "Created" + PgtaskStateCreated PgtaskState = "pgtask Created" // PgtaskStateProcessed ... - PgtaskStateProcessed PgtaskState = "Processed" + PgtaskStateProcessed PgtaskState = "pgtask Processed" ) diff --git a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/upgrade.go b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/upgrade.go index 85d3e34..55a9812 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/upgrade.go +++ b/vendor/github.com/crunchydata/postgres-operator/apis/cr/v1/upgrade.go @@ -30,11 +30,13 @@ const PgupgradeResourcePlural = "pgupgrades" // PgupgradeSpec ... type PgupgradeSpec struct { + Namespace string `json:"namespace"` Name string `json:"name"` ResourceType string `json:"resourcetype"` UpgradeType string `json:"upgradetype"` UpgradeStatus string `json:"upgradestatus"` StorageSpec PgStorageSpec `json:"storagespec"` + CCPImage string `json:"ccpimage"` CCPImageTag string `json:"ccpimagetag"` OldDatabaseName string `json:"olddatabasename"` NewDatabaseName string `json:"newdatabasename"` @@ -74,7 +76,7 @@ type PgupgradeStatus struct { type PgupgradeState string // PgupgradeStateCreated ... -const PgupgradeStateCreated PgupgradeState = "Created" +const PgupgradeStateCreated PgupgradeState = "pgupgrade Created" // PgupgradeStateProcessed ... -const PgupgradeStateProcessed PgupgradeState = "Processed" +const PgupgradeStateProcessed PgupgradeState = "pgupgrade Processed" diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/backrestmsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/backrestmsgs.go index b568053..85aa40a 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/backrestmsgs.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/backrestmsgs.go @@ -15,10 +15,6 @@ See the License for the specific language governing permissions and limitations under the License. */ -import ( -//crv1 "github.com/crunchydata/postgres-operator/apis/cr/v1" -) - // CreateBackrestBackupResponse ... type CreateBackrestBackupResponse struct { Results []string @@ -52,8 +48,10 @@ type RestoreResponse struct { // RestoreRequest ... type RestoreRequest struct { + Namespace string FromCluster string ToPVC string RestoreOpts string PITRTarget string + NodeLabel string } diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/clustermsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/clustermsgs.go index babb1c8..67ff7d6 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/clustermsgs.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/clustermsgs.go @@ -30,6 +30,7 @@ type CreateClusterRequest struct { UserLabels string BackupPath string Policies string + CCPImage string CCPImageTag string Series int ReplicaCount int diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/common.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/common.go index 64041d6..2d918c2 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/common.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/common.go @@ -1,7 +1,7 @@ package apiservermsgs /* -Copyright 2017 Crunchy Data Solutions, Inc. +Copyright 2019 Crunchy Data Solutions, Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -17,7 +17,7 @@ limitations under the License. import () -const PGO_VERSION = "3.5.0" +const PGO_VERSION = "3.5.1" // Ok status const Ok = "ok" diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/failovermsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/failovermsgs.go index 9788735..8a9a1ab 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/failovermsgs.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/failovermsgs.go @@ -43,6 +43,7 @@ type CreateFailoverResponse struct { // CreateFailoverRequest ... type CreateFailoverRequest struct { + Namespace string ClusterName string AutofailReplaceReplica string Target string diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgbouncermsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgbouncermsgs.go index ab9c937..4c1d08e 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgbouncermsgs.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgbouncermsgs.go @@ -21,6 +21,7 @@ import () type CreatePgbouncerRequest struct { Args []string Selector string + Namespace string ClientVersion string } @@ -34,6 +35,7 @@ type CreatePgbouncerResponse struct { type DeletePgbouncerRequest struct { Args []string Selector string + Namespace string ClientVersion string } diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgdumpmsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgdumpmsgs.go new file mode 100644 index 0000000..8f66eca --- /dev/null +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgdumpmsgs.go @@ -0,0 +1,51 @@ +package apiservermsgs + +/* +Copyright 2017-2019 Crunchy Data Solutions, Inc. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +//crv1 "github.com/crunchydata/postgres-operator/apis/cr/v1" + +type CreatepgDumpBackupResponse struct { + Results []string + Status +} + +type CreatepgDumpBackupRequest struct { + Namespace string + Args []string + Selector string + PVCName string + StorageConfig string + BackupOpts string +} + +type ShowpgDumpDetail struct { + Name string + Info string +} + +type PgRestoreResponse struct { + Results []string + Status +} + +type PgRestoreRequest struct { + Namespace string + FromCluster string + FromPVC string + RestoreOpts string + PITRTarget string + NodeLabel string +} diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgpoolmsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgpoolmsgs.go index 0792d15..e23faee 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgpoolmsgs.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/pgpoolmsgs.go @@ -21,6 +21,8 @@ import () type CreatePgpoolRequest struct { Args []string Selector string + PgpoolSecret string + Namespace string ClientVersion string } @@ -34,6 +36,7 @@ type CreatePgpoolResponse struct { type DeletePgpoolRequest struct { Args []string Selector string + Namespace string ClientVersion string } diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/policymsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/policymsgs.go index b7f533a..2a8423b 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/policymsgs.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/policymsgs.go @@ -61,6 +61,6 @@ type ShowPolicyResponse struct { // DeletePolicyResponse ... type DeletePolicyResponse struct { - PolicyList crv1.PgpolicyList + Results []string Status } diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/schedulemsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/schedulemsgs.go index 847914e..05d38aa 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/schedulemsgs.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/schedulemsgs.go @@ -19,6 +19,7 @@ limitations under the License. type CreateScheduleRequest struct { ClusterName string Name string + Namespace string Schedule string ScheduleType string Selector string @@ -37,12 +38,14 @@ type CreateScheduleResponse struct { } type DeleteScheduleRequest struct { + Namespace string ScheduleName string ClusterName string Selector string } type ShowScheduleRequest struct { + Namespace string ScheduleName string ClusterName string Selector string diff --git a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/usermsgs.go b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/usermsgs.go index 4b2deee..76726e2 100644 --- a/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/usermsgs.go +++ b/vendor/github.com/crunchydata/postgres-operator/apiservermsgs/usermsgs.go @@ -53,6 +53,7 @@ type UserResponse struct { // CreateUserRequest ... type CreateUserRequest struct { Name string + Namespace string Selector string Password string ManagedUser bool diff --git a/vendor/github.com/crunchydata/postgres-operator/config/pgoconfig.go b/vendor/github.com/crunchydata/postgres-operator/config/pgoconfig.go index cfbde4e..2f6c6b1 100644 --- a/vendor/github.com/crunchydata/postgres-operator/config/pgoconfig.go +++ b/vendor/github.com/crunchydata/postgres-operator/config/pgoconfig.go @@ -70,13 +70,14 @@ type ContainerResourcesStruct struct { } type PgoStruct struct { - PreferredFailoverNode string `yaml:"PreferredFailoverNode"` - AutofailSleepSeconds string `yaml:"AutofailSleepSeconds"` - Audit bool `yaml:"Audit"` - LSPVCTemplate string `yaml:"LSPVCTemplate"` - LoadTemplate string `yaml:"LoadTemplate"` - COImagePrefix string `yaml:"COImagePrefix"` - COImageTag string `yaml:"COImageTag"` + PreferredFailoverNode string `yaml:"PreferredFailoverNode"` + AutofailSleepSeconds string `yaml:"AutofailSleepSeconds"` + AutofailSleepSecondsValue int + Audit bool `yaml:"Audit"` + LSPVCTemplate string `yaml:"LSPVCTemplate"` + LoadTemplate string `yaml:"LoadTemplate"` + COImagePrefix string `yaml:"COImagePrefix"` + COImageTag string `yaml:"COImageTag"` } type PgoConfig struct { @@ -205,7 +206,7 @@ func (c *PgoConfig) Validate() error { log.Warn("Pgo.AutofailSleepSeconds not set, using default ") c.Pgo.AutofailSleepSeconds = DEFAULT_AUTOFAIL_SLEEP_SECONDS } - _, err = strconv.Atoi(c.Pgo.AutofailSleepSeconds) + c.Pgo.AutofailSleepSecondsValue, err = strconv.Atoi(c.Pgo.AutofailSleepSeconds) if err != nil { return errors.New("Pgo.AutofailSleepSeconds invalid int value found") } @@ -368,33 +369,3 @@ func (c *PgoConfig) GetContainerResource(name string) (crv1.PgContainerResources return r, err } - -/** -// GetContainerResources ... -func GetContainerResourcesJSON(resources *crv1.PgContainerResources) string { - - //test for the case where no container resources are specified - if resources.RequestsMemory == "" || resources.RequestsCPU == "" || - resources.LimitsMemory == "" || resources.LimitsCPU == "" { - return "" - } - fields := containerResourcesTemplateFields{} - fields.RequestsMemory = resources.RequestsMemory - fields.RequestsCPU = resources.RequestsCPU - fields.LimitsMemory = resources.LimitsMemory - fields.LimitsCPU = resources.LimitsCPU - - doc := bytes.Buffer{} - err := ContainerResourcesTemplate1.Execute(&doc, fields) - if err != nil { - log.Error(err.Error()) - return "" - } - - if log.GetLevel() == log.DebugLevel { - ContainerResourcesTemplate1.Execute(os.Stdout, fields) - } - - return doc.String() -} -*/ diff --git a/vendor/github.com/crunchydata/postgres-operator/kubeapi/deployment.go b/vendor/github.com/crunchydata/postgres-operator/kubeapi/deployment.go index af4d0c5..ad2843e 100644 --- a/vendor/github.com/crunchydata/postgres-operator/kubeapi/deployment.go +++ b/vendor/github.com/crunchydata/postgres-operator/kubeapi/deployment.go @@ -227,7 +227,7 @@ func AddLabelToDeployment(clientset *kubernetes.Clientset, origDeployment *v1bet log.Error(err) log.Errorf("error add label to Deployment %s=%s", key, value) } - log.Infof("add label to deployment %s=%v", key, value) + log.Debugf("add label to deployment %s=%v", key, value) return err } diff --git a/vendor/github.com/crunchydata/postgres-operator/kubeapi/pgreplica.go b/vendor/github.com/crunchydata/postgres-operator/kubeapi/pgreplica.go index 3730d86..f68f790 100644 --- a/vendor/github.com/crunchydata/postgres-operator/kubeapi/pgreplica.go +++ b/vendor/github.com/crunchydata/postgres-operator/kubeapi/pgreplica.go @@ -83,7 +83,7 @@ func Getpgreplica(client *rest.RESTClient, replica *crv1.Pgreplica, name, namesp } if err != nil { log.Error("error getting replica " + err.Error()) - return true, err + return false, err } return true, err diff --git a/vendor/github.com/crunchydata/postgres-operator/kubeapi/pgtask.go b/vendor/github.com/crunchydata/postgres-operator/kubeapi/pgtask.go index 9aefe35..debc673 100644 --- a/vendor/github.com/crunchydata/postgres-operator/kubeapi/pgtask.go +++ b/vendor/github.com/crunchydata/postgres-operator/kubeapi/pgtask.go @@ -83,7 +83,7 @@ func Getpgtask(client *rest.RESTClient, task *crv1.Pgtask, name, namespace strin } if err != nil { log.Error("error getting task " + err.Error()) - return true, err + return false, err } return true, err @@ -122,7 +122,6 @@ func Createpgtask(client *rest.RESTClient, task *crv1.Pgtask, namespace string) } log.Debugf("created pgtask %s", task.Name) - log.Debugf("pgtask result: %+v", result) return err } diff --git a/vendor/github.com/crunchydata/postgres-operator/kubeapi/pod.go b/vendor/github.com/crunchydata/postgres-operator/kubeapi/pod.go index 879940c..6d31c66 100644 --- a/vendor/github.com/crunchydata/postgres-operator/kubeapi/pod.go +++ b/vendor/github.com/crunchydata/postgres-operator/kubeapi/pod.go @@ -130,7 +130,7 @@ func AddLabelToPod(clientset *kubernetes.Clientset, origPod *v1.Pod, key, value, log.Error(err) log.Errorf("error add label to Pod %s %s=%s", origPod.Name, key, value) } - log.Infof("add label to Pod %s %s=%v", origPod.Name, key, value) + log.Debugf("add label to Pod %s %s=%v", origPod.Name, key, value) return err } diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/backrest.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/backrest.go index 5c8225e..eaa7a53 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/backrest.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/backrest.go @@ -25,10 +25,10 @@ import ( msgs "github.com/crunchydata/postgres-operator/apiservermsgs" ) -func ShowBackrest(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowBackrestResponse, error) { +func ShowBackrest(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowBackrestResponse, error) { var response msgs.ShowBackrestResponse - url := SessionCredentials.APIServerURL + "/backrest/" + arg + "?version=" + msgs.PGO_VERSION + "&selector=" + selector + url := SessionCredentials.APIServerURL + "/backrest/" + arg + "?version=" + msgs.PGO_VERSION + "&selector=" + selector + "&namespace=" + ns log.Debugf("show backrest called [%s]", url) diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/backup.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/backup.go index 84c1c14..87cd93f 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/backup.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/backup.go @@ -21,14 +21,15 @@ import ( "fmt" log "github.com/Sirupsen/logrus" msgs "github.com/crunchydata/postgres-operator/apiservermsgs" + "github.com/crunchydata/postgres-operator/util" "net/http" ) -func ShowBackup(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowBackupResponse, error) { +func ShowBackup(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowBackupResponse, error) { var response msgs.ShowBackupResponse - url := SessionCredentials.APIServerURL + "/backups/" + arg + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/backups/" + arg + "?version=" + msgs.PGO_VERSION + "&" + util.LABEL_NAMESPACE + "=" + ns log.Debugf("show backup called [%s]", url) @@ -60,10 +61,10 @@ func ShowBackup(httpclient *http.Client, arg string, SessionCredentials *msgs.Ba return response, err } -func DeleteBackup(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.DeleteBackupResponse, error) { +func DeleteBackup(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.DeleteBackupResponse, error) { var response msgs.DeleteBackupResponse - url := SessionCredentials.APIServerURL + "/backupsdelete/" + arg + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/backupsdelete/" + arg + "?version=" + msgs.PGO_VERSION + "&" + util.LABEL_NAMESPACE + "=" + ns log.Debug("delete backup called [%s]", url) diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/cluster.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/cluster.go index 72a8524..5e77964 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/cluster.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/cluster.go @@ -27,16 +27,16 @@ import ( const ( createClusterURL = "%s/clusters" - deleteClusterURL = "%s/clustersdelete/%s?selector=%s&delete-data=%t&delete-backups=%t&delete-configs=%t&version=%s" - updateClusterURL = "%s/clustersupdate/%s?selector=%s&autofail=%s&version=%s" - showClusterURL = "%s/clusters/%s?selector=%s&version=%s&ccpimagetag=%s" + deleteClusterURL = "%s/clustersdelete/%s?selector=%s&delete-data=%t&delete-backups=%t&version=%s&namespace=%s" + updateClusterURL = "%s/clustersupdate/%s?selector=%s&autofail=%s&version=%s&namespace=%s" + showClusterURL = "%s/clusters/%s?selector=%s&version=%s&ccpimagetag=%s&namespace=%s" ) -func ShowCluster(httpclient *http.Client, arg, selector, ccpimagetag string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowClusterResponse, error) { +func ShowCluster(httpclient *http.Client, arg, selector, ccpimagetag string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowClusterResponse, error) { var response msgs.ShowClusterResponse - url := fmt.Sprintf(showClusterURL, SessionCredentials.APIServerURL, arg, selector, msgs.PGO_VERSION, ccpimagetag) + url := fmt.Sprintf(showClusterURL, SessionCredentials.APIServerURL, arg, selector, msgs.PGO_VERSION, ccpimagetag, ns) log.Debugf("show cluster called [%s]", url) @@ -72,11 +72,11 @@ func ShowCluster(httpclient *http.Client, arg, selector, ccpimagetag string, Ses } -func DeleteCluster(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials, deleteData, deleteBackups, deleteConfigMaps bool) (msgs.DeleteClusterResponse, error) { +func DeleteCluster(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials, deleteData, deleteBackups bool, ns string) (msgs.DeleteClusterResponse, error) { var response msgs.DeleteClusterResponse - url := fmt.Sprintf(deleteClusterURL, SessionCredentials.APIServerURL, arg, selector, deleteData, deleteBackups, deleteConfigMaps, msgs.PGO_VERSION) + url := fmt.Sprintf(deleteClusterURL, SessionCredentials.APIServerURL, arg, selector, deleteData, deleteBackups, msgs.PGO_VERSION, ns) log.Debugf("delete cluster called %s", url) @@ -149,11 +149,11 @@ func CreateCluster(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCr return response, err } -func UpdateCluster(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials, autofailFlag string) (msgs.UpdateClusterResponse, error) { +func UpdateCluster(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials, autofailFlag, ns string) (msgs.UpdateClusterResponse, error) { var response msgs.UpdateClusterResponse - url := fmt.Sprintf(updateClusterURL, SessionCredentials.APIServerURL, arg, selector, autofailFlag, msgs.PGO_VERSION) + url := fmt.Sprintf(updateClusterURL, SessionCredentials.APIServerURL, arg, selector, autofailFlag, msgs.PGO_VERSION, ns) log.Debugf("update cluster called %s", url) diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/config.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/config.go index f3d8f7a..487f1f0 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/config.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/config.go @@ -23,11 +23,11 @@ import ( "net/http" ) -func ShowConfig(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowConfigResponse, error) { +func ShowConfig(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowConfigResponse, error) { var response msgs.ShowConfigResponse - url := SessionCredentials.APIServerURL + "/config?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/config?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debug(url) req, err := http.NewRequest("GET", url, nil) diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/df.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/df.go index ccd5fc5..479321c 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/df.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/df.go @@ -23,13 +23,13 @@ import ( "net/http" ) -func ShowDf(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.DfResponse, error) { +func ShowDf(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.DfResponse, error) { var response msgs.DfResponse log.Debugf("ShowDf called %s with selector=%s", arg, selector) - url := SessionCredentials.APIServerURL + "/df/" + arg + "?selector=" + selector + "&version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/df/" + arg + "?selector=" + selector + "&version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debug(url) req, err := http.NewRequest("GET", url, nil) diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/failover.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/failover.go index 1efe0f3..4a1b1a6 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/failover.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/failover.go @@ -62,11 +62,11 @@ func CreateFailover(httpclient *http.Client, SessionCredentials *msgs.BasicAuthC return response, err } -func QueryFailover(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.QueryFailoverResponse, error) { +func QueryFailover(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.QueryFailoverResponse, error) { var response msgs.QueryFailoverResponse - url := SessionCredentials.APIServerURL + "/failover/" + arg + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/failover/" + arg + "?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debugf("query failover called [%s]", url) action := "GET" diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/pgdump.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/pgdump.go new file mode 100644 index 0000000..12282a7 --- /dev/null +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/pgdump.go @@ -0,0 +1,102 @@ +package api + +/* + Copyright 2017-2019 Crunchy Data Solutions, Inc. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import ( + "bytes" + "encoding/json" + "fmt" + "net/http" + + log "github.com/Sirupsen/logrus" + msgs "github.com/crunchydata/postgres-operator/apiservermsgs" +) + +func ShowpgDump(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowBackupResponse, error) { + + var response msgs.ShowBackupResponse + url := SessionCredentials.APIServerURL + "/pgdump/" + arg + "?version=" + msgs.PGO_VERSION + "&selector=" + selector + "&namespace=" + ns + + log.Debugf("show pgdump called [%s]", url) + + action := "GET" + req, err := http.NewRequest(action, url, nil) + if err != nil { + return response, err + } + + req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password) + resp, err := httpclient.Do(req) + if err != nil { + fmt.Println("Error: Do: ", err) + return response, err + } + defer resp.Body.Close() + log.Debugf("%v", resp) + err = StatusCheck(resp) + if err != nil { + return response, err + } + + if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { + log.Debugf("%v", resp.Body) + log.Debug(err) + return response, err + } + + return response, err + +} + +func CreatepgDumpBackup(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCredentials, request *msgs.CreatepgDumpBackupRequest) (msgs.CreatepgDumpBackupResponse, error) { + + var response msgs.CreatepgDumpBackupResponse + + jsonValue, _ := json.Marshal(request) + + url := SessionCredentials.APIServerURL + "/pgdumpbackup" + + log.Debugf("create pgdump backup called [%s]", url) + + action := "POST" + req, err := http.NewRequest(action, url, bytes.NewBuffer(jsonValue)) + if err != nil { + return response, err + } + req.Header.Set("Content-Type", "application/json") + req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password) + + resp, err := httpclient.Do(req) + if err != nil { + return response, err + } + defer resp.Body.Close() + + log.Debugf("%v", resp) + err = StatusCheck(resp) + if err != nil { + return response, err + } + + if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { + log.Printf("%v\n", resp.Body) + fmt.Println("Error: ", err) + log.Println(err) + return response, err + } + + return response, err +} diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/policy.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/policy.go index f57e990..7132b80 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/policy.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/policy.go @@ -24,11 +24,11 @@ import ( "net/http" ) -func ShowPolicy(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowPolicyResponse, error) { +func ShowPolicy(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowPolicyResponse, error) { var response msgs.ShowPolicyResponse - url := SessionCredentials.APIServerURL + "/policies/" + arg + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/policies/" + arg + "?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debugf("showPolicy called...[%s]", url) action := "GET" @@ -102,11 +102,11 @@ func CreatePolicy(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCre return resp, err } -func DeletePolicy(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.DeletePolicyResponse, error) { +func DeletePolicy(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.DeletePolicyResponse, error) { var response msgs.DeletePolicyResponse - url := SessionCredentials.APIServerURL + "/policiesdelete/" + arg + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/policiesdelete/" + arg + "?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debugf("delete policy called [%s]", url) diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/pvc.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/pvc.go index e9fea6b..6392fd1 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/pvc.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/pvc.go @@ -23,11 +23,11 @@ import ( "net/http" ) -func ShowPVC(httpclient *http.Client, pvcName, pvcRoot string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowPVCResponse, error) { +func ShowPVC(httpclient *http.Client, pvcName, pvcRoot string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowPVCResponse, error) { var response msgs.ShowPVCResponse - url := SessionCredentials.APIServerURL + "/pvc/" + pvcName + "?pvcroot=" + pvcRoot + "&version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/pvc/" + pvcName + "?pvcroot=" + pvcRoot + "&version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debugf("ShowPVC called...[%s]", url) action := "GET" diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/restoreDump.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/restoreDump.go new file mode 100644 index 0000000..4557003 --- /dev/null +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/restoreDump.go @@ -0,0 +1,62 @@ +package api + +/* + Copyright 2017 Crunchy Data Solutions, Inc. + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +import ( + "bytes" + "encoding/json" + log "github.com/Sirupsen/logrus" + msgs "github.com/crunchydata/postgres-operator/apiservermsgs" + "net/http" +) + +func RestoreDump(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCredentials, request *msgs.PgRestoreRequest) (msgs.RestoreResponse, error) { + + var response msgs.RestoreResponse + + jsonValue, _ := json.Marshal(request) + url := SessionCredentials.APIServerURL + "/pgdumprestore" + + log.Debugf("restore dump called [%s]", url) + + action := "POST" + req, err := http.NewRequest(action, url, bytes.NewBuffer(jsonValue)) + if err != nil { + return response, err + } + req.Header.Set("Content-Type", "application/json") + req.SetBasicAuth(SessionCredentials.Username, SessionCredentials.Password) + + resp, err := httpclient.Do(req) + if err != nil { + return response, err + } + defer resp.Body.Close() + + log.Debugf("%v", resp) + err = StatusCheck(resp) + if err != nil { + return response, err + } + + if err := json.NewDecoder(resp.Body).Decode(&response); err != nil { + log.Printf("%v\n", resp.Body) + log.Println(err) + return response, err + } + + return response, err +} diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/scale.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/scale.go index acfc378..03ed672 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/scale.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/scale.go @@ -24,11 +24,11 @@ import ( "strconv" ) -func ScaleCluster(httpclient *http.Client, arg string, ReplicaCount int, ContainerResources, StorageConfig, NodeLabel, CCPImageTag, ServiceType string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ClusterScaleResponse, error) { +func ScaleCluster(httpclient *http.Client, arg string, ReplicaCount int, ContainerResources, StorageConfig, NodeLabel, CCPImageTag, ServiceType string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ClusterScaleResponse, error) { var response msgs.ClusterScaleResponse - url := SessionCredentials.APIServerURL + "/clusters/scale/" + arg + "?replica-count=" + strconv.Itoa(ReplicaCount) + "&resources-config=" + ContainerResources + "&storage-config=" + StorageConfig + "&node-label=" + NodeLabel + "&version=" + msgs.PGO_VERSION + "&ccp-image-tag=" + CCPImageTag + "&service-type=" + ServiceType + url := SessionCredentials.APIServerURL + "/clusters/scale/" + arg + "?replica-count=" + strconv.Itoa(ReplicaCount) + "&resources-config=" + ContainerResources + "&storage-config=" + StorageConfig + "&node-label=" + NodeLabel + "&version=" + msgs.PGO_VERSION + "&ccp-image-tag=" + CCPImageTag + "&service-type=" + ServiceType + "&namespace=" + ns log.Debug(url) action := "GET" diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/scaledown.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/scaledown.go index 53654a1..8c7f524 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/scaledown.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/scaledown.go @@ -25,10 +25,10 @@ import ( "strconv" ) -func ScaleDownCluster(httpclient *http.Client, clusterName, ScaleDownTarget string, DeleteData bool, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ScaleDownResponse, error) { +func ScaleDownCluster(httpclient *http.Client, clusterName, ScaleDownTarget string, DeleteData bool, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ScaleDownResponse, error) { var response msgs.ScaleDownResponse - url := SessionCredentials.APIServerURL + "/scaledown/" + clusterName + "?version=" + msgs.PGO_VERSION + "&" + util.LABEL_REPLICA_NAME + "=" + ScaleDownTarget + "&" + util.LABEL_DELETE_DATA + "=" + strconv.FormatBool(DeleteData) + url := SessionCredentials.APIServerURL + "/scaledown/" + clusterName + "?version=" + msgs.PGO_VERSION + "&" + util.LABEL_REPLICA_NAME + "=" + ScaleDownTarget + "&" + util.LABEL_DELETE_DATA + "=" + strconv.FormatBool(DeleteData) + "&namespace=" + ns log.Debug(url) action := "GET" @@ -60,11 +60,11 @@ func ScaleDownCluster(httpclient *http.Client, clusterName, ScaleDownTarget stri } -func ScaleQuery(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ScaleQueryResponse, error) { +func ScaleQuery(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ScaleQueryResponse, error) { var response msgs.ScaleQueryResponse - url := SessionCredentials.APIServerURL + "/scale/" + arg + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/scale/" + arg + "?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debug(url) action := "GET" diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/status.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/status.go index 5dc4770..0ff3230 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/status.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/status.go @@ -23,10 +23,10 @@ import ( "net/http" ) -func ShowStatus(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCredentials) (msgs.StatusResponse, error) { +func ShowStatus(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.StatusResponse, error) { var response msgs.StatusResponse - url := SessionCredentials.APIServerURL + "/status?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/status?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debug(url) action := "GET" diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/test.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/test.go index 8da1e6d..517414c 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/test.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/test.go @@ -23,11 +23,11 @@ import ( "net/http" ) -func ShowTest(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ClusterTestResponse, error) { +func ShowTest(httpclient *http.Client, arg, selector string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ClusterTestResponse, error) { var response msgs.ClusterTestResponse - url := SessionCredentials.APIServerURL + "/clusters/test/" + arg + "?selector=" + selector + "&version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/clusters/test/" + arg + "?selector=" + selector + "&version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debug(url) action := "GET" diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/upgrade.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/upgrade.go index 3d72c6f..52ef974 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/upgrade.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/upgrade.go @@ -24,11 +24,11 @@ import ( "net/http" ) -func ShowUpgrade(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowUpgradeResponse, error) { +func ShowUpgrade(httpclient *http.Client, arg string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowUpgradeResponse, error) { var response msgs.ShowUpgradeResponse - url := SessionCredentials.APIServerURL + "/upgrades/" + arg + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/upgrades/" + arg + "?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debugf("showUpgrade called...[%s]", url) action := "GET" @@ -97,11 +97,11 @@ func CreateUpgrade(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCr return response, err } -func DeleteUpgrade(httpclient *http.Client, v string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.DeleteUpgradeResponse, error) { +func DeleteUpgrade(httpclient *http.Client, v string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.DeleteUpgradeResponse, error) { var response msgs.DeleteUpgradeResponse - url := SessionCredentials.APIServerURL + "/upgradesdelete/" + v + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/upgradesdelete/" + v + "?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debugf("deleteUpgrade called...[%s]", url) action := "GET" diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/user.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/user.go index 30e8ace..4e8cb68 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/user.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/user.go @@ -24,11 +24,11 @@ import ( "net/http" ) -func ShowUser(httpclient *http.Client, arg, selector, expired string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowUserResponse, error) { +func ShowUser(httpclient *http.Client, arg, selector, expired string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowUserResponse, error) { var response msgs.ShowUserResponse - url := SessionCredentials.APIServerURL + "/users/" + arg + "?selector=" + selector + "&version=" + msgs.PGO_VERSION + "&expired=" + expired + url := SessionCredentials.APIServerURL + "/users/" + arg + "?selector=" + selector + "&version=" + msgs.PGO_VERSION + "&expired=" + expired + "&namespace=" + ns log.Debugf("show users called [%s]", url) @@ -97,11 +97,11 @@ func CreateUser(httpclient *http.Client, SessionCredentials *msgs.BasicAuthCrede return response, err } -func DeleteUser(httpclient *http.Client, username, selector string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.DeleteClusterResponse, error) { +func DeleteUser(httpclient *http.Client, username, selector string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.DeleteClusterResponse, error) { var response msgs.DeleteClusterResponse - url := SessionCredentials.APIServerURL + "/usersdelete/" + username + "?selector=" + selector + "&version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/usersdelete/" + username + "?selector=" + selector + "&version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debugf("delete users called [%s]", url) diff --git a/vendor/github.com/crunchydata/postgres-operator/pgo/api/workflow.go b/vendor/github.com/crunchydata/postgres-operator/pgo/api/workflow.go index c218656..518aab7 100644 --- a/vendor/github.com/crunchydata/postgres-operator/pgo/api/workflow.go +++ b/vendor/github.com/crunchydata/postgres-operator/pgo/api/workflow.go @@ -23,11 +23,11 @@ import ( "net/http" ) -func ShowWorkflow(httpclient *http.Client, workflowID string, SessionCredentials *msgs.BasicAuthCredentials) (msgs.ShowWorkflowResponse, error) { +func ShowWorkflow(httpclient *http.Client, workflowID string, SessionCredentials *msgs.BasicAuthCredentials, ns string) (msgs.ShowWorkflowResponse, error) { var response msgs.ShowWorkflowResponse - url := SessionCredentials.APIServerURL + "/workflow/" + workflowID + "?version=" + msgs.PGO_VERSION + url := SessionCredentials.APIServerURL + "/workflow/" + workflowID + "?version=" + msgs.PGO_VERSION + "&namespace=" + ns log.Debugf("ShowWorkflow called...[%s]", url) action := "GET" diff --git a/vendor/github.com/crunchydata/postgres-operator/util/labels.go b/vendor/github.com/crunchydata/postgres-operator/util/labels.go index e191249..fdaa8e9 100644 --- a/vendor/github.com/crunchydata/postgres-operator/util/labels.go +++ b/vendor/github.com/crunchydata/postgres-operator/util/labels.go @@ -24,6 +24,7 @@ const LABEL_OPERATOR = "postgres-operator" const LABEL_PG_CLUSTER = "pg-cluster" const LABEL_PG_DATABASE = "pg-database" const LABEL_PGBACKUP = "pgbackup" +const LABEL_PGTASK = "pg-task" const LABEL_AUTOFAIL = "autofail" const LABEL_AUTOFAIL_REPLACE_REPLICA = "autofail-replace-replica" @@ -44,6 +45,7 @@ const LABEL_NODE_LABEL_KEY = "NodeLabelKey" const LABEL_NODE_LABEL_VALUE = "NodeLabelValue" const LABEL_REPLICA_NAME = "replica-name" const LABEL_CCP_IMAGE_TAG_KEY = "ccp-image-tag" +const LABEL_CCP_IMAGE_KEY = "ccp-image" const LABEL_SERVICE_TYPE = "service-type" const LABEL_REPLICA_COUNT = "replica-count" @@ -69,6 +71,28 @@ const LABEL_BACKREST_PITR_TARGET = "backrest-pitr-target" const LABEL_BADGER = "crunchy-pgbadger" const LABEL_BACKUP_TYPE_BASEBACKUP = "pgbasebackup" const LABEL_BACKUP_TYPE_BACKREST = "pgbackrest" +const LABEL_BACKUP_TYPE_PGDUMP = "pgdump" + +const LABEL_PGDUMP_COMMAND = "pgdump" +const LABEL_PGDUMP_RESTORE = "pgdump-restore" +const LABEL_PGDUMP_OPTS = "pgdump-opts" +const LABEL_PGDUMP_HOST = "pgdump-host" +const LABEL_PGDUMP_DB = "pgdump-db" +const LABEL_PGDUMP_USER = "pgdump-user" +const LABEL_PGDUMP_PORT = "pgdump-port" +const LABEL_PGDUMP_ALL = "pgdump-all" +const LABEL_PGDUMP_PVC = "pgdump-pvc" + +const LABEL_RESTORE_TYPE_PGRESTORE = "pgrestore" +const LABEL_PGRESTORE_COMMAND = "pgrestore" +const LABEL_PGRESTORE_HOST = "pgrestore-host" +const LABEL_PGRESTORE_DB = "pgrestore-db" +const LABEL_PGRESTORE_USER = "pgrestore-user" +const LABEL_PGRESTORE_PORT = "pgrestore-port" +const LABEL_PGRESTORE_FROM_CLUSTER = "pgrestore-from-cluster" +const LABEL_PGRESTORE_FROM_PVC = "pgrestore-from-pvc" +const LABEL_PGRESTORE_OPTS = "pgrestore-opts" +const LABEL_PGRESTORE_PITR_TARGET = "pgrestore-pitr-target" const LABEL_DATA_ROOT = "data-root" const LABEL_PVC_NAME = "pvc-name" @@ -107,3 +131,5 @@ const LABEL_CLAIM_NAME = "claimName" const LABEL_TRUE = "true" const LABEL_FALSE = "false" + +const LABEL_NAMESPACE = "namespace" diff --git a/vendor/github.com/crunchydata/postgres-operator/util/policy.go b/vendor/github.com/crunchydata/postgres-operator/util/policy.go index 15b0739..df6cb95 100644 --- a/vendor/github.com/crunchydata/postgres-operator/util/policy.go +++ b/vendor/github.com/crunchydata/postgres-operator/util/policy.go @@ -50,7 +50,10 @@ func ExecPolicy(clientset *kubernetes.Clientset, restclient *rest.RESTClient, na //lastly, run the psql script log.Debugf("running psql password=%s ip=%s sql=[%s]", password, service.Spec.ClusterIP, sqlString) - RunPsql(password, service.Spec.ClusterIP, sqlString) + err = RunPsql(password, service.Spec.ClusterIP, sqlString) + if err != nil { + return err + } return nil diff --git a/vendor/github.com/crunchydata/postgres-operator/util/util.go b/vendor/github.com/crunchydata/postgres-operator/util/util.go index 8146d27..7cfd4c0 100644 --- a/vendor/github.com/crunchydata/postgres-operator/util/util.go +++ b/vendor/github.com/crunchydata/postgres-operator/util/util.go @@ -43,7 +43,6 @@ import ( const letterBytes = "abcdefghijklmnopqrstuvwxyz" const GLOBAL_CUSTOM_CONFIGMAP = "pgo-custom-pg-config" -const GLOBAL_PGBACKREST_CUSTOM_CONFIGMAP = "pgo-pgbackrest-config" func init() { rand.Seed(time.Now().UnixNano()) @@ -274,7 +273,7 @@ func PatchClusterCRD(restclient *rest.RESTClient, labelMap map[string]string, ol } // RunPsql runs a psql statement -func RunPsql(password string, hostip string, sqlstring string) { +func RunPsql(password string, hostip string, sqlstring string) error { log.Debugf("RunPsql hostip=[%s] sql=[%s]", hostip, sqlstring) cmd := exec.Command("runpsql.sh", password, hostip) @@ -290,10 +289,17 @@ func RunPsql(password string, hostip string, sqlstring string) { log.Error("error in run cmd " + err.Error()) log.Error(out.String()) log.Error(stderr.String()) - return + return err + } + + if stderr.String() != "" { + log.Errorf("stderror in run cmd %s", stderr.String()) + log.Error(out.String()) + return errors.New("SQL error: " + stderr.String()) } log.Debugf("runpsql output [%s]", out.String()[0:20]) + return err } // GetSecretPassword ...