Skip to content

Build: use same hack for VCS and build environments #9055

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 1 commit into from
Mar 31, 2022

Conversation

humitos
Copy link
Member

@humitos humitos commented Mar 30, 2022

sync_versions method executes some commands (e.g. hg tags) inside the Docker
container used for all the VCS commands. As it was being executed outside the
with statement the container was being killed after executing __exit__.

This commit uses the same technique we used as a workaround for build
environment as well (see #9018). However, this is not the most elegant solution and we
should find a way to make it better.

So far, it works and we can use it as a quick hotfix to make builds continue
working.

Closes #8995

`sync_versions` method executes some commands (e.g. `hg tags`) inside the Docker
container used for all the VCS commands. As it was being executed _outside_ the
`with` statement the container was being killed after executing `__exit__`.

This commit uses the same technique we used as a workaround for build
environment as well. However, this is not the most elegant solution and we
should find a way to make it better.

So far, it works and we can use it as a quick hotfix to make builds continue
working.
Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

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

Seems reasonable for a hotfix

@ericholscher ericholscher added the PR: hotfix Pull request applied as hotfix to release label Mar 30, 2022
Copy link
Contributor

@agjohnson agjohnson left a comment

Choose a reason for hiding this comment

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

I'm not caught up on the refactor we just did to this code, so I'm not confident my review here.

This seems safe enough, I understand the underlying issue and mostly understand this logic change I think, and I don't believe my note on the two conditionals is important.

So, take this as a +0.5, but only because this is code I'm not familiar with yet.

@@ -65,7 +65,30 @@ def setup_vcs(self):
),
)
Copy link
Contributor

Choose a reason for hiding this comment

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

These two conditionals will have moved to executing in the context manager. It doesn't seem important that either are executed outside the environment in the first place. But in case anyone has any more information about why this is, these seem to be the only logic order changes.

Copy link
Member Author

Choose a reason for hiding this comment

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

This code was being already executed inside the context manager. The difference now is that instead of the context manager being executed inside the BuildDirector is executed in the Celery task, so we can call an extra method there (sync_versions), which needs to be executed inside the context manager (Docker environment)

@humitos
Copy link
Member Author

humitos commented Mar 31, 2022

This commit uses the same technique we used as a workaround for build
environment as well (see #9018). However, this is not the most elegant solution and we
should find a way to make it better.

Another cleaner approach here would be to avoid using context manager (with statements) and use Celery handlers instead. This is, run the __enter__ and __exit__ code from the Celery task. Mainly, this is "creating the containers before they are needed", "removing the containers after they are used" and "performing a cleanup of the Docker containers in after_return in case there was an exception during the build process".

This will give us a better understanding of the flow without the complexity/magic/hiddenness that the context managers are currently providing.

@humitos
Copy link
Member Author

humitos commented Mar 31, 2022

I'm merging this PR since it's already hotfixed and it's working. We can open an issue to track the refactor, tho.

@humitos humitos merged commit 052f891 into main Mar 31, 2022
@humitos humitos deleted the humitos/build-environment-hack branch March 31, 2022 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: hotfix Pull request applied as hotfix to release
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Build: incompatible Mercurial versions from VCS setup than build commands
3 participants