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

Apply image changes 354 #922

Merged
merged 15 commits into from
Oct 22, 2014
Merged

Apply image changes 354 #922

merged 15 commits into from
Oct 22, 2014

Conversation

dwgebler
Copy link
Contributor

Fixes #353, #354 and #730 via the same code block.

See my comment on #730: #730 (comment)
in regards to deriving Link objects on Applications; all we have from DockerClient Units are environment variables, such as POSTGRES_PORT_5432_TCP_PORT=50432 or something in that format. Therefore to apply changes to the links portion of an application configuration, the only way I can see to do it at the moment (assuming we're being selective about what gets restarted, which we currently are) is to do some pretty awful regex matching on those environment variables to extrapolate the original Links. I'm not happy with this approach, but someone's going to have to give me a better idea if they want this to change.

Oh and #351 and/or #352 might be fixed by this branch, but if they are, it's a happy coincidence and work would certainly still need to be done on those issues at the very least in respect of tests.

…one.

This fixes the new application change detection code by making "inspected"
application state have the same shape as "desired" application state -
making both cases represent "no links" as an empty frozenset instead of
making one of those cases use None to represent that.
This is necessary on top of just telling the FakeDockerclient that
the unit has a volume.  Without it the storage pool and the docker client
have inconsistent volume state which is confusing and hopefully impossible
in real life.

It would be nice to have some nicer test scenario setup code so as to avoid
the need for this duplicate state setup.
…ects that are returned by DockerClient

in other words, horrible as it is, rely on RegEx parsing of environment variables in a container that match the format of <ALIAS>_PORT_<PORT>_TCP_PORT to derive the alias, local port (from the variable name) and remote port (from the variable value) for a Link. ** We do not have another way of doing this right now **
external_port=portmap.external_port
))
links = []
link_pattern = re.compile(
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest moving this logic out into its own function or method and then unit testing it directly, in addition to the high-level test.

Copy link
Contributor

Choose a reason for hiding this comment

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

Specifically the env variable parsing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of new function, just write relevant tests for application_from_units. Perhaps with some roundtripping to make sure you're using same environment variables we're generating elsewhere in the code.

@itamarst
Copy link
Contributor

Looking pretty good - please address comments and resubmit.

An ``Application`` with ``Link`` objects is discovered from a ``Unit``
with environment variables that correspond to an exposed link.
"""
environment = Environment(variables=frozenset((
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't we create these env variables automatically, rather than by hardcoding, if the test ran a StartApplication with the expected Application?

@itamarst
Copy link
Contributor

  1. There's missing code coverage for one of the code branches: http://build.clusterhq.com/results/apply-image-changes-354/flocker-2673/complete/flocker_node__deploy.html#n120
  2. Address comments above.

Then merge. Thanks!

@itamarst itamarst added accepted and removed review labels Oct 21, 2014
…vironments and replace with links parsed in to environment via StartApplication
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Changes to the ports in an existing application should be applied
2 participants