Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Chenhao Ma
core
Commits
63e223c5
Commit
63e223c5
authored
7 years ago
by
Harsha Kethineni
Browse files
Options
Downloads
Patches
Plain Diff
db upgrade for batch states
parent
3bf40d4d
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
api/jobs/batch.py
+3
-3
3 additions, 3 deletions
api/jobs/batch.py
api/jobs/queue.py
+1
-0
1 addition, 0 deletions
api/jobs/queue.py
bin/database.py
+25
-1
25 additions, 1 deletion
bin/database.py
with
29 additions
and
4 deletions
api/jobs/batch.py
+
3
−
3
View file @
63e223c5
...
...
@@ -218,9 +218,9 @@ def check_state(batch_id):
batch
=
get
(
str
(
batch_id
))
if
batch
.
get
(
'
state
'
)
==
'
cancelled
'
:
return
Fals
e
batch_jobs
=
config
.
db
.
jobs
.
find
({
'
_id
'
:{
'
$in
'
:
batch
.
get
(
'
jobs
'
)},
'
state
'
:
{
'
$nin
'
:
[
'
complete
'
,
'
failed
'
]}})
non_failed_batch_jobs
=
config
.
db
.
jobs
.
find
({
'
_id
'
:{
'
$in
'
:
batch
.
get
(
'
jobs
'
)},
'
state
'
:
{
'
$ne
'
:
'
failed
'
}})
return
Non
e
batch_jobs
=
config
.
db
.
jobs
.
find
({
'
_id
'
:{
'
$in
'
:
batch
.
get
(
'
jobs
'
,
[]
)},
'
state
'
:
{
'
$nin
'
:
[
'
complete
'
,
'
failed
'
,
'
cancelled
'
]}})
non_failed_batch_jobs
=
config
.
db
.
jobs
.
find
({
'
_id
'
:{
'
$in
'
:
batch
.
get
(
'
jobs
'
,
[]
)},
'
state
'
:
{
'
$ne
'
:
'
failed
'
}})
if
batch_jobs
.
count
()
==
0
:
if
non_failed_batch_jobs
.
count
()
>
0
:
...
...
This diff is collapsed.
Click to expand it.
api/jobs/queue.py
+
1
−
0
View file @
63e223c5
...
...
@@ -72,6 +72,7 @@ class Queue(object):
if
result
.
modified_count
!=
1
:
raise
Exception
(
'
Job modification not saved
'
)
# If the job did not succeed, check to see if job should be retried.
if
'
state
'
in
mutation
and
mutation
[
'
state
'
]
==
'
failed
'
and
retry_on_explicit_fail
():
job
.
state
=
'
failed
'
Queue
.
retry
(
job
)
...
...
This diff is collapsed.
Click to expand it.
bin/database.py
+
25
−
1
View file @
63e223c5
...
...
@@ -19,8 +19,9 @@ from api.dao.containerstorage import ProjectStorage
from
api.jobs.jobs
import
Job
from
api.jobs
import
gears
from
api.types
import
Origin
from
api.jobs
import
batch
CURRENT_DATABASE_VERSION
=
3
4
# An int that is bumped when a new schema change is made
CURRENT_DATABASE_VERSION
=
3
5
# An int that is bumped when a new schema change is made
def
get_db_version
():
...
...
@@ -1164,6 +1165,29 @@ def upgrade_to_34():
config
.
db
.
groups
.
update_many
({
'
roles
'
:
{
'
$exists
'
:
True
}},
{
'
$rename
'
:
{
'
roles
'
:
'
permissions
'
}})
config
.
db
.
groups
.
update_many
({
'
name
'
:
{
'
$exists
'
:
True
}},
{
'
$rename
'
:
{
'
name
'
:
'
label
'
}})
def
upgrade_to_35_closure
(
batch_job
):
if
batch_job
.
get
(
'
state
'
)
in
[
'
cancelled
'
,
'
running
'
,
'
complete
'
,
'
failed
'
]:
return
True
batch_id
=
batch_job
.
get
(
'
_id
'
)
config
.
db
.
jobs
.
update_many
({
'
_id
'
:
{
'
$in
'
:
batch_job
.
get
(
'
jobs
'
,[])}},
{
'
$set
'
:
{
'
batch
'
:
batch_id
}})
new_state
=
batch
.
check_state
(
batch_id
)
if
new_state
:
result
=
config
.
db
.
batch
.
update_one
({
'
_id
'
:
batch_id
},
{
'
$set
'
:
{
"
state
"
:
new_state
}})
if
result
.
modified_count
!=
1
:
raise
Exception
(
'
Batch job not updated
'
)
else
:
result
=
config
.
db
.
batch
.
update_one
({
'
_id
'
:
batch_id
},
{
'
$set
'
:
{
"
state
"
:
"
running
"
}})
if
result
.
modified_count
!=
1
:
raise
Exception
(
'
Batch job not updated
'
)
return
True
def
upgrade_to_35
():
"""
scitran/core issue #710 - give batch stable states
"""
cursor
=
config
.
db
.
batch
.
find
({})
process_cursor
(
cursor
,
upgrade_to_35_closure
)
def
upgrade_schema
(
force_from
=
None
):
"""
Upgrades db to the current schema version
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment