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

Amazon EBS Storage Driver #248

Merged
merged 1 commit into from
Sep 16, 2016
Merged

Conversation

proudh
Copy link
Contributor

@proudh proudh commented Aug 23, 2016

This adds basic functionality for the EBS driver that was originally in REX-Ray 0.3.3 under the EC2 driver as per issue #183. Snapshot functionality is written but is awaiting other storage drivers to implement snapshots as well.

  • Updated and more granular tagging: to be handled by @echupriyanov as per issue #126
  • Retries on failed operations (handles API overloads)
  • Updated next device discovery logic (handles phantom devices)
    • Implement
    • Test
  • Update ec2 to ebs with backwards compat
    • Register new driver for ebs that points to same constructor as ec2
    • Rename ec2 package(s) to ebs
    • Update config prefix from ec2 to ebs
    • Register backwards compat aliases for old ec2 config prefixes. See this file for an example of what that means.
  • Change rexrayTag config option to match the EFS driver's tag config name
  • Volume encryption option
  • Locking mechanism on volume attach/detaches

@CLAassistant
Copy link

CLAassistant commented Aug 23, 2016

CLA assistant check
All committers have signed the CLA.

WaitVolumeCreate = "create"
//@enum WaitAction
WaitVolumeAttach = "attach"
//@enum WaitAction

Choose a reason for hiding this comment

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

comment on exported const WaitVolumeDetach should be of the form "WaitVolumeDetach ..."

@proudh proudh force-pushed the feature/ec2-driver branch from d6bee7f to 900dfc2 Compare September 6, 2016 18:54
@codecov-io
Copy link

codecov-io commented Sep 6, 2016

Current coverage is 25.55% (diff: 16.39%)

Merging #248 into master will decrease coverage by 0.45%

@@             master       #248   diff @@
==========================================
  Files            41         43     +2   
  Lines          2484       2606   +122   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits            646        666    +20   
- Misses         1770       1872   +102   
  Partials         68         68          

Powered by Codecov. Last update c5cdd6d...1793ce2

@proudh proudh force-pushed the feature/ec2-driver branch from 900dfc2 to ccaa9ff Compare September 6, 2016 23:43
@proudh proudh force-pushed the feature/ec2-driver branch 3 times, most recently from 9699c2f to d3e8b0a Compare September 15, 2016 19:53
@akutz akutz self-assigned this Sep 15, 2016
@akutz
Copy link
Collaborator

akutz commented Sep 15, 2016

Hi @proudh,

Can you please attach a successful test run code cov output to this PR? Thank you.

@akutz akutz changed the title WiP - Feature/ec2 driver WiP - Amazon EBS Storage Driver Sep 15, 2016
@proudh
Copy link
Contributor Author

proudh commented Sep 15, 2016

Here is the test output:

$ go test -v ec2_test.go 
=== RUN   TestConfig
--- PASS: TestConfig (4.81s)
=== RUN   TestInstanceID
--- PASS: TestInstanceID (1.21s)
=== RUN   TestInstanceIDEC2
--- PASS: TestInstanceIDEC2 (1.24s)
=== RUN   TestServices
--- PASS: TestServices (2.45s)
=== RUN   TestVolumeAttach
--- PASS: TestVolumeAttach (18.05s)
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "available",
          "id": "vol-89875201",
          "type": "standard"
        }
    tests.go:504: {
          "attachments": [
            {
              "deviceName": "",
              "instanceID": {
                "id": "i-ad4ee5b5",
                "driver": "ebs"
              },
              "status": "attached",
              "volumeID": "vol-89875201"
            }
          ],
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "in-use",
          "id": "vol-89875201",
          "type": "standard"
        }
    tests.go:504: {
          "attachments": [
            {
              "deviceName": "/dev/xvdg",
              "instanceID": {
                "id": "i-ad4ee5b5",
                "driver": "ebs"
              },
              "status": "attached",
              "volumeID": "vol-89875201"
            }
          ],
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "in-use",
          "id": "vol-89875201",
          "type": "standard"
        }
    tests.go:504: {
          "attachments": [
            {
              "deviceName": "",
              "instanceID": {
                "id": "i-ad4ee5b5",
                "driver": "ebs"
              },
              "status": "attached",
              "volumeID": "vol-89875201"
            }
          ],
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "in-use",
          "id": "vol-89875201",
          "type": "standard"
        }
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "available",
          "id": "vol-89875201",
          "type": "standard"
        }
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "available",
          "id": "vol-89875201",
          "type": "standard"
        }
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "available",
          "id": "vol-89875201",
          "type": "standard"
        }
