-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
De-duplicate builds #7123
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
De-duplicate builds #7123
Changes from 2 commits
e76a948
95350aa
030b0a5
9fcf10d
141bbf5
6ce7617
2802da9
e9767f1
30dde39
8ed21f6
954e004
190a628
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,7 @@ | |
) | ||
from readthedocs.doc_builder.constants import DOCKER_LIMITS | ||
from readthedocs.projects.constants import CELERY_LOW, CELERY_MEDIUM, CELERY_HIGH | ||
from readthedocs.doc_builder.exceptions import BuildMaxConcurrencyError | ||
from readthedocs.doc_builder.exceptions import BuildMaxConcurrencyError, DuplicatedBuildError | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
@@ -165,8 +165,42 @@ def prepare_build( | |
# External builds should be lower priority. | ||
options['priority'] = CELERY_LOW | ||
|
||
skip_build = False | ||
if commit: | ||
skip_build = ( | ||
Build.objects | ||
.filter( | ||
project=project, | ||
version=version, | ||
commit=commit, | ||
).exclude( | ||
state=BUILD_STATE_FINISHED, | ||
).exists() | ||
) | ||
else: | ||
skip_build = Build.objects.filter( | ||
project=project, | ||
version=version, | ||
state=BUILD_STATE_TRIGGERED, | ||
).count() > 1 | ||
if skip_build: | ||
# TODO: we could mark the old build as duplicated, however we reset our | ||
# position in the queue and go back to the end of it --penalization | ||
log.warning( | ||
'Marking build to be skipped by builder. project=%s version=%s build=%s commit=%s', | ||
project.slug, | ||
version.slug, | ||
build.pk, | ||
commit, | ||
) | ||
build.error = DuplicatedBuildError.message | ||
build.success = False | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should make this nullable and set it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes sense to me. However, I don't think we can change it now without changing the UI (knockout code) that renders in the frontend; which I'm not sure if we want to touch at this point. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea, I just worry this will break the badge display. |
||
build.exit_code = 1 | ||
build.state = BUILD_STATE_FINISHED | ||
build.save() | ||
|
||
# Start the build in X minutes and mark it as limited | ||
if project.has_feature(Feature.LIMIT_CONCURRENT_BUILDS): | ||
if not skip_build and project.has_feature(Feature.LIMIT_CONCURRENT_BUILDS): | ||
running_builds = ( | ||
Build.objects | ||
.filter(project__slug=project.slug) | ||
|
Uh oh!
There was an error while loading. Please reload this page.