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
eec8fa8a
Commit
eec8fa8a
authored
7 years ago
by
Harsha Kethineni
Browse files
Options
Downloads
Patches
Plain Diff
Now checks to for tag with specific gear name
parent
aaf21766
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/database.py
+25
-10
25 additions, 10 deletions
bin/database.py
with
25 additions
and
10 deletions
bin/database.py
+
25
−
10
View file @
eec8fa8a
...
...
@@ -962,14 +962,14 @@ def upgrade_to_26_closure(job):
return
True
# This logic WILL NOT WORK in parallel mode
gear_name
=
gear
[
'
gear
'
][
'
name
'
]
# Checks if the specific gear tag already exists for the job
# Redundant now that cursor only finds jobs without the tags
# for tag in job['tags']:
# if tag == gear_name:
# return True
for
tag
in
job
[
'
tags
'
]:
if
tag
==
gear_name
:
logging
.
info
(
"
Gear name tag already exists
"
)
return
True
# Update doc
result
=
config
.
db
.
jobs
.
update_one
({
'
_id
'
:
job
[
'
_id
'
]},
{
'
$push
'
:
{
'
tags
'
:
gear_name
}})
if
result
.
modified_count
==
1
:
...
...
@@ -979,10 +979,25 @@ def upgrade_to_26_closure(job):
def
upgrade_to_26_test_closure
(
job
):
for
count
,
tag
in
enumerate
(
job
[
'
tags
'
],
1
):
logging
.
info
(
count
)
if
count
>
2
:
raise
Exception
(
"
Job has multiple gear tags
"
)
gear
=
config
.
db
.
gears
.
find_one
({
'
_id
'
:
bson
.
ObjectId
(
job
[
'
gear_id
'
])},
{
'
gear.name
'
:
1
})
# This logic WILL NOT WORK in parallel mode
if
gear
is
None
:
logging
.
info
(
'
No gear found for job
'
+
str
(
job
[
'
_id
'
]))
return
True
if
gear
.
get
(
'
gear
'
,
{}).
get
(
'
name
'
,
None
)
is
None
:
logging
.
info
(
'
No gear found for job
'
+
str
(
job
[
'
_id
'
]))
return
True
# This logic WILL NOT WORK in parallel mode
gear_name
=
gear
[
'
gear
'
][
'
name
'
]
gear_name_tag_count
=
0
# Checks if the specific gear tag already exists for the job
for
tag
in
job
[
'
tags
'
]:
if
tag
==
gear_name
:
gear_name_tag_count
=
gear_name_tag_count
+
1
if
gear_name_tag_count
>
1
:
raise
Exception
(
"
Job has multiple gear name tags
"
)
return
True
def
upgrade_to_26
():
...
...
@@ -991,7 +1006,7 @@ def upgrade_to_26():
Add job tags back to the job document, and use a faster cursor-walking update method
"""
cursor
=
config
.
db
.
jobs
.
find
({
'
tags[1]
'
:
{
'
$exists
'
:
True
}})
#
cursor = config.db.jobs.find({'tags[1]': {'$exists': True}})
process_cursor
(
cursor
,
upgrade_to_26_closure
)
cursor
=
config
.
db
.
jobs
.
find
({})
process_cursor
(
cursor
,
upgrade_to_26_test_closure
)
...
...
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