=== RUN   TestVolumeCreateRemove
--- PASS: TestVolumeCreateRemove (5.08s)
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "available",
          "id": "vol-99875211",
          "type": "standard"
        }
=== RUN   TestEncryptedVolumeCreateRemove
--- PASS: TestEncryptedVolumeCreateRemove (5.05s)
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "encrypted": true,
          "name": "RR/2ef136bf",
          "size": 2,
          "status": "available",
          "id": "vol-1c845194",
          "type": "standard"
        }
=== RUN   TestVolumes
--- PASS: TestVolumes (9.05s)
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/2ef136bf",
          "size": 1,
          "status": "available",
          "id": "vol-e0875268",
          "type": "standard"
        }
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/7f798c6e",
          "size": 1,
          "status": "available",
          "id": "vol-1787529f",
          "type": "standard"
        }
PASS
ok      command-line-arguments    47.468s

@akutz akutz changed the title WiP - Amazon EBS Storage Driver Amazon EBS Storage Driver Sep 16, 2016
Copy link
Collaborator

@akutz akutz left a comment

Choose a reason for hiding this comment

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

Hi @proudh,

This looks really good, but there are a few changes that need to be handled prior to merging this PR.

  • The manner in which the config compatibility is handled is incomplete and perhaps not in the correct location.
    • The config keys are driver specific so instead of being placed in api/types/types_config_compat.go you could create a similar file at api/drivers/storage/ebs/ebs_config_compat.go.
    • Just having the keys defined doesn't make anything backwards compatible. You must also reproduce this function. Please do so in an init() call in the same suggested file, api/drivers/storage/ebs/ebs_config_compat.go.
    • Because you're defining the back-compat keys as constants it also makes since to define the same EBS keys as constants. This will make things more error-proof when defining the back-compat links. Again, use the suggested file to do so.
  • Please rename any files with ec2 in them to ebs. For example, drivers/storage/ebs/ec2.go should be drivers/storage/ebs/ebs.go. The files include:
    Old File Name New File Name
    drivers/storage/ebs/ec2.go drivers/storage/ebs/ebs.go
    drivers/storage/ebs/executor/ec2_executor.go drivers/storage/ebs/executor/ebs_executor.go
    drivers/storage/ebs/storage/ec2_driver.go drivers/storage/ebs/storage/ebs_driver.go
    drivers/storage/ebs/tests/ec2_test.go drivers/storage/ebs/tests/ebs_test.go
  • Please remove this section from glide.yaml. I understand the point of adding it, even as a comment. However, tags or branch names should be used in glide.yaml where possible. Additionall, since the EFS driver already requires this dependency, please simply change the comment from # EFS to # EFS and EBS. Does that make sense? Thanks!

@akutz
Copy link
Collaborator

akutz commented Sep 16, 2016

Hi @proudh,

The table was not formatted correctly in my PR review. Here you go:

Old File Name New File Name
drivers/storage/ebs/ec2.go drivers/storage/ebs/ebs.go
drivers/storage/ebs/executor/ec2_executor.go drivers/storage/ebs/executor/ebs_executor.go
drivers/storage/ebs/storage/ec2_driver.go drivers/storage/ebs/storage/ebs_driver.go
drivers/storage/ebs/tests/ec2_test.go drivers/storage/ebs/tests/ebs_test.go


