Skip to content
This repository has been archived by the owner on Mar 28, 2020. It is now read-only.

backend: add Azure Blob Storage (ABS) backup support #1237

Closed
wants to merge 2 commits into from

Conversation

vdice
Copy link
Contributor

@vdice vdice commented Jun 29, 2017

This PR adds Azure Blob Storage (ABS) backup support.

Accomplishes part of #1110

[skip ci]

@vdice vdice force-pushed the feat/add-abs-support branch 2 times, most recently from 901f1b5 to b6313c1 Compare June 29, 2017 20:29
@vdice vdice changed the title backend: add Azure Blob Storage (abs) backup support backend: add Azure Blob Storage (ABS) backup support Jun 29, 2017
@hongchaodeng
Copy link
Member

Thanks for the contribution.
Can you discuss about your design (api, spec change) first in #1110 ?

@vdice
Copy link
Contributor Author

vdice commented Jul 3, 2017

@hongchaodeng design document added in latest push; please see doc/design/abs_backup.md. Thank you!


When starting etcd operator, we need to provide flags in order to access the ABS storage account:
```bash
$ etcd-operator --backup-abs-secret ${secret_name} --backup-abs-container ${container_name} ...
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if both s3 and abs options are given, users can choose from s3 or abs? they are not mutual-exclusive, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct.

"io/ioutil"

"github.com/Sirupsen/logrus"
"github.com/coreos/etcd-operator/pkg/backup/abs"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separate internal and external imports

func (ab *absBackend) getBlobSize(key string) (int64, error) {
rc, err := ab.open(key)

b, err := ioutil.ReadAll(rc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need to close rc on error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated to close rc on error and otherwise return ioutil.Close(rc) as the error returned from the function -- how does this sound?

containerExists, err := containerRef.Exists()
if err != nil {
return nil, err
} else if !containerExists {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change this to if !containerExists

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else is not needed.

opts := &storage.DeleteBlobOptions{}
err := blob.Delete(opts)

return err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return blob.Delete(&storage.DeleteBlobOptions{})

blob := w.container.GetBlobReference(blobName)

opts := &storage.GetBlobOptions{}
resp, err := blob.Get(opts)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return blob.Get(&storage.GetBlobOptions{})

t.Fatal(err)
}
if err.Error() != "missing required environment variable of AZURE_STORAGE_ACCOUNT" {
t.Fatal(err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t.Error("explain the problem here")

@xiang90
Copy link
Collaborator

xiang90 commented Jul 5, 2017

@vdice Looks good in general. @hongchaodeng needs to approve this.

return fmt.Errorf("create block blob from reader failed: %v", err)
}

return err
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably just be return nil

@hongchaodeng
Copy link
Member

Code freeze right now. K8s 1.7 is released and it breaks a lot of our tests. We need to fix failures and make tests stable before merging any feature.

@vdice vdice force-pushed the feat/add-abs-support branch 2 times, most recently from 2c8a0c2 to ebdb5e1 Compare July 5, 2017 17:04
@vdice
Copy link
Contributor Author

vdice commented Jul 14, 2017

PR updated/rebased from master; also added changelog addition. PTAL @hongchaodeng

@hongchaodeng
Copy link
Member

We won't merge any feature for a while.
First, we need to make CRD migration happen. TPR will be removed in k8s 1.8 . For survival, we need to put all our efforts into migration and won't have much time on other stuff.
Second, for longer term, we will move to more extensible backup storage. We will eventually move all stuff except PV over there too due to security concerns and easier management, e.g. separate persistent disk to save the credentials and config.

@vdice
Copy link
Contributor Author

vdice commented Aug 23, 2017

@hongchaodeng rebased off master and tested to success on a (minikube) k8s 1.7.0 cluster -- please let me know if anything looks awry, when convenient. Thank you!

type: Opaque
stringData:
storage-account: <storage-account-name>
storage-key: <storage-key>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line?

## the section below can be added to restore from a pre-existing cluster backup
restore:
backupClusterName: "cluster-a"
storageType: "ABS"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new line

@xiang90
Copy link
Collaborator

xiang90 commented Aug 24, 2017

@hongchaodeng

I feel this is OK to merge. I am OK with adding Azure/AWS/GCP support in tree initially. Then we need to figure out a way to add out of tree support for backup storage.

I give this pr a quick look. It seems OK. defer to @hongchaodeng, @hasbro17 and @fanminshi for a detailed review.

@hongchaodeng
Copy link
Member

hongchaodeng commented Aug 24, 2017

Yeah. I agree that we should merge this and move forward.
After we finished the CRD migration, our focus has moved a bit off etcd operator and doesn't have much time making the extensible design for short term. Let's merge this for easier cloud support at this moment.

@@ -76,6 +79,9 @@ func init() {
flag.StringVar(&awsConfig, "backup-aws-config", "",
"The name of the kube configmap object that stores the AWS config file. The file name must be 'config'.")
flag.StringVar(&s3Bucket, "backup-s3-bucket", "", "The name of the AWS S3 bucket to store backups in.")
flag.StringVar(&absSecret, "backup-abs-secret", "",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will deprecate the the operator wide flag for backup storage options.
Each cluster's backup storage option should sit in its own cluster spec.

@@ -0,0 +1,19 @@
apiVersion: "etcd.database.coreos.com/v1beta2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The example in spec_examples.md is good enough.
To keep it consistent, no duplicate example here again.


See the [ABS backup with cluster specific configuration](spec_examples.md#abs-backup-and-cluster-specific-abs-configuration) spec to see what the cluster's `spec.backup` field should be configured as to set a cluster specific ABS backup configuration. The following additional fields need to be set under the cluster spec's `spec.backup.abs` field:
- `absContainer`: The name of the ABS container to store backups in.
- `absSecret`: The secret object name which should contain two key value pairs for the ABS account name and key.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please mention the file layout of the secret:

storage-account:
storage-key:

@@ -0,0 +1,8 @@
apiVersion: v1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this under example/azure/ ?

glide.yaml Outdated
@@ -25,3 +25,5 @@ import:
- package: github.com/jpillora/go-ogle-analytics
- package: golang.org/x/net
- package: golang.org/x/time
- package: github.com/Azure/azure-sdk-for-go/storage
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put glide.yaml, glide.lock change in separate commit ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is no different to vendor the entire repo or specific dir under the repo.
Just

package: github.com/Azure/azure-sdk-for-go
version ...

BTW, it's v10.3.0-beta now :)

@hongchaodeng
Copy link
Member

hongchaodeng commented Aug 24, 2017

@vdice
I would like to move forward this PR. Here's some thoughts:

  • First, I would like this PR to be separated into four smaller PRs to better review it
    1. Separate the design docs, user docs, spec changes into a PR and submit first
    2. Separate the backup sidecar (mainly pkg/backup/backup.go) related changes into a PR and submit.
    3. Finish the operator code.
    4. Add testing. Backup sidecar should be testable since it is just an HTTP endpoint. See s3_backend_test.go . I will help setup azurite container running in jenkins.
  • The operator flag is not recommended. Just add the options in cluster spec. That's the way to go. We have moved storage class into cluster spec too. All backup storage related flags will be deprecated.

@vdice
Copy link
Contributor Author

vdice commented Aug 24, 2017

@hongchaodeng Great news! I'll get to work addressing code comments and breaking this up into separate PRs as requested. Will have an update (and new PRs) by tomorrow.

@vdice
Copy link
Contributor Author

vdice commented Aug 25, 2017

@hongchaodeng pushed an additional commit that hopefully addresses all feedback. Wanted to make sure I'm on the right track prior to breaking these changes out.

In particular, hoping for confirmation that I fully removed operator flag/backup customization in anticipation of the deprecation you've mentioned. Thanks!

Copy link
Member

@hongchaodeng hongchaodeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The direction looks good. Just some implementation detail issues. But we can fix them along the way in individual PRs.

Thanks @vdice for the fast work.


When starting etcd operator, we need to provide flags in order to access the ABS storage account:
```bash
$ etcd-operator --backup-abs-secret ${secret_name} --backup-abs-container ${container_name} ...
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove the flag?

return err
}

os.Setenv(env.ABSStorageAccount, string(se.Data[spec.ABSStorageAccount]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't set env. This will affect other clusters.

@@ -4,6 +4,7 @@ In etcd operator, we provide the following options to save cluster backups to:
- Persistent Volume (PV) on GCE or AWS
- Persistent Volume (PV) with custom StorageClasses
- S3 bucket on AWS
- ABS container on Azure
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Blob Storage (ABS) container

@vdice
Copy link
Contributor Author

vdice commented Aug 30, 2017

(work split up into PRs linked above -- follow those for progress)

@vdice vdice closed this Aug 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants