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

OZ-560: Rename project,Added E2E tests and registration Opt In #1

Merged
merged 16 commits into from
Oct 7, 2024

Conversation

enyachoke
Copy link
Contributor

@enyachoke enyachoke commented Sep 20, 2024

This is a PR for the work in https://mekomsolutions.atlassian.net/browse/OZ-560. It introduces a number of changes to the original project;

  • Container registration is now opt-in
  • Upgrade a number of libraries
  • Adds E2E Tests

@rbuisson rbuisson self-requested a review September 23, 2024 09:09
await stopDockerCompose();
await startDockerCompose();
// Pause for 5 seconds to allow nginx test containers to start
await new Promise(r => setTimeout(r, 3000));
Copy link

Choose a reason for hiding this comment

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

Suggested change
await new Promise(r => setTimeout(r, 3000));
await new Promise(r => setTimeout(r, 5000));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kdaud is this based on your tests locally?

Copy link

Choose a reason for hiding this comment

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

Setting 3000 milliseconds equates to 3 seconds, and the comment indicates that a pause of 5 minutes is required to allow the Nginx test containers to start.

README.md Outdated
-e c2c_consul__host=localhost \
-e c2c_consul__port=8500 \
-v /var/run/docker.sock:/var/run/docker.sock \
mekomsolutions/container2sul
Copy link
Member

Choose a reason for hiding this comment

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

Should we keep this Docker image name?