// Retrieve config arguments
func (d *driver) accessKey() string {
if d.config.GetString("ebs.accessKey") != "" {
Copy link
Collaborator

@akutz akutz Sep 16, 2016

Choose a reason for hiding this comment

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

Hi @proudh,

Wherever you're following this convention:

if d.config.GetVALUE("key") != DEFAULT {
    return d.config.GetVALUE("key")
}

It should be changed to the following to make it more efficient:

if val := d.config.GetVALUE("key"); val != DEFAULT {
    return val
}

This commit ports volume management functionality for AWS EBS
for EC2 instances from REX-Ray 0.3.3, as per issue #183.
@proudh
Copy link
Contributor Author

proudh commented Sep 16, 2016

Test output after code review changes and rebase:

$ go test -v ebs_test.go 
=== RUN   TestConfig
--- PASS: TestConfig (4.90s)
=== RUN   TestInstanceID
--- PASS: TestInstanceID (1.24s)
=== RUN   TestInstanceIDEC2
--- PASS: TestInstanceIDEC2 (1.26s)
=== RUN   TestServices
--- PASS: TestServices (2.48s)
=== RUN   TestVolumeAttach
--- PASS: TestVolumeAttach (18.43s)
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "available",
          "id": "vol-3d3aedb5",
          "type": "standard"
        }
    tests.go:504: {
          "attachments": [
            {
              "deviceName": "",
              "instanceID": {
                "id": "i-ad4ee5b5",
                "driver": "ebs"
              },
              "status": "attached",
              "volumeID": "vol-3d3aedb5"
            }
          ],
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "in-use",
          "id": "vol-3d3aedb5",
          "type": "standard"
        }
    tests.go:504: {
          "attachments": [
            {
              "deviceName": "/dev/xvdg",
              "instanceID": {
                "id": "i-ad4ee5b5",
                "driver": "ebs"
              },
              "status": "attached",
              "volumeID": "vol-3d3aedb5"
            }
          ],
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "in-use",
          "id": "vol-3d3aedb5",
          "type": "standard"
        }
    tests.go:504: {
          "attachments": [
            {
              "deviceName": "",
              "instanceID": {
                "id": "i-ad4ee5b5",
                "driver": "ebs"
              },
              "status": "attached",
              "volumeID": "vol-3d3aedb5"
            }
          ],
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "in-use",
          "id": "vol-3d3aedb5",
          "type": "standard"
        }
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "available",
          "id": "vol-3d3aedb5",
          "type": "standard"
        }
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "available",
          "id": "vol-3d3aedb5",
          "type": "standard"
        }
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "available",
          "id": "vol-3d3aedb5",
          "type": "standard"
        }
=== RUN   TestVolumeCreateRemove
--- PASS: TestVolumeCreateRemove (5.11s)
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "available",
          "id": "vol-123aed9a",
          "type": "standard"
        }
=== RUN   TestEncryptedVolumeCreateRemove
--- PASS: TestEncryptedVolumeCreateRemove (5.52s)
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "encrypted": true,
          "name": "RR/8783557d",
          "size": 2,
          "status": "available",
          "id": "vol-3a3aedb2",
          "type": "standard"
        }
=== RUN   TestVolumes
--- PASS: TestVolumes (13.38s)
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/8783557d",
          "size": 1,
          "status": "available",
          "id": "vol-153aed9d",
          "type": "standard"
        }
    tests.go:504: {
          "availabilityZone": "us-west-2a",
          "name": "RR/1f5a1ce4",
          "size": 1,
          "status": "available",
          "id": "vol-473aedcf",
          "type": "standard"
        }
PASS
ok      command-line-arguments  52.837s

Copy link
Collaborator

@akutz akutz left a comment

Choose a reason for hiding this comment

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

Hi @proudh,

I saw two things that will not halt the merge, but I did want you to see my comments about them.

"github.com/akutz/gofig"
"github.com/akutz/goof"

ebsConfig "github.com/emccode/libstorage/api/drivers/storage/ebs"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @proudh,

No need to import this twice as separate packages. I'll handle it later. Just calling attention to it for your future projects :)


func (d *driver) Init(ctx types.Context, config gofig.Config) error {
// Ensure backwards compatibility with ebs and ec2 in config
ebsConfig.BackCompat(config)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @proudh,

See my above comment. This line could just be:

ebs.BackCompat(config)

@akutz akutz merged commit e8f10ec into thecodeteam:master Sep 16, 2016
@akutz akutz removed the in progress label Sep 16, 2016
@codenrhoden
Copy link
Contributor

Just a heads up that I am currently testing the EBS driver functionality. I'll test out basic rexray CLI usage, docker volumes, and pre-emption. @cduchesne @akutz

As part of that, I can already say I will have a PR to update docs for both rexray and libstorage.

@codenrhoden
Copy link
Contributor

Just to document what I tested...

I installed rexray with the latest libstorage on Ubuntu 16.04 and CentOS 7.2. I did both single-node (all in one) and 2-node setups with one node as a libstorage server. I tested rexray CLI directly and docker volume commands for create, mount, and unmount.

I found a crash for preemption that was fixed with #271

I added docs with #273. The docs were mostly taken from rexray 0.3.3 docs, with some relevant changes and inspiration from the EFS driver. It may be the case that there is more work to do around IAM if you want to use a libstorage server and IAM roles. I was just using my admin keys directly.

@cduchesne cduchesne added this to the 0.3.0 milestone Oct 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants