Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
3436bcedb4df
Commit
3436bced
authored
Oct 03, 2019
by
GitLab Bot
Browse files
Add latest changes from gitlab-org/gitlab@master
parent
09d81de5e5f6
Changes
51
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/monitoring/utils.js
View file @
3436bced
import
{
secondsIn
,
timeWindowsKeyNames
}
from
'
./constants
'
;
const
secondsToMilliseconds
=
seconds
=>
seconds
*
1000
;
export
const
getTimeDiff
=
timeWindow
=>
{
const
end
=
Math
.
floor
(
Date
.
now
()
/
1000
);
// convert milliseconds to seconds
const
difference
=
secondsIn
[
timeWindow
]
||
secondsIn
.
eightHours
;
const
start
=
end
-
difference
;
return
{
...
...
@@ -3,13 +5,13 @@
export
const
getTimeDiff
=
timeWindow
=>
{
const
end
=
Math
.
floor
(
Date
.
now
()
/
1000
);
// convert milliseconds to seconds
const
difference
=
secondsIn
[
timeWindow
]
||
secondsIn
.
eightHours
;
const
start
=
end
-
difference
;
return
{
start
:
new
Date
(
s
tart
*
1000
).
toISOString
(),
end
:
new
Date
(
end
*
1000
).
toISOString
(),
start
:
new
Date
(
s
econdsToMilliseconds
(
start
)
).
toISOString
(),
end
:
new
Date
(
secondsToMilliseconds
(
end
)
).
toISOString
(),
};
};
export
const
getTimeWindow
=
({
start
,
end
})
=>
Object
.
entries
(
secondsIn
).
reduce
((
acc
,
[
timeRange
,
value
])
=>
{
...
...
@@ -11,9 +13,9 @@
};
};
export
const
getTimeWindow
=
({
start
,
end
})
=>
Object
.
entries
(
secondsIn
).
reduce
((
acc
,
[
timeRange
,
value
])
=>
{
if
(
end
-
start
===
value
)
{
if
(
new
Date
(
end
)
-
new
Date
(
start
)
===
secondsToMilliseconds
(
value
)
)
{
return
timeRange
;
}
return
acc
;
...
...
app/assets/javascripts/reports/store/utils.js
View file @
3436bced
...
...
@@ -11,7 +11,7 @@
const
{
failed
,
resolved
,
total
}
=
results
;
const
failedString
=
failed
?
n__
(
'
%d failed test result
'
,
'
%d failed test results
'
,
failed
)
?
n__
(
'
%d failed
/error
test result
'
,
'
%d failed
/error
test results
'
,
failed
)
:
null
;
const
resolvedString
=
resolved
?
n__
(
'
%d fixed test result
'
,
'
%d fixed test results
'
,
resolved
)
...
...
app/controllers/health_controller.rb
View file @
3436bced
...
...
@@ -4,12 +4,7 @@
protect_from_forgery
with: :exception
,
prepend:
true
include
RequiresWhitelistedMonitoringClient
CHECKS
=
[
Gitlab
::
HealthChecks
::
DbCheck
,
Gitlab
::
HealthChecks
::
Redis
::
RedisCheck
,
Gitlab
::
HealthChecks
::
Redis
::
CacheCheck
,
Gitlab
::
HealthChecks
::
Redis
::
QueuesCheck
,
Gitlab
::
HealthChecks
::
Redis
::
SharedStateCheck
,
Gitlab
::
HealthChecks
::
GitalyCheck
].
freeze
def
readiness
results
=
checks
.
flat_map
(
&
:readiness
)
success
=
results
.
all?
(
&
:success
)
...
...
@@ -15,4 +10,4 @@
def
readiness
results
=
CHECKS
.
map
{
|
check
|
[
check
.
name
,
check
.
readiness
]
}
# disable static error pages at the gitlab-workhorse level, we want to see this error response even in production
headers
[
"X-GitLab-Custom-Error"
]
=
1
unless
success
...
...
@@ -18,5 +13,6 @@
render_check_results
(
results
)
response
=
results
.
map
{
|
result
|
[
result
.
name
,
result
.
payload
]
}.
to_h
render
json:
response
,
status:
success
?
:ok
:
:service_unavailable
end
def
liveness
...
...
@@ -25,26 +21,7 @@
private
def
render_check_results
(
results
)
flattened
=
results
.
flat_map
do
|
name
,
result
|
if
result
.
is_a?
(
Gitlab
::
HealthChecks
::
Result
)
[[
name
,
result
]]
else
result
.
map
{
|
r
|
[
name
,
r
]
}
end
end
success
=
flattened
.
all?
{
|
name
,
r
|
r
.
success
}
response
=
flattened
.
map
do
|
name
,
r
|
info
=
{
status:
r
.
success
?
'ok'
:
'failed'
}
info
[
'message'
]
=
r
.
message
if
r
.
message
info
[
:labels
]
=
r
.
labels
if
r
.
labels
[
name
,
info
]
end
# disable static error pages at the gitlab-workhorse level, we want to see this error response even in production
headers
[
"X-GitLab-Custom-Error"
]
=
1
unless
success
render
json:
response
.
to_h
,
status:
success
?
:ok
:
:service_unavailable
def
checks
::
Gitlab
::
HealthChecks
::
CHECKS
end
end
app/controllers/projects/settings/operations_controller.rb
View file @
3436bced
...
...
@@ -63,7 +63,9 @@
:api_host
,
:token
,
project:
[
:slug
,
:name
,
:organization_slug
,
:organization_name
]
]
],
grafana_integration_attributes:
[
:token
,
:grafana_url
]
}
end
end
...
...
app/helpers/groups_helper.rb
View file @
3436bced
...
...
@@ -32,8 +32,7 @@
end
def
can_disable_group_emails?
(
group
)
Feature
.
enabled?
(
:emails_disabled
,
group
,
default_enabled:
true
)
&&
can?
(
current_user
,
:set_emails_disabled
,
group
)
&&
!
group
.
parent
&
.
emails_disabled?
can?
(
current_user
,
:set_emails_disabled
,
group
)
&&
!
group
.
parent
&
.
emails_disabled?
end
def
group_issues_count
(
state
:)
...
...
app/helpers/projects_helper.rb
View file @
3436bced
...
...
@@ -160,7 +160,7 @@
def
can_disable_emails?
(
project
,
current_user
)
return
false
if
project
.
group
&
.
emails_disabled?
can?
(
current_user
,
:set_emails_disabled
,
project
)
&&
Feature
.
enabled?
(
:emails_disabled
,
project
,
default_enabled:
true
)
can?
(
current_user
,
:set_emails_disabled
,
project
)
end
def
last_push_event
...
...
@@ -354,6 +354,14 @@
@project
.
metrics_setting_external_dashboard_url
end
def
grafana_integration_url
@project
.
grafana_integration
&
.
grafana_url
end
def
grafana_integration_token
@project
.
grafana_integration
&
.
token
end
private
def
get_project_nav_tabs
(
project
,
current_user
)
...
...
app/models/grafana_integration.rb
0 → 100644
View file @
3436bced
# frozen_string_literal: true
class
GrafanaIntegration
<
ApplicationRecord
belongs_to
:project
attr_encrypted
:token
,
mode: :per_attribute_iv
,
algorithm:
'aes-256-gcm'
,
key:
Settings
.
attr_encrypted_db_key_base_32
validates
:grafana_url
,
length:
{
maximum:
1024
},
addressable_url:
{
enforce_sanitization:
true
,
ascii_only:
true
}
validates
:token
,
:project
,
presence:
true
end
app/models/namespace.rb
View file @
3436bced
...
...
@@ -182,7 +182,7 @@
# any ancestor can disable emails for all descendants
def
emails_disabled?
strong_memoize
(
:emails_disabled
)
do
Feature
.
enabled?
(
:emails_disabled
,
self
,
default_enabled:
true
)
&&
self_and_ancestors
.
where
(
emails_disabled:
true
).
exists?
self_and_ancestors
.
where
(
emails_disabled:
true
).
exists?
end
end
...
...
app/models/project.rb
View file @
3436bced
...
...
@@ -195,6 +195,7 @@
has_one
:project_repository
,
inverse_of: :project
has_one
:error_tracking_setting
,
inverse_of: :project
,
class_name:
'ErrorTracking::ProjectErrorTrackingSetting'
has_one
:metrics_setting
,
inverse_of: :project
,
class_name:
'ProjectMetricsSetting'
has_one
:grafana_integration
,
inverse_of: :project
# Merge Requests for target project should be removed with it
has_many
:merge_requests
,
foreign_key:
'target_project_id'
,
inverse_of: :target_project
...
...
@@ -311,6 +312,7 @@
accepts_nested_attributes_for
:error_tracking_setting
,
update_only:
true
accepts_nested_attributes_for
:metrics_setting
,
update_only:
true
,
allow_destroy:
true
accepts_nested_attributes_for
:grafana_integration
,
update_only:
true
,
allow_destroy:
true
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
delegate
:members
,
to: :team
,
prefix:
true
...
...
@@ -664,7 +666,7 @@
def
emails_disabled?
strong_memoize
(
:emails_disabled
)
do
# disabling in the namespace overrides the project setting
Feature
.
enabled?
(
:emails_disabled
,
self
,
default_enabled:
true
)
&&
(
super
||
namespace
.
emails_disabled?
)
super
||
namespace
.
emails_disabled?
end
end
...
...
app/models/storage/hashed_project.rb
View file @
3436bced
...
...
@@ -27,4 +27,8 @@
"
#{
base_dir
}
/
#{
disk_hash
}
"
if
disk_hash
end
# TODO: remove this method entirely after 12.4 https://gitlab.com/gitlab-org/gitlab/issues/33244
# we no longer need ensure_storage_path_exists to call add_namespace since both creating and moving
# repositories will be preceded by a mkdir -p in gitaly to ensure the parent of the destination directory
# exists.
def
ensure_storage_path_exists
...
...
@@ -30,5 +34,5 @@
def
ensure_storage_path_exists
gitlab_shell
.
add_namespace
(
repository_storage
,
base_dir
)
true
end
def
rename_repo
(
old_full_path:
nil
,
new_full_path:
nil
)
...
...
app/models/storage/legacy_project.rb
View file @
3436bced
...
...
@@ -23,6 +23,10 @@
project
.
full_path
end
# TODO: remove this method entirely after 12.4 https://gitlab.com/gitlab-org/gitlab/issues/33244
# we no longer need ensure_storage_path_exists to call add_namespace since both creating and moving
# repositories will be preceded by a mkdir -p in gitaly to ensure the parent of the destination directory
# exists.
def
ensure_storage_path_exists
return
unless
namespace
...
...
@@ -26,7 +30,7 @@
def
ensure_storage_path_exists
return
unless
namespace
gitlab_shell
.
add_namespace
(
repository_storage
,
base_dir
)
true
end
def
rename_repo
(
old_full_path:
nil
,
new_full_path:
nil
)
...
...
app/services/projects/operations/update_service.rb
View file @
3436bced
...
...
@@ -12,7 +12,9 @@
private
def
project_update_params
error_tracking_params
.
merge
(
metrics_setting_params
)
error_tracking_params
.
merge
(
metrics_setting_params
)
.
merge
(
grafana_integration_params
)
end
def
metrics_setting_params
...
...
@@ -44,6 +46,14 @@
}
}
end
def
grafana_integration_params
return
{}
unless
attrs
=
params
[
:grafana_integration_attributes
]
destroy
=
attrs
[
:grafana_url
].
blank?
&&
attrs
[
:token
].
blank?
{
grafana_integration_attributes:
attrs
.
merge
(
_destroy:
destroy
)
}
end
end
end
end
...
...
changelogs/unreleased/30186-mirror-pull-api-no-unpause.yml
0 → 100644
View file @
3436bced
---
title
:
Do not start mirroring via API when paused
merge_request
:
17930
author
:
type
:
changed
changelogs/unreleased/33158-time-window-filter-dropdown-doesn-t-retain-previously-selected-wind.yml
0 → 100644
View file @
3436bced
---
title
:
Time window filter in monitor dashboard gets reset
merge_request
:
17972
author
:
type
:
fixed
changelogs/unreleased/eb-support-test-report-error-key.yml
0 → 100644
View file @
3436bced
---
title
:
MR Test Summary now shows errors as failures.
merge_request
:
17039
author
:
type
:
changed
changelogs/unreleased/sy-grafana-auth-be.yml
0 → 100644
View file @
3436bced
---
title
:
Create table for grafana api token for metrics embeds
merge_request
:
17234
author
:
type
:
added
config/light_settings.rb
View file @
3436bced
...
...
@@ -22,7 +22,7 @@
end
def
host
config
[
'gitlab'
][
'
host'
]
config
.
dig
(
'gitlab'
,
'host'
)
||
ENV
[
'GITLAB_HOST'
]
||
'local
host'
end
def
gl_subdomain?
...
...
config/locales/en.yml
View file @
3436bced
...
...
@@ -16,6 +16,9 @@
api_url
:
"
Sentry
API
URL"
project/metrics_setting
:
external_dashboard_url
:
"
External
dashboard
URL"
project/grafana_integration
:
token
:
"
Grafana
HTTP
API
Token"
grafana_url
:
"
Grafana
API
URL"
views
:
pagination
:
previous
:
"
Prev"
...
...
db/migrate/20190918102042_create_grafana_integrations.rb
0 → 100644
View file @
3436bced
# frozen_string_literal: true
class
CreateGrafanaIntegrations
<
ActiveRecord
::
Migration
[
5.2
]
DOWNTIME
=
false
def
change
create_table
:grafana_integrations
do
|
t
|
t
.
references
:project
,
index:
true
,
foreign_key:
{
on_delete: :cascade
},
unique:
true
,
null:
false
t
.
timestamps_with_timezone
null:
false
t
.
string
:encrypted_token
,
limit:
255
,
null:
false
t
.
string
:encrypted_token_iv
,
limit:
255
,
null:
false
t
.
string
:grafana_url
,
null:
false
,
limit:
1024
end
end
end
db/schema.rb
View file @
3436bced
...
...
@@ -1704,6 +1704,16 @@
t
.
index
[
"project_id"
],
name:
"index_gpg_signatures_on_project_id"
end
create_table
"grafana_integrations"
,
force: :cascade
do
|
t
|
t
.
bigint
"project_id"
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
t
.
string
"encrypted_token"
,
limit:
255
,
null:
false
t
.
string
"encrypted_token_iv"
,
limit:
255
,
null:
false
t
.
string
"grafana_url"
,
limit:
1024
,
null:
false
t
.
index
[
"project_id"
],
name:
"index_grafana_integrations_on_project_id"
end
create_table
"group_custom_attributes"
,
id: :serial
,
force: :cascade
do
|
t
|
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
datetime_with_timezone
"updated_at"
,
null:
false
...
...
@@ -3997,6 +4007,7 @@
add_foreign_key
"gpg_signatures"
,
"gpg_key_subkeys"
,
on_delete: :nullify
add_foreign_key
"gpg_signatures"
,
"gpg_keys"
,
on_delete: :nullify
add_foreign_key
"gpg_signatures"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"grafana_integrations"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"group_custom_attributes"
,
"namespaces"
,
column:
"group_id"
,
on_delete: :cascade
add_foreign_key
"identities"
,
"saml_providers"
,
name:
"fk_aade90f0fc"
,
on_delete: :cascade
add_foreign_key
"import_export_uploads"
,
"projects"
,
on_delete: :cascade
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment