-
-
Notifications
You must be signed in to change notification settings - Fork 234
Support running pipelines in scheduled task queue #1871
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
Changes from all commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
380cd6f
Add PipelineSchedule and PipelineRun models
keshav-space 0b7f47c
Add pipeline execution task
keshav-space 6e48ddc
Add scheduler for pipeline tasks
keshav-space 21d9d5a
Add management command to init schedule
keshav-space 7bc98b3
Configure RQ settings
keshav-space efd8d2c
Add utility to get latest commit hash
keshav-space 656ef3c
Update logs in PipelineRun instance
keshav-space 7a79948
Add API endpoint for Pipeline schedule
keshav-space 202db9d
Add docker service for pipeline schedule
keshav-space dd8b252
Add list view for pipeline schedules
keshav-space baae4a8
Add css and js for log highlighting
keshav-space ba3879f
Add pipeline run list view
keshav-space e8b1cda
Add detail view for pipeline run
keshav-space d616ce6
Show default values for empty fields
keshav-space 0ba0549
Enable datetime localization for client
keshav-space 34dcd72
Allow temporary copy of .git to extract commit hash
keshav-space 1936d9f
Populate tag and commit on pulling git archive
keshav-space 354c605
Extract commit hash from git archive and local docker deployment
keshav-space ae1a260
Use uuid to track pipeline job id
keshav-space a96f775
Use scheduler to explicitly queue pipeline execution jobs
keshav-space 279bd06
Handle the stats for queued pipeline
keshav-space 472edc2
Add pipeline_url property to construct pipeline URL
keshav-space 0df4d48
Show execution_time for running jobs
keshav-space e7c8cba
Do not humanize execution time in api response
keshav-space 54a1911
Return only the latest pipeline run in API
keshav-space deda888
Truncate log to 5000 characters in API response
keshav-space edb6b61
Restrict modifications to admin users
keshav-space 4195e76
Prefix task queue services with vulnerablecode
keshav-space d074f6d
Add pipeline schedule to navbar
keshav-space 129bd9b
Highlight active navbar items
keshav-space 5c4e7c1
Pass redis hostname to docker image
keshav-space c1d6375
Defer unused fields to optimize pipeline queries
keshav-space 2bfbc46
Render stopped and stale pipeline statuses
keshav-space 84efc89
Dequeue job awaiting execution when stop job is requested
keshav-space 7879fb5
Skip linkcheck for unresponsive URL
keshav-space fd28465
Update failing view tests
keshav-space 2ffbb24
Use fa arrow icon for back buttons
keshav-space a34f485
Add tests for schedule and run model
keshav-space 9bdeba6
Ensure run fields are reset before job requeue
keshav-space 263f503
Add method to reset and requeue pipeline
keshav-space 6130597
Track execution timeout in schedule model
keshav-space fefe611
Show timezone in logs and stats
keshav-space 587328e
Add clientside pagination for bigger log snippets
keshav-space 312674f
Handle boundary condition in snippet navigation
keshav-space c67cf66
Add setting to toggle live logging for pipelines
keshav-space 217a466
Add copy button for pipeline and job ids
keshav-space 54ec053
Restrict modifications to staff users authed via session
keshav-space 9d8d22e
Add tests for /api/v2/schedule endpoint
keshav-space 5f2eb94
Display pipeline description in UI
keshav-space 0db4727
Reset throttling to properly test api rate limits
keshav-space 3c7def2
Add captcha challenge to staff login page
keshav-space File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
refs=$Format:%D$ | ||
commit=$Format:%H$ | ||
commit=$Format:%h$ | ||
abbrev_commit=$Format:%H$ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.VERSION export-subst |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# | ||
# Copyright (c) nexB Inc. and others. All rights reserved. | ||
# VulnerableCode is a trademark of nexB Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
# See https://github.com/aboutcode-org/vulnerablecode for support or download. | ||
# See https://aboutcode.org for more information about nexB OSS projects. | ||
# | ||
|
||
|
||
from django_rq.management.commands import rqscheduler | ||
|
||
from vulnerabilities import models | ||
from vulnerabilities.schedules import clear_zombie_pipeline_schedules | ||
from vulnerabilities.schedules import scheduled_job_exists | ||
from vulnerabilities.schedules import update_pipeline_schedule | ||
|
||
|
||
def init_pipeline_scheduled(): | ||
"""Initialize schedule jobs for active PipelineSchedule.""" | ||
active_pipeline_qs = models.PipelineSchedule.objects.filter(is_active=True).order_by( | ||
"created_date" | ||
) | ||
for pipeline_schedule in active_pipeline_qs: | ||
if scheduled_job_exists(pipeline_schedule.schedule_work_id): | ||
continue | ||
new_id = pipeline_schedule.create_new_job() | ||
pipeline_schedule.schedule_work_id = new_id | ||
pipeline_schedule.save(update_fields=["schedule_work_id"]) | ||
|
||
|
||
class Command(rqscheduler.Command): | ||
def handle(self, *args, **kwargs): | ||
clear_zombie_pipeline_schedules() | ||
update_pipeline_schedule() | ||
init_pipeline_scheduled() | ||
super(Command, self).handle(*args, **kwargs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# | ||
# Copyright (c) nexB Inc. and others. All rights reserved. | ||
# VulnerableCode is a trademark of nexB Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# See http://www.apache.org/licenses/LICENSE-2.0 for the license text. | ||
# See https://github.com/aboutcode-org/vulnerablecode for support or download. | ||
# See https://aboutcode.org for more information about nexB OSS projects. | ||
# | ||
|
||
import zoneinfo | ||
|
||
from django.utils import timezone | ||
|
||
|
||
class UserTimezoneMiddleware: | ||
def __init__(self, get_response): | ||
self.get_response = get_response | ||
|
||
def __call__(self, request): | ||
try: | ||
# Activate local timezone for user using cookies | ||
tzname = request.COOKIES.get("user_timezone") | ||
if tzname: | ||
timezone.activate(zoneinfo.ZoneInfo(tzname)) | ||
else: | ||
timezone.deactivate() | ||
except Exception as e: | ||
timezone.deactivate() | ||
|
||
return self.get_response(request) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.