Skip to content

Commit

Permalink
support for GCS snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
danisla committed May 23, 2018
1 parent d19545d commit f2ff75b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
8 changes: 6 additions & 2 deletions pkg/apis/elasticsearchoperator/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ type Snapshot struct {
// Enabled determines if snapshots are enabled
SchedulerEnabled bool `json:"scheduler-enabled"`

// BucketName defines the AWS S3 bucket to store snapshots
// RepoType defines the type of Elasticsearch Repository, s3 or gcs
RepoType string `json:"type"`

// BucketName defines the AWS S3 or GCS bucket to store snapshots
BucketName string `json:"bucket-name"`

// CronSchedule defines how to run the snapshots
Expand Down Expand Up @@ -204,7 +207,8 @@ type Cerebro struct {

// Scheduler stores info about how to snapshot the cluster
type Scheduler struct {
S3bucketName string
RepoType string
BucketName string
CronSchedule string
Enabled bool
Auth SchedulerAuthentication
Expand Down
5 changes: 4 additions & 1 deletion pkg/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func (p *Processor) refreshClusters() error {
KeepSecretsOnDelete: cluster.Spec.KeepSecretsOnDelete,
Snapshot: myspec.Snapshot{
SchedulerEnabled: cluster.Spec.Snapshot.SchedulerEnabled,
RepoType: cluster.Spec.Snapshot.RepoType,
BucketName: cluster.Spec.Snapshot.BucketName,
CronSchedule: cluster.Spec.Snapshot.CronSchedule,
},
Expand All @@ -175,7 +176,8 @@ func (p *Processor) refreshClusters() error {
VolumeReclaimPolicy: cluster.Spec.Storage.VolumeReclaimPolicy,
},
Scheduler: myspec.Scheduler{
S3bucketName: cluster.Spec.Snapshot.BucketName,
RepoType: cluster.Spec.Snapshot.RepoType,
BucketName: cluster.Spec.Snapshot.BucketName,
CronSchedule: cluster.Spec.Snapshot.CronSchedule,
Enabled: cluster.Spec.Snapshot.SchedulerEnabled,
Auth: myspec.SchedulerAuthentication{
Expand Down Expand Up @@ -210,6 +212,7 @@ func (p *Processor) refreshClusters() error {
},
},
Scheduler: snapshot.New(
cluster.Spec.Snapshot.RepoType,
cluster.Spec.Snapshot.BucketName,
cluster.Spec.Snapshot.CronSchedule,
cluster.Spec.Snapshot.SchedulerEnabled,
Expand Down
12 changes: 9 additions & 3 deletions pkg/snapshot/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,22 @@ type Scheduler struct {
}

// New creates an instance of Scheduler
func New(bucketName, cronSchedule string, enabled, useSSL bool, userName, password, image,
func New(repoType, bucketName, cronSchedule string, enabled, useSSL bool, userName, password, image,
elasticURL, clusterName, namespace string, kc kubernetes.Interface) *Scheduler {

if repoType == "" {
repoType = "s3"
}

if image == "" {
image = defaultCronImage
}

return &Scheduler{
Kclient: kc,
CRD: enterprisesv1.Scheduler{
S3bucketName: bucketName,
RepoType: repoType,
BucketName: bucketName,
CronSchedule: cronSchedule,
ElasticURL: elasticURL,
Auth: enterprisesv1.SchedulerAuthentication{
Expand Down Expand Up @@ -214,7 +219,8 @@ func (s *Scheduler) CreateCronJob(namespace, clusterName, action, cronSchedule s
},
Args: []string{
fmt.Sprintf("--action=%s", action),
fmt.Sprintf("--s3-bucket-name=%s", s.CRD.S3bucketName),
fmt.Sprintf("--repo-type=%s", s.CRD.RepoType),
fmt.Sprintf("--bucket-name=%s", s.CRD.BucketName),
fmt.Sprintf("--elastic-url=%s", s.CRD.ElasticURL),
fmt.Sprintf("--auth-username=%s", s.CRD.Auth.UserName),
fmt.Sprintf("--auth-password=%s", s.CRD.Auth.Password),
Expand Down

0 comments on commit f2ff75b

Please sign in to comment.