Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backend: add Google Cloud storage support #73

Merged
merged 3 commits into from
Feb 7, 2020

Conversation

a-hilaly
Copy link
Contributor

@a-hilaly a-hilaly commented Oct 11, 2019

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Fixes #61

Proposed Changes

  • Add cloud.google.com/go/storage dependency
  • Implement Cloud Storage backend
  • Add Cloud Storage to plugins config
  • Edit flags/environment variables

Description

Checklist

  • Read the CONTRIBUTING document. (It's checked since you are alread here.)
  • Read the CODE OF CONDUCT document.
  • Add tests to cover changes.
  • Make sure your code follows the code style of this project
  • Make sure CI and all other PR checks are green OR
  • Code compiles correctly.
  • Created tests which fail without the change (if possible).
  • All new and existing tests passed.
  • Add your changes to CHANGELOG.
  • Improve and update the README (if necessary).
  • Make sure documentation is up-to-date. Same file should also be updated in plugin index by sending a PR to that repository.

@a-hilaly a-hilaly requested a review from kakkoyun as a code owner October 11, 2019 12:09
@kakkoyun kakkoyun added storage-backend New storage backends WIP Work in progress labels Oct 11, 2019
@kakkoyun
Copy link
Contributor

@a-hilaly This looks great so far. Thanks a lot for the contribution, this is one of the most wanted backends because GCP is very popular nowadays.

I'm sure you've noticed our contribution guidelines, we're also trying to improve those, PTAL #71. It'd be great if you could complete the PR checklist and rebase your branch.

And ping me whenever you need a review.

@a-hilaly
Copy link
Contributor Author

@kakkoyun Done ! For the CHANGELOG.md file should i add bump the version and add changes to a [1.0.5] section or juste update the [1.0.4] one ?

@kakkoyun
Copy link
Contributor

@a-hilaly Thanks a lot. I'll have a look at it this weekend.
For the Changelog, could you please create an Unreleased titled section at the top and put your changes there. I'll handle the rest before release.

Copy link
Contributor

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

So far so good, I have highlighted a couple of points. If you could fix those, that'd be great.
A major blocker is the lack of tests, We should add tests, if it's possible proper integration tests, you can check examples in plugin_test.go.

README.md Show resolved Hide resolved
cache/backend/backend.go Show resolved Hide resolved
cache/backend/cloud_storage.go Outdated Show resolved Hide resolved
cache/backend/cloud_storage.go Outdated Show resolved Hide resolved
@a-hilaly
Copy link
Contributor Author

@kakkoyun Thanks for the review, i made the changes as requested. I still have the e2e tests to write. Will need to understand how they are working in order to add the correct tests.

@kakkoyun
Copy link
Contributor

Hey @a-hilaly, since you worked on GCP and aware of the AWS integration, I would like to have your opinion on https://github.com/google/go-cloud. This project is an abstraction over AWS, GCP and Azure. Maybe we can use this for object store integrations and provide integrations for other vendors like Azure as well. I'm not suggesting anything, just food for thought.

@a-hilaly
Copy link
Contributor Author

a-hilaly commented Oct 15, 2019

I think that's a very good idea ! it will be a tree birds one stone deal 😄 i also like the fact that it uses only the standard sdk for each cloud nothing more https://github.com/google/go-cloud/blob/master/go.mod
drone-cache will also benefit whenever go-cloud implement support a new blop storage provider.
One thing i cannot find in go-cloud is encryption and ACL support, maybe i'm looking on the wrong place 🤔

@kakkoyun
Copy link
Contributor

Thanks for the comment. Good point I'll check it.
Let's finish up with this PR since we are nearly at the end of it.
I have created an issue for go-cloud #76.

@kakkoyun
Copy link
Contributor

@a-hilaly Would you be able to push this through? Let me know if you need any help.

@a-hilaly
Copy link
Contributor Author

a-hilaly commented Oct 21, 2019

@kakkoyun Yes i'm working on this PR now. Need to rebase and add the plugin tests. Not sure how to use APIKey based access with minio (S3 uses SecretKey and AccessKey)

@kakkoyun
Copy link
Contributor

@a-hilaly Cool thanks! I'm not sure if minio could be used to test google cloud storage locally, we need to check. If not there must be a someway to emulate google cloud storage, we should just find it.

go.mod Outdated Show resolved Hide resolved
@a-hilaly
Copy link
Contributor Author

i made some research around GCS testing technics and i have found these two interesting projects:

I personally like the fake gcs server it could be very useful to write e2e tests. What do you think @kakkoyun ?

@kakkoyun
Copy link
Contributor

@a-hilaly I'm %100 with you on this one, just go with e2e tests. We only have e2e tests right now anyway.
fake-gcs-server it is 👍

@a-hilaly
Copy link
Contributor Author

@kakkoyun i tried to add the end to end tests, bucket creation and object creation works as expected but reading object fails with a weird error:

~/source/drone-cache(gcs-support*) » go test -v -timeout 30s github.com/meltwater/drone-cache/cache/backend -run ^TestCloudStorageTruth
=== RUN   TestCloudStorageTruth
--- FAIL: TestCloudStorageTruth (0.71s)
    cloud_storage_test.go:66: googleapi: got HTTP response code 403 with body: <?xml version='1.0' encoding='UTF-8'?><Error><Code>UserProjectAccountProblem</Code><Message>User project billing account not in good standing.</Message><Details>The billing account for project 47866975936 is disabled in state absent</Details></Error>
FAIL
FAIL    github.com/meltwater/drone-cache/cache/backend  0.860s
FAIL

i'll try to investigate more this error with different fake-gcs-servers versions

@a-hilaly a-hilaly force-pushed the gcs-support branch 2 times, most recently from 0cb82cc to 1228fcb Compare October 22, 2019 15:15
@kakkoyun
Copy link
Contributor

kakkoyun commented Nov 1, 2019

Hey @a-hilaly, I will try to give this one a push this weekend or in the next week.

What's left? Do you need help with something specific?

@a-hilaly
Copy link
Contributor Author

a-hilaly commented Nov 1, 2019

Hey @kakkoyun, i couldn't have all the end2end test fixed. Specifically this part https://github.com/A-Hilaly/drone-cache/blob/gcs-support/cache/backend/cloud_storage_test.go#L69-L73 . I'm not sure why this happens, i'm suspecting the fake-gcs-server.
EDIT: i remember trying to switch version for the fake-gcs-server because some of them were too buggy, i'll try to build my own image and see if that works

@kakkoyun
Copy link
Contributor

kakkoyun commented Feb 7, 2020

@a-hilaly I have rebased it, and I'm going to merge it.
I'll address testing issues in #45 before we cut v1.1.0 release.

@kakkoyun kakkoyun merged commit 5fc2888 into meltwater:master Feb 7, 2020
@kakkoyun kakkoyun added v1.1.0 Issues for v1.1.0 release and removed WIP Work in progress labels Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
storage-backend New storage backends v1.1.0 Issues for v1.1.0 release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Google Cloud Storage Backend
2 participants