-
Notifications
You must be signed in to change notification settings - Fork 741
*: add ABS support for backup and restore #1842
Conversation
Can one of the admins verify this patch? |
2 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Our backup test right now is a bit flaky: #1825 We are focusing on that and need to fix it first. We have rules to prioritize making testing stable, fixing bugs over adding features. Will review this PR once it is fixed. |
@hongchaodeng SGTM ! |
pkg/backup/writer/abs_writer.go
Outdated
|
||
blob := containerRef.GetBlobReference(key) | ||
putBlobOpts := storage.PutBlobOptions{} | ||
err = blob.CreateBlockBlobFromReader(r, &putBlobOpts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline putBlobOpts
to
err = blob.CreateBlockBlobFromReader(r, &storage.PutBlobOptions{})
pkg/backup/writer/abs_writer.go
Outdated
} | ||
|
||
getBlobOpts := &storage.GetBlobOptions{} | ||
_, err = blob.Get(getBlobOpts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline getBlobOpts
to
blob.Get(&storage.GetBlobOptions{})
if err != nil { | ||
return fmt.Errorf("failed to create ABS client: %v", err) | ||
} | ||
// Nothing to Close for absCli yet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when should absCli be closed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is simply an object. We don't need to explicit call Close. It would be GC when no reference :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjtsdl sometime a client can create gorutines that must be closed to avoid any go routines leaks. not sure if that's the case for abs client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absCli doesn't do that. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to know.
|
||
abs := bc.GetBlobService() | ||
w.ABS = &abs | ||
return w, nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline w
as
return &ABSClient{ABS: &bc.GetBlobService()}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It throw error "cannot take address of bc.GetBlobService()" So I can only do small refactoring
a2249d9
to
efa6712
Compare
pkg/backup/reader/abs_reader.go
Outdated
abs *storage.BlobStorageClient | ||
} | ||
|
||
func NewABSReader(abs *storage.BlobStorageClient) Reader { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc string on public func.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjtsdl ping? fix the above?
pkg/backup/writer/abs_writer.go
Outdated
"io" | ||
|
||
"github.com/Azure/azure-sdk-for-go/storage" | ||
"github.com/coreos/etcd-operator/pkg/backup/util" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate internal and external import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the import according to what @xiang90's suggestion?
e.g:
"bytes"
"encoding/base64"
"fmt"
"github.com/coreos/etcd-operator/pkg/backup/util"
"github.com/Azure/azure-sdk-for-go/storage"
"github.com/pborman/uuid"
@rjtsdl what is the test plan for this? |
pkg/backup/reader/abs_reader.go
Outdated
|
||
blob := containerRef.GetBlobReference(key) | ||
getBlobOpts := &storage.GetBlobOptions{} | ||
return blob.Get(getBlobOpts) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inline getBlobOpts
? to
return blob.Get( &storage.GetBlobOptions{})
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjtsdl ping? fix the above?
@xiang90 currently I don't have unittests for this. Mostly it is me, building custom image, and try it out with ABS specified. What's the plan for different storage types? ABS should have no difference. |
There is an e2e test for S3 storage. I am fine if ABS starts with replicating that test. |
@rjtsdl take a look of how |
@fanminshi @xiang90 thx for the pointer. I will add test in this PR. It may not be very soon. But bear with me :) |
@rjtsdl take your time. feel free to ask if you have any questions or concerns. |
@shrutir25 we need to rebase/merge with the latest master :) |
@shrutir25 added tests for ABS. |
@rjtsdl The API parts and the overall workflow look good to me. Need @hongchaodeng and @fanminshi to look through the implementation and tests. Thanks for the contribution! |
test/container/run
Outdated
@@ -20,7 +20,10 @@ echo "TEST_NAMESPACE: ${TEST_NAMESPACE}" | |||
echo "OPERATOR_IMAGE: ${OPERATOR_IMAGE}" | |||
|
|||
export TEST_AWS_SECRET="aws" | |||
export TEST_ABS_SECRET="abs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't change this file test/container/run
@@ -81,6 +82,49 @@ func TestBackupAndRestore(t *testing.T) { | |||
testEtcdRestoreOperatorForS3Source(t, clusterName, s3Path) | |||
} | |||
|
|||
// TestBackupAndRestoreABS runs the backup test first, and only runs the restore test after if the backup test succeeds and sets the ABS path | |||
func TestBackupAndRestoreABS(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the code is duplicate to TestBackupAndRestoreS3().
Can you refactor it to reduce duplication?
test/e2e/e2eutil/spec_util.go
Outdated
@@ -59,6 +59,30 @@ func NewS3Backup(endpoints []string, clusterName, path, secret, clientTLSSecret | |||
} | |||
} | |||
|
|||
// NewABSBackup creates a EtcdBackup object using clusterName. | |||
func NewABSBackup(endpoints []string, clusterName, path, secret, clientTLSSecret string) *api.EtcdBackup { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the code are duplicate to NewS3Backup().
Can you refactor it?
} | ||
|
||
var tlsConfig *tls.Config | ||
if len(clientTLSSecret) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code is duplicate to handleS3(). Can you refactor it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can just extract line 39 - 49 to something like generateTLSConfig
?
Can you split this PR into two:
|
pkg/backup/writer/abs_writer.go
Outdated
|
||
const ( | ||
// AzureBlobBlockChunkLimitInBytes 100MiB is the limit | ||
AzureBlobBlockChunkLimitInBytes = 104857600 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer AzureBlobBlockChunkLimitInBytes = 100 * 1024 * 1024
for readability; It is pretty clear that 100 * 1024 * 1024
is 100MiB
pkg/backup/writer/abs_writer.go
Outdated
"io" | ||
|
||
"github.com/Azure/azure-sdk-for-go/storage" | ||
"github.com/coreos/etcd-operator/pkg/backup/util" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change the import according to what @xiang90's suggestion?
e.g:
"bytes"
"encoding/base64"
"fmt"
"github.com/coreos/etcd-operator/pkg/backup/util"
"github.com/Azure/azure-sdk-for-go/storage"
"github.com/pborman/uuid"
} | ||
|
||
buf := new(bytes.Buffer) | ||
buf.ReadFrom(r) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if reader has a 2 GB size? Will ReadFrom
return ErrTooLarge
on system that has smaller memory or disk space?
I think we need to figure out a way to read 100MB into buffer and then write 100MB buffer into ABS and repeat.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjtsdl the suggestion is just an optimization and it will not affect the correctness. we can optimize the uploading logic in a future pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will submit this optimization in the next pr since I dont want to block the merging of this current pr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx, we can do it in another PR. :)
@rjtsdl most of code looks good. I just have few concern with abs uploading logic. the test can be refactor a bit more but let's do that in a separate pr like @hongchaodeng suggested. |
@fanminshi @hongchaodeng - thanks for reviewing the PR ! I will make all the changes as mentioned and submit out a new PR for the tests. |
@rjtsdl @hongchaodeng @fanminshi @khenidak - I have made the changes as per the review comments. PTAL :) |
} | ||
|
||
var tlsConfig *tls.Config | ||
if tlsConfig, err := generateTLSConfig(kubecli, clientTLSSecret, namespace); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replace :=
with =
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good in general.
@@ -39,7 +39,7 @@ func init() { | |||
rand.Seed(time.Now().UTC().UnixNano()) | |||
} | |||
|
|||
// TestBackupAndRestore runs the backup test first, and only runs the restore test after if the backup test succeeds and sets the S3 path | |||
// TestBackupAndRestoreS3 runs the backup test first, and only runs the restore test after if the backup test succeeds and sets the S3 path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this?
test/pod/README.md
Outdated
@@ -6,6 +6,10 @@ The scripts at `test/pod` can be used to package and run the e2e tests inside a | |||
|
|||
The e2e tests need access to an S3 bucket for testing. Create a secret containing the aws credentials and config files in the same namespace that the test-pod will run in. Consult the [backup-operator guide][setup-aws-secret] on how to do so. | |||
|
|||
## Create the ABS secret |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In test/pod/
, it is testing related.
Can you revert this and put the changes into upcoming testing PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure I will add it to the test PR.
@@ -6,6 +6,18 @@ | |||
packages = ["compute/metadata","internal"] | |||
revision = "3b1ae45394a234c385be014e9a488f2bb6eef821" | |||
|
|||
[[projects]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't you need to update Gopkg.toml?
How could you have changes in Gopkg.lock
while Gopkg.toml
remains unchanged?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rjtsdl - is there a change that needs to be made in Gopkg.toml ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i saw "github.com/Azure/azure-sdk-for-go" being added. how come Gopkg.toml
has not changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added it :)
@etcd-bot ok to test |
please also squash the commits into just few relevant ones: all the go dep change can be in one commit. I hope you get the idea. |
e1af336
to
b61134b
Compare
b61134b
to
69fcda8
Compare
Gopkg.toml
Outdated
name = "github.com/Azure/azure-sdk-for-go" | ||
version = "v11.3.0-beta" | ||
|
||
[[constraint]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These three deps aren't imported directly in the code. Can you get rid of them:
[[constraint]]
name = "github.com/Azure/go-autorest"
version = "v9.6.0"
[[constraint]]
name = "github.com/dgrijalva/jwt-go"
[[constraint]]
name = "github.com/satori/uuid"
version = "v1.1.0
"k8s.io/client-go/kubernetes" | ||
) | ||
|
||
// TODO: replace this with generic backend interface for other options (PV, Azure) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this TODO.
test/pod/README.md
Outdated
@@ -21,6 +21,7 @@ The [test-pod-tmpl.yaml](./test-pod-tmpl.yaml) can be used to define the test-po | |||
- `OPERATOR_IMAGE` is the etcd-operator image used for testing | |||
- `TEST_S3_BUCKET` is the S3 bucket name used for testing | |||
- `TEST_AWS_SECRET` is the secret name containing the aws credentials/config files. | |||
- `TEST_ABS_SECRET` is the secret name containing the abs credentials |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you revert the changes related under test/pod/
. These would come into testing PR later.
ec07d43
to
01cd7ff
Compare
Please also update generated code:
|
|
@rjtsdl please also rebase the commits as well. probably merge |
5b030c7
to
e26c421
Compare
No need to worry the commits. |
I rebased it a bit. |
@rjtsdl a bit nit on the commit msg. usually, we want the format to be in your case, pkg can be |
@fanminshi |
@hongchaodeng sure thing. @rjtsdl you can follow my advice on future pr then. |
Add ABS support for backup-operator and restore-operator
Fix #1784