README.md Outdated
Comment on lines 3 to 4
[![Build Status](https://travis-ci.org/mekomsolutions/container-to-consul.svg?branch=master)](https://travis-ci.org/mekomsolutions/container-to-consul)
[![codecov](https://codecov.io/gh/mekomsolutions/container-to-consul/branch/master/graph/badge.svg)](https://codecov.io/gh/mekomsolutions/container-to-consul)
Copy link
Member

Choose a reason for hiding this comment

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

Are these going to work?

Copy link
Member

Choose a reason for hiding this comment

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

Did you remove these lines?

README.md Outdated
The registered ip address can be configured using a `consul.ip` label.

```
docker run --rm --name containertoConsul -ti -l consul.ip=10.0.0.1 alpine ash
Copy link
Member

@rbuisson rbuisson Sep 23, 2024

Choose a reason for hiding this comment

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

Let's have the container named container-to-consul if possible.

README.md Outdated

Container-to-Consul automatically registers and deregisters nodes for any Docker container.

This project is inspired by [gliderlabs registrator](https://github.com/gliderlabs/registrator).
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this based on https://github.com/benoitvidis/con-tainer2sul instead?

Copy link
Member

Choose a reason for hiding this comment

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

If so, it needs more emphasis.
What about:

This project is largely based on the original work done in con-tainer2sul by Benoît Vidis. While this fork includes significant changes and improvements, we would like to acknowledge the foundation provided by the original project, without which this version would not have been possible.

Please note that some files, variables, or other elements might still reference the original project name. These remnants will be updated over time as the project evolves, but their presence reflects the project's roots as con-tainer2sul.

README.md Outdated
[![Build Status](https://travis-ci.org/mekomsolutions/container-to-consul.svg?branch=master)](https://travis-ci.org/mekomsolutions/container-to-consul)
[![codecov](https://codecov.io/gh/mekomsolutions/container-to-consul/branch/master/graph/badge.svg)](https://codecov.io/gh/mekomsolutions/container-to-consul)

Container-to-Consul automatically registers and deregisters nodes for any Docker container.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Container-to-Consul automatically registers and deregisters nodes for any Docker container.
Container-to-Consul automatically registers and deregisters any Docker container as HashiCorp Consul nodes.

Copy link
Member

Choose a reason for hiding this comment

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

@enyachoke the doc specifies multiple commands to be run, with different option. Can those options be used simultaneously? eg, using consul.service=myservice and consul.tags=xyz

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes they can as used in the tests

image: nginx:1-alpine
labels:
- "consul.port=80"
- "consul.tags=nginx"
- "consul.service=nginx-register"
- "consul.ip=10.0.0.1"
- "consul.register=true"

Copy link
Member

@rbuisson rbuisson Sep 23, 2024

Choose a reason for hiding this comment

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

In that case, the structure of the doc is misleading.
Why would someone want to run those commands one by one like that?

I suppose it is better to simply document what the options can do, without an example docker run --rm ... which in fact will probably never be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In that case, the structure of the doc is misleading. Why would someone want to run those commands one by one like that?

I suppose it is better to simply document what the options can do, without an example docker run --rm ... which in fact will probably never be used.

The commands are used to explain the effect of the option and are not necessarily complete usage examples.

@rbuisson
Copy link
Member

rbuisson commented Sep 23, 2024

@enyachoke could you provide some instructions to test?
The Docker image mekomsolutions/container2sul does not seem to be available so how do I build it?

@enyachoke
Copy link
Contributor Author

enyachoke commented Sep 23, 2024

@enyachoke could you provide some instructions to test? The Docker image mekomsolutions/container2sul does not seem to be available so how do I build it?

@rbuisson This will be available after we merge see

uses: mekomsolutions/shared-github-workflow/.github/workflows/docker-build-publish.yml@main
with:
download-artifacts: false
image-name: "container-to-consul"
secrets:
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_REGISTRY_USERNAME }}
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_REGISTRY_PASSWORD }}

@rbuisson
Copy link
Member

Yes I know. So what are the instructions?
docker build first? (what exact command). And then what?

Copy link
Member

@rbuisson rbuisson left a comment

Choose a reason for hiding this comment

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

I've pushed a change on the README to add some screenshots.
I've left some comments as well.

But it works!
Thanks, that's an awesome tool!

types: [published]

jobs:
docker-release:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
docker-release:
docker-publish:

"unit-tests": "istanbul cover _mocha -- --recursive --reporter spec --require should --require should-sinon"
},
"author": "Benoît Vidis",
"license": "Apache-2.0",
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a new key for contributors:

"contributors": [ "Mekom Solutions (https://mekomsolutions.com/)" ]

README.md Outdated
Comment on lines 3 to 4
[![Build Status](https://travis-ci.org/mekomsolutions/container-to-consul.svg?branch=master)](https://travis-ci.org/mekomsolutions/container-to-consul)
[![codecov](https://codecov.io/gh/mekomsolutions/container-to-consul/branch/master/graph/badge.svg)](https://codecov.io/gh/mekomsolutions/container-to-consul)
Copy link
Member

Choose a reason for hiding this comment

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

Did you remove these lines?

README.md Outdated
Running;

```
docker run --name docker-nginx -d -l consul.register=true -l consul.ip=10.0.0.1 -l consul.service=nginx-service -l consul.tags=www,api -l consul.port=80 -l consul.kv.foo=bar -l consul.kv.bar=baz nginx
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
docker run --name docker-nginx -d -l consul.register=true -l consul.ip=10.0.0.1 -l consul.service=nginx-service -l consul.tags=www,api -l consul.port=80 -l consul.kv.foo=bar -l consul.kv.bar=baz nginx
docker run --name nginx -d \
-l consul.register=true \
-l consul.ip=10.0.0.1 \
-l consul.service=nginx \
-l consul.tags=www,api \
-l consul.port=80 \
-l consul.kv.foo=bar \
-l consul.kv.bar=baz \
nginx

README.md Outdated

### Deregistration

To deregister the container, you can simply stop it and remove it.
Copy link
Member

Choose a reason for hiding this comment

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

Is removing the container necessary to deregister? I don't think so, right?
I suggest to then remove the rm command to put it a bit after, as a note or something.

Copy link

@kdaud kdaud left a comment

Choose a reason for hiding this comment

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

LGTM

@rbuisson needs to do a final review of the PR.

@rbuisson rbuisson merged commit 13f6f97 into mekomsolutions:main Oct 7, 2024
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.

5 participants