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

Add volumes config to LXC driver #3687

Merged
merged 6 commits into from
Jan 18, 2018

Conversation

mikemccracken
Copy link
Contributor

Allow lxc driver to accept bind mount config similarly to the docker
driver.

Includes some static sanity checks in Validate step

Signed-off-by: Michael McCracken [email protected]

@mikemccracken
Copy link
Contributor Author

The failing check looks like a Travis-only error. I was unable to reproduce it locally.
I'm going to close and reopen this PR in case it is transient.

@@ -250,6 +270,13 @@ func (d *LxcDriver) Start(ctx *ExecContext, task *structs.Task) (*StartResponse,
fmt.Sprintf("%s alloc none rw,bind,create=dir", ctx.TaskDir.SharedAllocDir),
fmt.Sprintf("%s secrets none rw,bind,create=dir", ctx.TaskDir.SecretsDir),
}

for _, volDesc := range driverConfig.Volumes {
Copy link
Contributor

Choose a reason for hiding this comment

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


for _, volDesc := range driverConfig.Volumes {
// the format was checked in Validate()
paths := strings.Split(volDesc, ":")
Copy link
Contributor

Choose a reason for hiding this comment

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

Add tests and documentation

@mikemccracken
Copy link
Contributor Author

My apologies if overwriting the first commit made the review hard to go back to. Let me know if there's a workflow you prefer to follow for Nomad.

@schmichael
Copy link
Member

My apologies if overwriting the first commit made the review hard to go back to. Let me know if there's a workflow you prefer to follow for Nomad. -- @mikemccracken

Nope! That's fine!

Copy link
Member

@schmichael schmichael left a comment

Choose a reason for hiding this comment

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

LGTM other than a small style change to make a linter happy!

[]string{
":def",
},
[]string{
Copy link
Member

Choose a reason for hiding this comment

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

Tests are failing because our linter prefers the simplified version of this code. You can fix it with either gofmt -s lxc_test.go or just by using this:

        brokenVolumeConfigs := [][]string{
                {
                        "foo:/var",
                },
                {
                        ":",
                },
                {
                        "abc:",
                },
                {
                        ":def",
                },
                {
                        "abc:def:ghi",
                },
        }

A bit of a silly code style quibble, but it keeps our code consistent and linters happy!

@mikemccracken
Copy link
Contributor Author

Hi, just checking if there's anything else you need me to do here.

Thanks!


}

func TestLxcDriver_Start_NoVolumes(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be nice to get one that tests actually mounting a volume

@dadgar
Copy link
Contributor

dadgar commented Jan 18, 2018

@mikemccracken Everything looks great. I would just like to see a test actually mount a volume

Allow lxc driver to accept bind mount config similarly to the docker
driver.

Includes some static sanity checks in Validate step

Signed-off-by: Michael McCracken <[email protected]>
Signed-off-by: Michael McCracken <[email protected]>
Signed-off-by: Michael McCracken <[email protected]>
Ensure that bind mounting via the volumes config really did work.

Signed-off-by: Michael McCracken <[email protected]>
@mikemccracken
Copy link
Contributor Author

Rebased onto master, and added an extra check:

The original changes to TestLxcDriver_Start_Wait() mounted /tmp as /mnt/tmp in the container and just checked that the directory's mount point is created in the container. I added code to write a file and check that the file's contents as seen from inside the container match.

@dadgar dadgar merged commit 335fb4e into hashicorp:master Jan 18, 2018
@dadgar
Copy link
Contributor

dadgar commented Jan 18, 2018

@mikemccracken Really great PR! Thank you

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 13, 2023
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.

3 participants