Skip to content

Conversation

@metayd
Copy link

@metayd metayd commented Sep 1, 2016

Fixes #3892

- What I did
Add volume and network label support for compose file v2

- How I did it

  1. Add labels to volume and network section in config_schema_v2.0.json
  2. Add implementation
  3. Add doc of volume and network label to docs/compose-file.md

-How to verify it
Add test in tests/unit/config/config_test.py, tests/integration/project_test.py and tests/acceptance/cli_test.py

@shin- PTAL

Signed-off-by: dbdd wangtong2712@gmail.com

v for v in self.client.volumes().get('Volumes', [])
if v['Name'].startswith('composetest_')
]

Copy link

Choose a reason for hiding this comment

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

nit: we don't need sorted() here since there's a single element

@shin-
Copy link

shin- commented Sep 1, 2016

Thanks! This is quite thourough. There's a few things I see:

  1. I have one minor nitpick on the test code, see above.
  2. We need to update the docker-py dependency in requirements.txt. We can use 235964607d200b57ea41383e54473c2976f4d730
  3. Since this requires API 1.23, we may actually want to / have to make it part of a 2.1 compose file spec. It's actually something we've already done for another option in Add support for link-local IPs in service.networks definition #3653 , but just hasn't been merged yet. cc @dnephin @aanand on this.

@metayd
Copy link
Author

metayd commented Sep 2, 2016

PR updated. PTAL @shin-

  1. Fixes nits
  2. Update docker-py dependency to 235964607d200b57ea41383e54473c2976f4d730

Do I need to use @v2_1_only in the releated test code and add [Version 2.1 file format] to the releated doc? or do these things after when #3653 is merged?

@alexmavr
Copy link

alexmavr commented Sep 6, 2016

@dbdd4us are you planning to address the network part of #3892 as well? This PR only seems to address volume labels

@metayd
Copy link
Author

metayd commented Sep 9, 2016

@alexmavr
I will add the network part as soon as possible. : )

I'm sorry I close this pr by accident just now.

@metayd metayd closed this Sep 9, 2016
@metayd metayd reopened this Sep 9, 2016
@metayd metayd changed the title Add support for creating volume with label definition Add support for creating volume and network with label definition Sep 17, 2016
@metayd
Copy link
Author

metayd commented Sep 17, 2016

PR updated. PTAL @alexmavr @shin-

  1. Add network part
  2. Update docker-py dependency to 1.10.2

I was wondering if I need to use @v2_1_only in the releated test code and add [Version 2.1 file format] to the releated doc? or do these things after when #3653 is merged?

Copy link

@shin- shin- left a comment

Choose a reason for hiding this comment

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

Hey @dbdd4us - sorry it took so long to get back to you. I wanted to have the changes from #3653 merged before we move forward with this.

I added a few comments to highlight the changes that need to be made to make the labels directives part of the 2.1 file format. They're trivial changes, but let me know if anything is unclear and I'll be happy to help. :)

},
"internal": {"type": "boolean"}
"internal": {"type": "boolean"},
"labels": {"$ref": "#/definitions/list_or_dict"}
Copy link

Choose a reason for hiding this comment

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

Now that config_schema_v2.1.json has been merged, we can move this property there.

"name": {"type": "string"}
}
},
"labels": {"$ref": "#/definitions/list_or_dict"},
Copy link

Choose a reason for hiding this comment

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

Now that config_schema_v2.1.json has been merged, we can move this property there.

requirements.txt Outdated
backports.ssl-match-hostname==3.5.0.1; python_version < '3'
cached-property==1.2.0
docker-py==1.9.0
docker-py==1.10.2
Copy link

Choose a reason for hiding this comment

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

You'll probably get a merge conflict here since we bumped to 1.10.3 in master.

self.dispatch(['-f', filename, 'up', '-d'])
container = self.project.containers()[0]
assert list(container.get('NetworkSettings.Networks')) == [network_name]

Copy link

Choose a reason for hiding this comment

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

Update this to @v2_1_only()

assert [n['Name'] for n in networks] == [network_with_label]

assert networks[0]['Labels'] == {'label_key': 'label_val'}

Copy link

Choose a reason for hiding this comment

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

Update this to @v2_1_only()

network = self.client.networks(names=['composetest_internal'])[0]

assert network['Internal'] is True

Copy link

Choose a reason for hiding this comment

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

Update this to @v2_1_only()

volume_data = self.client.inspect_volume(full_vol_name)
self.assertEqual(volume_data['Name'], full_vol_name)
self.assertEqual(volume_data['Driver'], 'local')

Copy link

Choose a reason for hiding this comment

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

Update this to @v2_1_only()

name: actual-name-of-volume

### labels

Copy link

Choose a reason for hiding this comment

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

Needs the > Added in version 2.1 file format line, similar to this

name: actual-name-of-network

### labels

Copy link

Choose a reason for hiding this comment

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

Needs the > Added in version 2.1 file format line, similar to this

@metayd metayd force-pushed the master branch 3 times, most recently from 73da01e to 0fcdeb3 Compare September 26, 2016 11:19
@metayd
Copy link
Author

metayd commented Sep 26, 2016

@shin- PR Updated, PTAL

I'm confused about the Reorder python imports Failed in Jenkins build.

@dnephin
Copy link

dnephin commented Sep 26, 2016

"Reorder python imports" is a lint/style check performed by pre-commit. It means the imports are not ordered correctly. You can either install http://pre-commit.com/ and run it to fix the issue, or you can re-order them manually.

Imports should be sorted and grouped according to "built-in", "third-party", "local"

I think in this case it doesn't like the multiple imports on a single line, and is moving it onto a new line

@metayd
Copy link
Author

metayd commented Sep 27, 2016

@dnephin
Thanks, it has been fixed. PR Updated, PTAL : )

@shin- shin- added this to the 1.9.0 milestone Sep 28, 2016
Copy link

@shin- shin- left a comment

Choose a reason for hiding this comment

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

LGTM!

@shin-
Copy link

shin- commented Oct 6, 2016

WIth the docs moving to a separate repository, this needs a rebase that removes the docs/compose-file.md. @dbdd4us , do you mind taking care of it? Thanks, and sorry about the delay on merging this.

@metayd
Copy link
Author

metayd commented Oct 7, 2016

@shin-
Rebased, but it seems that jenkins ci is broken, I'm not sure if it's accidental.

Signed-off-by: dbdd <wangtong2712@gmail.com>
@allencloud
Copy link

LGTM (IANAM)
Any Update?
Thanks

@volkyeth
Copy link

Closes #3107

Copy link

@aanand aanand left a comment

Choose a reason for hiding this comment

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

LGTM

@shin- shin- merged commit bdcce13 into docker:master Oct 17, 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.

8 participants