-
Notifications
You must be signed in to change notification settings - Fork 315
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
Fix idempotency when using scaling with docker-compose #805
Conversation
in case they are referenced, otherwise compose update will fail on first run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed lint
Can I get tests run on this again please? I have fixed the lint, but am also looking at the acceptance test as it doesn't include scaling for docker-compose. Will look at that unless someone more familiar with this module can do it faster. |
There appears to be the error below on some tests. Any insight on if this needs to be stubbed or managed otherwise? It works IRL.
|
I have tried using the fileutils resource as an alternative, however the above issue still occurs, and only in testing. My guess is that the test is trying to create the /tmp_docker folder on the testing host, and failing. I have changed the tmp_docker path with removed leading slash, on production Linux hosts this now creates under /root, unsure if I am ok with this and where it would be created on Windows hosts (opinions appreciated). However it now passes spec tests locally. I have also added scaling to the acceptance tests, however am unable to run this locally, so if a mod could please rerun the automated tests and provide advice on acceptability to have the TMPDIR variable pointing to /root/tmp_docker, or how to otherwise solve this. I have tried stubbing the existence of the /tmp_docker folder as below, but cannot get it to work.
|
add scale to docker_compose acceptance test
@canihavethisone Hey thanks! I think i'm with you regarding the @david22swan Have you seen anything like this before? |
@chelnak thanks for assisting with this. I spent ages trying to mock/stub rspec to not create the /tmp_docker folder during spec test, I think that whatever folder is used we don't want rspec shelling out to actually create it! I can't get a stub to work, but feel it is the way to get it passing. In the meantime I have changed the path back to /tmp_docker as I see the non-absolute path failed in acceptance tests. At this stage I will leave it to the maintainers as I'm a bit out of ideas. Again, it (the /tmp_docker path) works IRL, at least on Linux. |
spec tests now pass
Now added a successful stub for /tmp_docker. Can you please re-run tests, and merge if acceptable. Thanks. |
@canihavethisone Thanks for this. Tests are running! |
@chelnak : Interesting, it looks like the spec test for define docker::registry is failing now. While the stub could be added to that test, I am unsure why it is referencing the mkdir from the compose? |
I'm not sure off the top of my head. I'd have to pull the code down and take a look. I'll try and get to that today but I'll also ping this to the team. Someone might be able to spot something. |
Thanks. I'm running spec tests with 'pdk test unit' and that wasn't failing locally, perhaps it's only running tests in /spec and not /functions |
Thats some good info.. It looks like the spec tests are run with Can you try that and let me know the outcome? |
@chelnak thanks for the parallel_spec command. I have got all spec tests to pass now by:
Looks like it should be fine now, although I did see one of the acceptance tests fail on connection error previously which seems unrelated. Boy, I don't like the way rspec stub work! |
Great job! Thanks for putting in the work!! |
No worries. I'm actually fixing 3 issues in this merge request:
I appreciate the opportunity to get this working. A colleague actually helped me with the stub syntax as I was stuck. |
@chelnak Passed! :) |
Thanks for your contribution! 🚀 |
@@ -13,6 +13,11 @@ | |||
environment(HOME: '/root') | |||
end | |||
|
|||
has_command(:docker_compose, command(:dockercompose)) do | |||
Dir.mkdir('/tmp_docker') unless Dir.exist?('/tmp_docker') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm getting permission denied from this, even when puppet agent is running as root. Besides that, it seems wrong to be creating this directory in the root of the filesystem. Also, what is this for? The TMPDIR
env var is never used in this code. Seems like this is here by mistake for the tests only. Bug report: #819
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Unsure why you are getting permission denied, it works for me IRL and also passes acceptance tests. What OS are you using?
- /tmp_docker is in the base path so that it is adjacent to /tmp, which is the dir that docker-compose uses by default. What location do you suggest?
- the $TMPDIR env var is respected by the Python underlying docker-compose. Using a path other than /tmp and setting that var overcomes the well-documented issue of docker-compose failing to run when noexec is set on /tmp. The change is there to overcome this and not for testing purposes only.
I have requested investigation into the reports of this issue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Ubuntu. What is the issue that this pull request is trying to address?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if the problem is that this code is running on the Puppet Server, not the agent, because the error occurs during catalog compilation. I can't find any evidence of this error other than during the puppet agent run, so I'm not sure why it's getting permission denied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it would be good if this were somehow made optional, so that we don't end up with /tmp_docker
on every system, even where docker isn't used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kenyon to address your comments:
- the pull request addresses the known issue with docker-compose executing from /tmp as also reported at /tmp directory requires "exec" mode for docker-compose execution docker/compose#8041
- I agree that the issue, while appearing only on the first puppet run, may be trying to apply the dir on the server. It may be linked to other reported issues I referenced on your issue raised as a result of this unexpected outcome
- the actual creation of the dir only occurs if resources are applied by docker_compose, and will not actually occur otherwise. Further, if you have this module on your puppetserver but not applied to nodes, they do not appear to be affected.
I agree that it is both unexpected and needs to be addressed, and have reported more detailed observations in your raised issue and also requested maintainer input.
Thank you for reporting the issue.
@@ -196,6 +196,12 @@ | |||
} | |||
else | |||
it { | |||
# Stub /tmp_docker dir to prevent shelling out during spec test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is that these are hiding real errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This stub/mock is to address the spec test only, not acceptance tests (which passed)
No description provided.