Skip to content

Added RTD_VERSION_SLUG environment variable. #1570

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

Merged
merged 5 commits into from
Oct 22, 2015

Conversation

rrahn
Copy link

@rrahn rrahn commented Aug 18, 2015

Adds environment variable called RTD_VERSION_SLUG to identify selected version in conf.py.
See #1096 for more details.

@gregmuellegger
Copy link
Contributor

I'll leave the review up to @agjohnson who knows the infrastructure in that place best.

@agjohnson
Copy link
Contributor

This is only implemented on the BuildCommand class, it needs to be implemented on the DockerBuildCommand class as well.

We expose a READTHEDOCS var, this var should probably be called READTHEDOCS_VERSION, instead of RTD_VERSION_SLUG for consistency.

@ericholscher
Copy link
Member

Sounds like we should have a "Add env variables" function that is shared between both Command classes?

@agjohnson
Copy link
Contributor

Possibly. There is an added restriction here because env vars are added to the Popen call inside the BuildCommand class, whereas the docker API doesn't allow passing in env vars per command when using exec_create/exec_start. This would have to be done on environment creation, inside DockerBuildEnvironment, on the create_container call to the docker api:
https://github.com/rtfd/readthedocs.org/blob/master/readthedocs/doc_builder/environments.py#L571-L587

See also:
http://docker-py.readthedocs.org/en/latest/api/#create_container

@rrahn
Copy link
Author

rrahn commented Oct 1, 2015

Ok, I will change the name of the environment variable and add it to the DockerBuildCommand as described above.

@ericholscher
Copy link
Member

Seems good. The only change I would say is make it READTHEDOCS_VERSION instead of RTD_VERSION_SLUG. 👍 on merging after that. Might also make sense to add a READTHEDOCS_PROJECT in there as well, for completeness.

@rrahn
Copy link
Author

rrahn commented Oct 7, 2015

Ok I don't get the last comment correctly? I now should omit to pass the environment variable to the DockerBuilder and only rename it?
Otherwise, if I understand it correctly I have to pass the env variable to the DockerEnvironment when invoking create_container. Here I get the version slug from the base class BuildEnvironment which is also passed as build_env to the BuildCommand? Or where do I have to look for the version slug within the DockerEnvironment class?

Adds another environment var for the project slug.
Adds both to DockerEnvironment create_container function.
@rrahn
Copy link
Author

rrahn commented Oct 7, 2015

Ok I updated the PR. Hope this is done correctly. I am not so the python guy ... yet 😄

@@ -539,6 +542,8 @@ def create_container(self):
}
}),
detach=True,
environment = {'READTHEDOCS_VERSION' : self.version.slug,
Copy link
Member

Choose a reason for hiding this comment

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

This isn't needed. The top part is the only bit that will run in prod.

Remove these lines, and I'll merge.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, this was the thing that confused me if I should still provide this to the DockerEnvironment.

@agjohnson
Copy link
Contributor

This will effectively do nothing now that we are running build environments through Docker. My last comment above still stands, this will in fact need to be established on Docker container creation as well.

@agjohnson agjohnson added PR: work in progress Pull request is not ready for full review and removed PR: ready for review labels Oct 7, 2015
@ericholscher
Copy link
Member

This is where I added the READTHEDOCS env stuff -- seems like this should work the same way?

@agjohnson
Copy link
Contributor

It does work in the same way -- that is, it doesn't work :)

The above env pieces are only added on the BuildCommand call to Popen, the DockerEnvironment command execution doesn't use Popen at all, instead calling DockerBuildCommand.run, which executes through the Docker API via exec_start instead.

These pieces should be added to DockerEnvironment.create_container as well.

@rrahn
Copy link
Author

rrahn commented Oct 9, 2015

Ok i pushed the changes to the DockerEnvironment.

@agjohnson
Copy link
Contributor

Great, thanks!

agjohnson added a commit that referenced this pull request Oct 22, 2015
Added RTD_VERSION_SLUG environment variable.
@agjohnson agjohnson merged commit bb5a50a into readthedocs:master Oct 22, 2015
@rrahn
Copy link
Author

rrahn commented Oct 22, 2015

Oh cool.
Just one last question, are these changes already live or do we have to wait for the next release of RTD?
Thank you very much for your excellent support.

@agjohnson
Copy link
Contributor

Not yet deployed, but we'll likely squeeze those deploys in later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: work in progress Pull request is not ready for full review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants