From fe9b037e526d14d6da1c829015fa6599368a308f Mon Sep 17 00:00:00 2001 From: tamal Date: Tue, 4 Jul 2017 07:10:20 -0700 Subject: [PATCH 1/2] Allow setting resources for StatefulSet or Snapshot/Restore jobs --- glide.lock | 8 ++++---- vendor/github.com/k8sdb/apimachinery/api/elastic_types.go | 3 +++ .../github.com/k8sdb/apimachinery/api/postgres_types.go | 2 ++ .../github.com/k8sdb/apimachinery/api/snapshot_types.go | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/glide.lock b/glide.lock index 50c522336..ce35f40ea 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: b737760e0f81a2850433fe5b9a0ddc1d6b15d93a1207fe0a607313978062c265 -updated: 2017-07-03T13:45:01.621025584-07:00 +updated: 2017-07-04T07:07:58.670833568-07:00 imports: - name: cloud.google.com/go version: fe3d41e1ecb2ce36ad3a979037c9b9a2b726226f @@ -212,7 +212,7 @@ imports: - name: github.com/juju/ratelimit version: 77ed1c8a01217656d2080ad51981f6e99adaa177 - name: github.com/k8sdb/apimachinery - version: cfbc99b5853355232cb2c6528aa9add2a28eeb4c + version: c56aea3eda424defd1069a05a76757d99da08ac2 subpackages: - api - api/install @@ -224,11 +224,11 @@ imports: - pkg/storage - pkg/validator - name: github.com/k8sdb/elasticsearch - version: 20f613b1ed7153e60352099b75434ea86152c706 + version: 961199034185482f9ce934ea147d4f09701e5cbc subpackages: - pkg/validator - name: github.com/k8sdb/postgres - version: e912a28c494089aff29b4bc4444fe9b1af4ff2e9 + version: 1eb1c1f1f29342e8571caf081d0743870f689c0e subpackages: - pkg/validator - name: github.com/mailru/easyjson diff --git a/vendor/github.com/k8sdb/apimachinery/api/elastic_types.go b/vendor/github.com/k8sdb/apimachinery/api/elastic_types.go index 987d96319..d20c88f3f 100644 --- a/vendor/github.com/k8sdb/apimachinery/api/elastic_types.go +++ b/vendor/github.com/k8sdb/apimachinery/api/elastic_types.go @@ -3,6 +3,7 @@ package api import ( "github.com/appscode/go/encoding/json/types" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apiv1 "k8s.io/client-go/pkg/api/v1" ) const ( @@ -43,6 +44,8 @@ type ElasticSpec struct { // Monitor is used monitor database instance // +optional Monitor *MonitorSpec `json:"monitor,omitempty"` + // Compute Resources required by the sidecar container. + Resources apiv1.ResourceRequirements `json:"resources,omitempty"` } type ElasticStatus struct { diff --git a/vendor/github.com/k8sdb/apimachinery/api/postgres_types.go b/vendor/github.com/k8sdb/apimachinery/api/postgres_types.go index 7149509da..6a34f83c6 100644 --- a/vendor/github.com/k8sdb/apimachinery/api/postgres_types.go +++ b/vendor/github.com/k8sdb/apimachinery/api/postgres_types.go @@ -44,6 +44,8 @@ type PostgresSpec struct { // Monitor is used monitor database instance // +optional Monitor *MonitorSpec `json:"monitor,omitempty"` + // Compute Resources required by the sidecar container. + Resources apiv1.ResourceRequirements `json:"resources,omitempty"` } type PostgresStatus struct { diff --git a/vendor/github.com/k8sdb/apimachinery/api/snapshot_types.go b/vendor/github.com/k8sdb/apimachinery/api/snapshot_types.go index 12b298b37..0ec940f74 100644 --- a/vendor/github.com/k8sdb/apimachinery/api/snapshot_types.go +++ b/vendor/github.com/k8sdb/apimachinery/api/snapshot_types.go @@ -2,6 +2,7 @@ package api import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + apiv1 "k8s.io/client-go/pkg/api/v1" ) const ( @@ -23,6 +24,8 @@ type SnapshotSpec struct { DatabaseName string `json:"databaseName,omitempty"` // Snapshot Spec SnapshotStorageSpec `json:",inline,omitempty"` + // Compute Resources required by the sidecar container. + Resources apiv1.ResourceRequirements `json:"resources,omitempty"` } type SnapshotPhase string From 920d083b205c411aa5da05081725c662f5e2e19d Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Thu, 6 Jul 2017 02:35:11 -0700 Subject: [PATCH 2/2] Revendor apimachinery (#84) --- glide.lock | 12 +- pkg/describer/k8sdb_describer.go | 20 +- pkg/printer/resource_printer.go | 10 +- .../k8sdb/apimachinery/api/helpers.go | 144 +++++++++++++ .../k8sdb/apimachinery/api/register.go | 8 +- .../k8sdb/apimachinery/api/types.go | 7 +- .../apimachinery/pkg/controller/controller.go | 5 +- .../k8sdb/apimachinery/pkg/controller/cron.go | 15 +- .../k8sdb/apimachinery/pkg/controller/lib.go | 6 +- .../apimachinery/pkg/controller/snapshot.go | 11 +- .../k8sdb/apimachinery/pkg/storage/osm.go | 34 +-- vendor/gopkg.in/yaml.v2/LICENSE | 195 +++++++++++++++++- vendor/gopkg.in/yaml.v2/decode.go | 3 +- vendor/gopkg.in/yaml.v2/emitterc.go | 1 + vendor/gopkg.in/yaml.v2/parserc.go | 1 + vendor/gopkg.in/yaml.v2/readerc.go | 7 +- vendor/gopkg.in/yaml.v2/resolve.go | 11 +- vendor/gopkg.in/yaml.v2/scannerc.go | 4 +- vendor/gopkg.in/yaml.v2/yaml.go | 2 +- vendor/k8s.io/kubernetes/pkg/api/helpers.go | 1 + vendor/k8s.io/kubernetes/pkg/version/base.go | 2 +- 21 files changed, 393 insertions(+), 106 deletions(-) create mode 100644 vendor/github.com/k8sdb/apimachinery/api/helpers.go diff --git a/glide.lock b/glide.lock index ce35f40ea..52bbd0f03 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: b737760e0f81a2850433fe5b9a0ddc1d6b15d93a1207fe0a607313978062c265 -updated: 2017-07-04T07:07:58.670833568-07:00 +updated: 2017-07-05T22:25:51.546855959-07:00 imports: - name: cloud.google.com/go version: fe3d41e1ecb2ce36ad3a979037c9b9a2b726226f @@ -212,7 +212,7 @@ imports: - name: github.com/juju/ratelimit version: 77ed1c8a01217656d2080ad51981f6e99adaa177 - name: github.com/k8sdb/apimachinery - version: c56aea3eda424defd1069a05a76757d99da08ac2 + version: 2c5b02dc26b3858700248bdc5a955d27d29390a7 subpackages: - api - api/install @@ -224,11 +224,11 @@ imports: - pkg/storage - pkg/validator - name: github.com/k8sdb/elasticsearch - version: 961199034185482f9ce934ea147d4f09701e5cbc + version: a27fcd5c3adfb8d0d9c6e30964252f12b20daf5c subpackages: - pkg/validator - name: github.com/k8sdb/postgres - version: 1eb1c1f1f29342e8571caf081d0743870f689c0e + version: 9597d0a7fd1027cd1d06b5dbafeb311596c380ab subpackages: - pkg/validator - name: github.com/mailru/easyjson @@ -348,7 +348,7 @@ imports: - name: gopkg.in/robfig/cron.v2 version: be2e0b0deed5a68ffee390b4583a13aff8321535 - name: gopkg.in/yaml.v2 - version: cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b + version: 53feefa2559fb8dfa8d81baad31be332c97d6c77 - name: k8s.io/apimachinery version: 75b8dd260ef0469d96d578705a87cffd0e09dab8 subpackages: @@ -505,7 +505,7 @@ imports: - util/integer - util/jsonpath - name: k8s.io/kubernetes - version: 7fa1c1756d8bc963f1a389f4a6937dc71f08ada2 + version: 095136c3078ccf887b9034b7ce598a0a1faff769 subpackages: - federation/apis/federation - federation/apis/federation/install diff --git a/pkg/describer/k8sdb_describer.go b/pkg/describer/k8sdb_describer.go index f5a582180..c117bace2 100644 --- a/pkg/describer/k8sdb_describer.go +++ b/pkg/describer/k8sdb_describer.go @@ -6,8 +6,6 @@ import ( "github.com/golang/glog" tapi "github.com/k8sdb/apimachinery/api" - amc "github.com/k8sdb/apimachinery/pkg/controller" - "github.com/k8sdb/apimachinery/pkg/storage" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/pkg/api" @@ -26,8 +24,8 @@ func (d *humanReadableDescriber) describeElastic(item *tapi.Elastic, describerSe metav1.ListOptions{ LabelSelector: labels.SelectorFromSet( map[string]string{ - amc.LabelDatabaseKind: tapi.ResourceKindElastic, - amc.LabelDatabaseName: item.Name, + tapi.LabelDatabaseKind: tapi.ResourceKindElastic, + tapi.LabelDatabaseName: item.Name, }, ).String(), }, @@ -96,8 +94,8 @@ func (d *humanReadableDescriber) describePostgres(item *tapi.Postgres, describer metav1.ListOptions{ LabelSelector: labels.SelectorFromSet( map[string]string{ - amc.LabelDatabaseKind: tapi.ResourceKindPostgres, - amc.LabelDatabaseName: item.Name, + tapi.LabelDatabaseKind: tapi.ResourceKindPostgres, + tapi.LabelDatabaseName: item.Name, }, ).String(), }, @@ -215,8 +213,8 @@ func (d *humanReadableDescriber) describeDormantDatabase(item *tapi.DormantDatab metav1.ListOptions{ LabelSelector: labels.SelectorFromSet( map[string]string{ - amc.LabelDatabaseKind: item.Labels[amc.LabelDatabaseKind], - amc.LabelDatabaseName: item.Name, + tapi.LabelDatabaseKind: item.Labels[tapi.LabelDatabaseKind], + tapi.LabelDatabaseName: item.Name, }, ).String(), }, @@ -321,9 +319,13 @@ func listSnapshots(snapshotList *tapi.SnapshotList, out io.Writer) { fmt.Fprint(w, " Name\tBucket\tStartTime\tCompletionTime\tPhase\n") fmt.Fprint(w, " ----\t------\t---------\t--------------\t-----\n") for _, e := range snapshotList.Items { + location, err := e.Spec.SnapshotStorageSpec.Location() + if err != nil { + location = "" + } fmt.Fprintf(w, " %s\t%s\t%s\t%s\t%s\n", e.Name, - storage.GetLocation(e.Spec.SnapshotStorageSpec), + location, timeToString(e.Status.StartTime), timeToString(e.Status.CompletionTime), e.Status.Phase, diff --git a/pkg/printer/resource_printer.go b/pkg/printer/resource_printer.go index 5f3155157..24dde851e 100644 --- a/pkg/printer/resource_printer.go +++ b/pkg/printer/resource_printer.go @@ -12,8 +12,6 @@ import ( "github.com/golang/glog" tapi "github.com/k8sdb/apimachinery/api" "github.com/k8sdb/apimachinery/client/clientset" - amc "github.com/k8sdb/apimachinery/pkg/controller" - "github.com/k8sdb/apimachinery/pkg/storage" "github.com/k8sdb/cli/pkg/decoder" "github.com/k8sdb/cli/pkg/util" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -261,7 +259,7 @@ func (h *HumanReadablePrinter) printSnapshot(item *tapi.Snapshot, w io.Writer, o status = statusUnknown } - short, found := util.ResourceShortFormFor(item.Labels[amc.LabelDatabaseKind]) + short, found := util.ResourceShortFormFor(item.Labels[tapi.LabelDatabaseKind]) database := fmt.Sprintf(`%v/%v`, short, item.Spec.DatabaseName) if !found { database = fmt.Sprintf(`%v`, item.Spec.DatabaseName) @@ -272,7 +270,11 @@ func (h *HumanReadablePrinter) printSnapshot(item *tapi.Snapshot, w io.Writer, o } if options.Wide { - if _, err := fmt.Fprintf(w, "%s\t", storage.GetLocation(item.Spec.SnapshotStorageSpec)); err != nil { + loc, err := item.Spec.SnapshotStorageSpec.Location() + if err != nil { + return err + } + if _, err := fmt.Fprintf(w, "%s\t", loc); err != nil { return err } } diff --git a/vendor/github.com/k8sdb/apimachinery/api/helpers.go b/vendor/github.com/k8sdb/apimachinery/api/helpers.go new file mode 100644 index 000000000..37378abf0 --- /dev/null +++ b/vendor/github.com/k8sdb/apimachinery/api/helpers.go @@ -0,0 +1,144 @@ +package api + +import ( + "errors" + "path/filepath" + "strings" +) + +const ( + DatabaseNamePrefix = "kubedb" + + GenericKey = "kubedb.com" + + LabelDatabaseKind = GenericKey + "/kind" + LabelDatabaseName = GenericKey + "/name" + LabelJobType = GenericKey + "/job-type" + + PostgresKey = ResourceNamePostgres + "." + GenericKey + PostgresDatabaseVersion = PostgresKey + "/version" + + ElasticKey = ResourceNameElastic + ".kubedb.com" + ElasticDatabaseVersion = ElasticKey + "/version" + + SnapshotKey = ResourceNameSnapshot + "s.kubedb.com" + LabelSnapshotStatus = SnapshotKey + "/status" +) + +func (p Postgres) OffshootName() string { + return p.Name +} + +func (p Postgres) OffshootLabels() map[string]string { + return map[string]string{ + LabelDatabaseName: p.Name, + LabelDatabaseKind: ResourceKindPostgres, + } +} + +func (p Postgres) StatefulSetLabels() map[string]string { + labels := p.OffshootLabels() + for key, val := range p.Labels { + if !strings.HasPrefix(key, GenericKey+"/") && !strings.HasPrefix(key, PostgresKey+"/") { + labels[key] = val + } + } + return labels +} + +func (p Postgres) StatefulSetAnnotations() map[string]string { + annotations := make(map[string]string) + for key, val := range p.Annotations { + if !strings.HasPrefix(key, GenericKey+"/") && !strings.HasPrefix(key, PostgresKey+"/") { + annotations[key] = val + } + } + annotations[PostgresDatabaseVersion] = string(p.Spec.Version) + return annotations +} + +func (e Elastic) OffshootName() string { + return e.Name +} + +func (e Elastic) OffshootLabels() map[string]string { + return map[string]string{ + LabelDatabaseKind: ResourceKindElastic, + LabelDatabaseName: e.Name, + } +} + +func (e Elastic) StatefulSetLabels() map[string]string { + labels := e.OffshootLabels() + for key, val := range e.Labels { + if !strings.HasPrefix(key, GenericKey+"/") && !strings.HasPrefix(key, ElasticKey+"/") { + labels[key] = val + } + } + return labels +} + +func (e Elastic) StatefulSetAnnotations() map[string]string { + annotations := make(map[string]string) + for key, val := range e.Annotations { + if !strings.HasPrefix(key, GenericKey+"/") && !strings.HasPrefix(key, ElasticKey+"/") { + annotations[key] = val + } + } + annotations[ElasticDatabaseVersion] = string(e.Spec.Version) + return annotations +} + +func (s Snapshot) OffshootName() string { + return s.Name +} + +func (d DormantDatabase) OffshootName() string { + return d.Name +} + +func (s Snapshot) Location() (string, error) { + spec := s.Spec.SnapshotStorageSpec + if spec.S3 != nil { + return filepath.Join(spec.S3.Prefix, DatabaseNamePrefix, s.Namespace, s.Spec.DatabaseName), nil + } else if spec.GCS != nil { + return filepath.Join(spec.GCS.Prefix, DatabaseNamePrefix, s.Namespace, s.Spec.DatabaseName), nil + } else if spec.Azure != nil { + return filepath.Join(spec.Azure.Prefix, DatabaseNamePrefix, s.Namespace, s.Spec.DatabaseName), nil + } else if spec.Local != nil { + return filepath.Join(spec.Local.Path, DatabaseNamePrefix, s.Namespace, s.Spec.DatabaseName), nil + } else if spec.Swift != nil { + return filepath.Join(spec.Swift.Prefix, DatabaseNamePrefix, s.Namespace, s.Spec.DatabaseName), nil + } + return "", errors.New("No storage provider is configured.") +} + +func (s SnapshotStorageSpec) Container() (string, error) { + if s.S3 != nil { + return s.S3.Bucket, nil + } else if s.GCS != nil { + return s.GCS.Bucket, nil + } else if s.Azure != nil { + return s.Azure.Container, nil + } else if s.Local != nil { + return "kubedb", nil + } else if s.Swift != nil { + return s.Swift.Container, nil + } + return "", errors.New("No storage provider is configured.") +} + +func (s SnapshotStorageSpec) Location() (string, error) { + if s.S3 != nil { + return "s3://" + s.S3.Bucket, nil + } else if s.GCS != nil { + return "gs://" + s.GCS.Bucket, nil + } else if s.Azure != nil { + return "azure://" + s.Azure.Container, nil + } else if s.Local != nil { + return "local://kubedb", nil + } else if s.Swift != nil { + return "swift://" + s.Swift.Container, nil + } + return "", errors.New("No storage provider is configured.") +} diff --git a/vendor/github.com/k8sdb/apimachinery/api/register.go b/vendor/github.com/k8sdb/apimachinery/api/register.go index a2e123ae4..9cd89aa5e 100644 --- a/vendor/github.com/k8sdb/apimachinery/api/register.go +++ b/vendor/github.com/k8sdb/apimachinery/api/register.go @@ -45,14 +45,14 @@ func addKnownTypes(scheme *runtime.Scheme) error { return nil } -func (obj *Snapshot) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } +func (s *Snapshot) GetObjectKind() schema.ObjectKind { return &s.TypeMeta } func (obj *SnapshotList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } -func (obj *DormantDatabase) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } +func (d *DormantDatabase) GetObjectKind() schema.ObjectKind { return &d.TypeMeta } func (obj *DormantDatabaseList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } -func (obj *Elastic) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } +func (e *Elastic) GetObjectKind() schema.ObjectKind { return &e.TypeMeta } func (obj *ElasticList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } -func (obj *Postgres) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } +func (p *Postgres) GetObjectKind() schema.ObjectKind { return &p.TypeMeta } func (obj *PostgresList) GetObjectKind() schema.ObjectKind { return &obj.TypeMeta } diff --git a/vendor/github.com/k8sdb/apimachinery/api/types.go b/vendor/github.com/k8sdb/apimachinery/api/types.go index ff6f65fa5..6b53043eb 100644 --- a/vendor/github.com/k8sdb/apimachinery/api/types.go +++ b/vendor/github.com/k8sdb/apimachinery/api/types.go @@ -30,6 +30,8 @@ type SnapshotSourceSpec struct { type BackupScheduleSpec struct { CronExpression string `json:"cronExpression,omitempty"` SnapshotStorageSpec `json:",inline,omitempty"` + // Compute Resources required by the sidecar container. + Resources apiv1.ResourceRequirements `json:"resources,omitempty"` } const ( @@ -84,21 +86,24 @@ type LocalSpec struct { type S3Spec struct { Endpoint string `json:"endpoint,omitempty"` - Region string `json:"region,omitempty"` Bucket string `json:"bucket,omiempty"` + Prefix string `json:"prefix,omitempty"` } type GCSSpec struct { Location string `json:"location,omitempty"` Bucket string `json:"bucket,omiempty"` + Prefix string `json:"prefix,omitempty"` } type AzureSpec struct { Container string `json:"container,omitempty"` + Prefix string `json:"prefix,omitempty"` } type SwiftSpec struct { Container string `json:"container,omitempty"` + Prefix string `json:"prefix,omitempty"` } type MonitorSpec struct { diff --git a/vendor/github.com/k8sdb/apimachinery/pkg/controller/controller.go b/vendor/github.com/k8sdb/apimachinery/pkg/controller/controller.go index a65082761..d949f1dc6 100644 --- a/vendor/github.com/k8sdb/apimachinery/pkg/controller/controller.go +++ b/vendor/github.com/k8sdb/apimachinery/pkg/controller/controller.go @@ -15,8 +15,5 @@ type Controller struct { } const ( - DatabaseNamePrefix = "kubedb" - LabelDatabaseKind = "kubedb.com/kind" - LabelDatabaseName = "kubedb.com/name" - sleepDuration = time.Second * 10 + sleepDuration = time.Second * 10 ) diff --git a/vendor/github.com/k8sdb/apimachinery/pkg/controller/cron.go b/vendor/github.com/k8sdb/apimachinery/pkg/controller/cron.go index 40559a5d5..b82394f91 100644 --- a/vendor/github.com/k8sdb/apimachinery/pkg/controller/cron.go +++ b/vendor/github.com/k8sdb/apimachinery/pkg/controller/cron.go @@ -167,9 +167,9 @@ func (s *snapshotInvoker) createScheduledSnapshot() { name := s.om.Name labelMap := map[string]string{ - LabelDatabaseKind: kind, - LabelDatabaseName: name, - LabelSnapshotStatus: string(tapi.SnapshotPhaseRunning), + tapi.LabelDatabaseKind: kind, + tapi.LabelDatabaseName: name, + tapi.LabelSnapshotStatus: string(tapi.SnapshotPhaseRunning), } snapshotList, err := s.extClient.Snapshots(s.om.Namespace).List(metav1.ListOptions{ @@ -200,8 +200,8 @@ func (s *snapshotInvoker) createScheduledSnapshot() { // Set label. Elastic controller will detect this using label selector labelMap = map[string]string{ - LabelDatabaseKind: kind, - LabelDatabaseName: name, + tapi.LabelDatabaseKind: kind, + tapi.LabelDatabaseName: name, } now := time.Now().UTC() @@ -214,8 +214,8 @@ func (s *snapshotInvoker) createScheduledSnapshot() { func (s *snapshotInvoker) createSnapshot(snapshotName string) error { labelMap := map[string]string{ - LabelDatabaseKind: s.runtimeObject.GetObjectKind().GroupVersionKind().Kind, - LabelDatabaseName: s.om.Name, + tapi.LabelDatabaseKind: s.runtimeObject.GetObjectKind().GroupVersionKind().Kind, + tapi.LabelDatabaseName: s.om.Name, } snapshot := &tapi.Snapshot{ @@ -227,6 +227,7 @@ func (s *snapshotInvoker) createSnapshot(snapshotName string) error { Spec: tapi.SnapshotSpec{ DatabaseName: s.om.Name, SnapshotStorageSpec: s.spec.SnapshotStorageSpec, + Resources: s.spec.Resources, }, } diff --git a/vendor/github.com/k8sdb/apimachinery/pkg/controller/lib.go b/vendor/github.com/k8sdb/apimachinery/pkg/controller/lib.go index 62dae1fc7..f120343c5 100644 --- a/vendor/github.com/k8sdb/apimachinery/pkg/controller/lib.go +++ b/vendor/github.com/k8sdb/apimachinery/pkg/controller/lib.go @@ -90,7 +90,7 @@ func (c *Controller) DeleteSnapshotData(snapshot *tapi.Snapshot) error { if err != nil { return err } - bucket, err := storage.GetContainer(snapshot.Spec.SnapshotStorageSpec) + bucket, err := snapshot.Spec.SnapshotStorageSpec.Container() if err != nil { return err } @@ -99,7 +99,7 @@ func (c *Controller) DeleteSnapshotData(snapshot *tapi.Snapshot) error { return err } - prefix := fmt.Sprintf("%v/%v/%v/%v", DatabaseNamePrefix, snapshot.Namespace, snapshot.Spec.DatabaseName, snapshot.Name) + prefix, _ := snapshot.Location() // error checked by .Container() cursor := stow.CursorStart for { items, next, err := container.Items(prefix, cursor, 50) @@ -287,7 +287,7 @@ func (c *Controller) DeleteService(name, namespace string) error { } } - if service.Spec.Selector[LabelDatabaseName] != name { + if service.Spec.Selector[tapi.LabelDatabaseName] != name { return nil } diff --git a/vendor/github.com/k8sdb/apimachinery/pkg/controller/snapshot.go b/vendor/github.com/k8sdb/apimachinery/pkg/controller/snapshot.go index fea22d69b..b90806372 100644 --- a/vendor/github.com/k8sdb/apimachinery/pkg/controller/snapshot.go +++ b/vendor/github.com/k8sdb/apimachinery/pkg/controller/snapshot.go @@ -44,11 +44,6 @@ type SnapshotController struct { syncPeriod time.Duration } -const ( - LabelJobType = "job.kubedb.com/type" - LabelSnapshotStatus = "snapshot.kubedb.com/status" -) - // NewSnapshotController creates a new SnapshotController func NewSnapshotController( client clientset.Interface, @@ -182,8 +177,8 @@ func (c *SnapshotController) create(snapshot *tapi.Snapshot) error { return err } - snapshot.Labels[LabelDatabaseName] = snapshot.Spec.DatabaseName - snapshot.Labels[LabelSnapshotStatus] = string(tapi.SnapshotPhaseRunning) + snapshot.Labels[tapi.LabelDatabaseName] = snapshot.Spec.DatabaseName + snapshot.Labels[tapi.LabelSnapshotStatus] = string(tapi.SnapshotPhaseRunning) snapshot.Status.Phase = tapi.SnapshotPhaseRunning if _, err = c.extClient.Snapshots(snapshot.Namespace).Update(snapshot); err != nil { c.eventRecorder.Eventf( @@ -429,7 +424,7 @@ func (c *SnapshotController) checkSnapshotJob(snapshot *tapi.Snapshot, jobName s ) } - delete(snapshot.Labels, LabelSnapshotStatus) + delete(snapshot.Labels, tapi.LabelSnapshotStatus) if _, err := c.extClient.Snapshots(snapshot.Namespace).Update(snapshot); err != nil { c.eventRecorder.Eventf( snapshot, diff --git a/vendor/github.com/k8sdb/apimachinery/pkg/storage/osm.go b/vendor/github.com/k8sdb/apimachinery/pkg/storage/osm.go index b1dd0825f..d42e505fa 100644 --- a/vendor/github.com/k8sdb/apimachinery/pkg/storage/osm.go +++ b/vendor/github.com/k8sdb/apimachinery/pkg/storage/osm.go @@ -57,7 +57,7 @@ func CheckBucketAccess(client clientset.Interface, spec tapi.SnapshotStorageSpec if err != nil { return err } - c, err := GetContainer(spec) + c, err := spec.Container() if err != nil { return err } @@ -91,7 +91,7 @@ func NewOSMContext(client clientset.Interface, spec tapi.SnapshotStorageSpec, na nc.Provider = s3.Kind nc.Config[s3.ConfigAccessKeyID] = string(secret.Data[tapi.AWS_ACCESS_KEY_ID]) nc.Config[s3.ConfigEndpoint] = spec.S3.Endpoint - nc.Config[s3.ConfigRegion] = spec.S3.Region + nc.Config[s3.ConfigRegion] = "us-east-1" // only used for creating buckets nc.Config[s3.ConfigSecretKey] = string(secret.Data[tapi.AWS_SECRET_ACCESS_KEY]) if u, err := url.Parse(spec.S3.Endpoint); err == nil { nc.Config[s3.ConfigDisableSSL] = strconv.FormatBool(u.Scheme == "http") @@ -150,33 +150,3 @@ func NewOSMContext(client clientset.Interface, spec tapi.SnapshotStorageSpec, na } return nil, errors.New("No storage provider is configured.") } - -func GetContainer(spec tapi.SnapshotStorageSpec) (string, error) { - if spec.S3 != nil { - return spec.S3.Bucket, nil - } else if spec.GCS != nil { - return spec.GCS.Bucket, nil - } else if spec.Azure != nil { - return spec.Azure.Container, nil - } else if spec.Local != nil { - return "kubedb", nil - } else if spec.Swift != nil { - return spec.Swift.Container, nil - } - return "", errors.New("No storage provider is configured.") -} - -func GetLocation(spec tapi.SnapshotStorageSpec) string { - if spec.S3 != nil { - return "s3://" + spec.S3.Bucket - } else if spec.GCS != nil { - return "gs://" + spec.GCS.Bucket - } else if spec.Azure != nil { - return "azure://" + spec.Azure.Container - } else if spec.Local != nil { - return "local://kubedb" - } else if spec.Swift != nil { - return "swift://" + spec.Swift.Container - } - return "Unknown" -} diff --git a/vendor/gopkg.in/yaml.v2/LICENSE b/vendor/gopkg.in/yaml.v2/LICENSE index 866d74a7a..a68e67f01 100644 --- a/vendor/gopkg.in/yaml.v2/LICENSE +++ b/vendor/gopkg.in/yaml.v2/LICENSE @@ -1,13 +1,188 @@ -Copyright 2011-2016 Canonical Ltd. -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 +Copyright (c) 2011-2014 - Canonical Inc. - http://www.apache.org/licenses/LICENSE-2.0 +This software is licensed under the LGPLv3, included below. -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. +As a special exception to the GNU Lesser General Public License version 3 +("LGPL3"), the copyright holders of this Library give you permission to +convey to a third party a Combined Work that links statically or dynamically +to this Library without providing any Minimal Corresponding Source or +Minimal Application Code as set out in 4d or providing the installation +information set out in section 4e, provided that you comply with the other +provisions of LGPL3 and provided that you meet, for the Application the +terms and conditions of the license(s) which apply to the Application. + +Except as stated in this special exception, the provisions of LGPL3 will +continue to comply in full to this Library. If you modify this Library, you +may apply this exception to your version of this Library, but you are not +obliged to do so. If you do not wish to do so, delete this exception +statement from your version. This exception does not (and cannot) modify any +license terms which apply to the Application, with which you must still +comply. + + + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/vendor/gopkg.in/yaml.v2/decode.go b/vendor/gopkg.in/yaml.v2/decode.go index 052ecfcd1..085cddc44 100644 --- a/vendor/gopkg.in/yaml.v2/decode.go +++ b/vendor/gopkg.in/yaml.v2/decode.go @@ -120,6 +120,7 @@ func (p *parser) parse() *node { default: panic("attempted to parse unknown event: " + strconv.Itoa(int(p.event.typ))) } + panic("unreachable") } func (p *parser) node(kind int) *node { @@ -250,7 +251,7 @@ func (d *decoder) callUnmarshaler(n *node, u Unmarshaler) (good bool) { // // If n holds a null value, prepare returns before doing anything. func (d *decoder) prepare(n *node, out reflect.Value) (newout reflect.Value, unmarshaled, good bool) { - if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "" && n.implicit) { + if n.tag == yaml_NULL_TAG || n.kind == scalarNode && n.tag == "" && (n.value == "null" || n.value == "") { return out, false, false } again := true diff --git a/vendor/gopkg.in/yaml.v2/emitterc.go b/vendor/gopkg.in/yaml.v2/emitterc.go index 6ecdcb3c7..2befd553e 100644 --- a/vendor/gopkg.in/yaml.v2/emitterc.go +++ b/vendor/gopkg.in/yaml.v2/emitterc.go @@ -666,6 +666,7 @@ func yaml_emitter_emit_node(emitter *yaml_emitter_t, event *yaml_event_t, return yaml_emitter_set_emitter_error(emitter, "expected SCALAR, SEQUENCE-START, MAPPING-START, or ALIAS") } + return false } // Expect ALIAS. diff --git a/vendor/gopkg.in/yaml.v2/parserc.go b/vendor/gopkg.in/yaml.v2/parserc.go index 81d05dfe5..0a7037ad1 100644 --- a/vendor/gopkg.in/yaml.v2/parserc.go +++ b/vendor/gopkg.in/yaml.v2/parserc.go @@ -166,6 +166,7 @@ func yaml_parser_state_machine(parser *yaml_parser_t, event *yaml_event_t) bool default: panic("invalid parser state") } + return false } // Parse the production: diff --git a/vendor/gopkg.in/yaml.v2/readerc.go b/vendor/gopkg.in/yaml.v2/readerc.go index f45079171..d5fb09727 100644 --- a/vendor/gopkg.in/yaml.v2/readerc.go +++ b/vendor/gopkg.in/yaml.v2/readerc.go @@ -247,7 +247,7 @@ func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool { if parser.encoding == yaml_UTF16LE_ENCODING { low, high = 0, 1 } else { - low, high = 1, 0 + high, low = 1, 0 } // The UTF-16 encoding is not as simple as one might @@ -357,26 +357,23 @@ func yaml_parser_update_buffer(parser *yaml_parser_t, length int) bool { if value <= 0x7F { // 0000 0000-0000 007F . 0xxxxxxx parser.buffer[buffer_len+0] = byte(value) - buffer_len += 1 } else if value <= 0x7FF { // 0000 0080-0000 07FF . 110xxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xC0 + (value >> 6)) parser.buffer[buffer_len+1] = byte(0x80 + (value & 0x3F)) - buffer_len += 2 } else if value <= 0xFFFF { // 0000 0800-0000 FFFF . 1110xxxx 10xxxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xE0 + (value >> 12)) parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 6) & 0x3F)) parser.buffer[buffer_len+2] = byte(0x80 + (value & 0x3F)) - buffer_len += 3 } else { // 0001 0000-0010 FFFF . 11110xxx 10xxxxxx 10xxxxxx 10xxxxxx parser.buffer[buffer_len+0] = byte(0xF0 + (value >> 18)) parser.buffer[buffer_len+1] = byte(0x80 + ((value >> 12) & 0x3F)) parser.buffer[buffer_len+2] = byte(0x80 + ((value >> 6) & 0x3F)) parser.buffer[buffer_len+3] = byte(0x80 + (value & 0x3F)) - buffer_len += 4 } + buffer_len += width parser.unread++ } diff --git a/vendor/gopkg.in/yaml.v2/resolve.go b/vendor/gopkg.in/yaml.v2/resolve.go index 232313cc0..93a863274 100644 --- a/vendor/gopkg.in/yaml.v2/resolve.go +++ b/vendor/gopkg.in/yaml.v2/resolve.go @@ -3,7 +3,6 @@ package yaml import ( "encoding/base64" "math" - "regexp" "strconv" "strings" "unicode/utf8" @@ -81,8 +80,6 @@ func resolvableTag(tag string) bool { return false } -var yamlStyleFloat = regexp.MustCompile(`^[-+]?[0-9]*\.?[0-9]+([eE][-+][0-9]+)?$`) - func resolve(tag string, in string) (rtag string, out interface{}) { if !resolvableTag(tag) { return tag, in @@ -138,11 +135,9 @@ func resolve(tag string, in string) (rtag string, out interface{}) { if err == nil { return yaml_INT_TAG, uintv } - if yamlStyleFloat.MatchString(plain) { - floatv, err := strconv.ParseFloat(plain, 64) - if err == nil { - return yaml_FLOAT_TAG, floatv - } + floatv, err := strconv.ParseFloat(plain, 64) + if err == nil { + return yaml_FLOAT_TAG, floatv } if strings.HasPrefix(plain, "0b") { intv, err := strconv.ParseInt(plain[2:], 2, 64) diff --git a/vendor/gopkg.in/yaml.v2/scannerc.go b/vendor/gopkg.in/yaml.v2/scannerc.go index 2c9d5111f..d97d76fa5 100644 --- a/vendor/gopkg.in/yaml.v2/scannerc.go +++ b/vendor/gopkg.in/yaml.v2/scannerc.go @@ -9,7 +9,7 @@ import ( // ************ // // The following notes assume that you are familiar with the YAML specification -// (http://yaml.org/spec/1.2/spec.html). We mostly follow it, although in +// (http://yaml.org/spec/cvs/current.html). We mostly follow it, although in // some cases we are less restrictive that it requires. // // The process of transforming a YAML stream into a sequence of events is @@ -1546,7 +1546,7 @@ func yaml_parser_scan_directive(parser *yaml_parser_t, token *yaml_token_t) bool // Unknown directive. } else { yaml_parser_set_scanner_error(parser, "while scanning a directive", - start_mark, "found unknown directive name") + start_mark, "found uknown directive name") return false } diff --git a/vendor/gopkg.in/yaml.v2/yaml.go b/vendor/gopkg.in/yaml.v2/yaml.go index 36d6b883a..d133edf9d 100644 --- a/vendor/gopkg.in/yaml.v2/yaml.go +++ b/vendor/gopkg.in/yaml.v2/yaml.go @@ -222,7 +222,7 @@ func getStructInfo(st reflect.Type) (*structInfo, error) { inlineMap := -1 for i := 0; i != n; i++ { field := st.Field(i) - if field.PkgPath != "" && !field.Anonymous { + if field.PkgPath != "" { continue // Private field } diff --git a/vendor/k8s.io/kubernetes/pkg/api/helpers.go b/vendor/k8s.io/kubernetes/pkg/api/helpers.go index faa7df7c0..21b35a4fa 100644 --- a/vendor/k8s.io/kubernetes/pkg/api/helpers.go +++ b/vendor/k8s.io/kubernetes/pkg/api/helpers.go @@ -246,6 +246,7 @@ func IsServiceIPRequested(service *Service) bool { var standardFinalizers = sets.NewString( string(FinalizerKubernetes), metav1.FinalizerOrphanDependents, + metav1.FinalizerDeleteDependents, ) // HasAnnotation returns a bool if passed in annotation exists diff --git a/vendor/k8s.io/kubernetes/pkg/version/base.go b/vendor/k8s.io/kubernetes/pkg/version/base.go index 5c89b3aa7..201514d41 100644 --- a/vendor/k8s.io/kubernetes/pkg/version/base.go +++ b/vendor/k8s.io/kubernetes/pkg/version/base.go @@ -51,7 +51,7 @@ var ( // semantic version is a git hash, but the version itself is no // longer the direct output of "git describe", but a slight // translation to be semver compliant. - gitVersion string = "v1.6.6+$Format:%h$" + gitVersion string = "v1.6.7+$Format:%h$" gitCommit string = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD) gitTreeState string = "not a git tree" // state of git tree, either "clean" or "dirty"