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

Use atomic ints for namespaces #113

Merged
merged 1 commit into from
May 14, 2021
Merged

Use atomic ints for namespaces #113

merged 1 commit into from
May 14, 2021

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented May 14, 2021

It's always been a weird quirk that you need to specify a unique namespace string when
deploying containers. This is for parallel tests such that if 2 tests deploy
BlueprintAlice they get unique container names.

This PR changes the API so that we just increment an atomic
counter and use that as the namespace.

It's always been a weird quirk that you need to specify a unique namespace string when
deploying containers. This is for parallel tests such that if 2 tests deploy
BlueprintAlice they get unique container names.

This PR changes the API so that we just increment an atomic
counter and use that as the namespace.
@kegsay kegsay requested a review from anoadragon453 May 14, 2021 13:59
Copy link
Member

@anoadragon453 anoadragon453 left a comment

Choose a reason for hiding this comment

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

Great QoL improvement, thanks!

@kegsay kegsay merged commit e8c19ba into master May 14, 2021
kegsay added a commit that referenced this pull request Jul 20, 2021
This is the beginning of the work for #119.

 - Add the concept of `PackageNamespace` to `config.Complement`. Set to `""` for now.
 - Update all filters to look for a matching package namespace when creating blueprints
   and containers.
 - Cleanup `docker.Builder` to read from the config more and from copies of config fields less.

This change should be invisible to any existing Complement users.

Background:

Previously, Complement assumed that each container could be uniquely
identified by the combination of `deployment_namespace + blueprint_name + hs_name`.
For example, if you were running `BlueprintAlice` then a unique string might look like
`5_alice_hs1` where `5` is an atomic, monotonically increasing integer incremented when
`Deploy()` is called (see #113 for more info).

In a parallel by default world this is no longer true because the `deployment_namespace`
is not shared between different test processes. This means we cannot co-ordinate non-clashing
namespaces like before. Instead, we will bring in another namespace for the test process
(which in #119 will be on a per-package basis, hence the name `PackageNamespace`).

As of this PR, literally everything Complement makes (images, containers, networks, etc) are prefixed with
this package namespace, which allows multiple complement instances to share the same underlying
docker daemon, with caveats:
 - Creating CA certificates will race and needs a lockfile to prevent 2 processes trying to create
  the certificate at the same time.
 - Complement federation servers cannot run together due to trying to bind to `:8448` at the same time.

That being said, this PR should enable the parallelisation of a number of CS API only tests,
which will come in another PR.
kegsay added a commit that referenced this pull request Jul 21, 2021
* Introduce the concept of a package namespace

This is the beginning of the work for #119.

 - Add the concept of `PackageNamespace` to `config.Complement`. Set to `""` for now.
 - Update all filters to look for a matching package namespace when creating blueprints
   and containers.
 - Cleanup `docker.Builder` to read from the config more and from copies of config fields less.

This change should be invisible to any existing Complement users.

Background:

Previously, Complement assumed that each container could be uniquely
identified by the combination of `deployment_namespace + blueprint_name + hs_name`.
For example, if you were running `BlueprintAlice` then a unique string might look like
`5_alice_hs1` where `5` is an atomic, monotonically increasing integer incremented when
`Deploy()` is called (see #113 for more info).

In a parallel by default world this is no longer true because the `deployment_namespace`
is not shared between different test processes. This means we cannot co-ordinate non-clashing
namespaces like before. Instead, we will bring in another namespace for the test process
(which in #119 will be on a per-package basis, hence the name `PackageNamespace`).

As of this PR, literally everything Complement makes (images, containers, networks, etc) are prefixed with
this package namespace, which allows multiple complement instances to share the same underlying
docker daemon, with caveats:
 - Creating CA certificates will race and needs a lockfile to prevent 2 processes trying to create
  the certificate at the same time.
 - Complement federation servers cannot run together due to trying to bind to `:8448` at the same time.

That being said, this PR should enable the parallelisation of a number of CS API only tests,
which will come in another PR.

* Set to pkg to keep the ref format of committed containers valid
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.

2 participants