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
dadfab0c4424
Commit
dadfab0c
authored
Dec 06, 2019
by
GitLab Bot
Browse files
Add latest changes from gitlab-org/gitlab@master
parent
038949853ce8
Changes
43
Hide whitespace changes
Inline
Side-by-side
app/assets/javascripts/pages/snippets/show/index.js
View file @
dadfab0c
...
...
@@ -5,9 +5,11 @@
import
snippetEmbed
from
'
~/snippet/snippet_embed
'
;
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
new
LineHighlighter
();
// eslint-disable-line no-new
new
BlobViewer
();
// eslint-disable-line no-new
initNotes
();
new
ZenMode
();
// eslint-disable-line no-new
snippetEmbed
();
if
(
!
gon
.
features
.
snippetsVue
)
{
new
LineHighlighter
();
// eslint-disable-line no-new
new
BlobViewer
();
// eslint-disable-line no-new
initNotes
();
new
ZenMode
();
// eslint-disable-line no-new
snippetEmbed
();
}
});
app/finders/clusters/knative_serving_namespace_finder.rb
0 → 100644
View file @
dadfab0c
# frozen_string_literal: true
module
Clusters
class
KnativeServingNamespaceFinder
attr_reader
:cluster
def
initialize
(
cluster
)
@cluster
=
cluster
end
def
execute
cluster
.
kubeclient
&
.
get_namespace
(
Clusters
::
Kubernetes
::
KNATIVE_SERVING_NAMESPACE
)
rescue
Kubeclient
::
ResourceNotFoundError
nil
end
end
end
app/finders/clusters/knative_version_role_binding_finder.rb
View file @
dadfab0c
...
...
@@ -9,9 +9,9 @@
end
def
execute
cluster
&
.
kubeclient
&
.
get_cluster_role_binding
s
&
.
find
do
|
resource
|
res
ource
.
metadata
.
name
==
Clusters
::
Kubernetes
::
GITLAB_KNATIVE_VERSION_ROLE_BINDING_NAME
end
cluster
.
kubeclient
&
.
get_cluster_role_binding
(
Clusters
::
Kubernetes
::
GITLAB_KNATIVE_VERSION_ROLE_BINDING_NAME
)
res
cue
Kubeclient
::
ResourceNotFoundError
nil
end
end
end
app/finders/deployments_finder.rb
View file @
dadfab0c
...
...
@@ -22,4 +22,5 @@
private
# rubocop: disable CodeReuse/ActiveRecord
def
init_collection
...
...
@@ -25,3 +26,20 @@
def
init_collection
project
.
deployments
project
.
deployments
.
includes
(
:user
,
environment:
[],
deployable:
{
job_artifacts:
[],
pipeline:
{
project:
{
route:
[],
namespace: :route
}
},
project:
{
namespace: :route
}
}
)
end
...
...
@@ -27,4 +45,5 @@
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
sort
(
items
)
...
...
@@ -43,6 +62,9 @@
order_by
=
ALLOWED_SORT_VALUES
.
include?
(
params
[
:order_by
])
?
params
[
:order_by
]
:
DEFAULT_SORT_VALUE
order_direction
=
ALLOWED_SORT_DIRECTIONS
.
include?
(
params
[
:sort
])
?
params
[
:sort
]
:
DEFAULT_SORT_DIRECTION
{
order_by
=>
order_direction
}
{
order_by
=>
order_direction
}.
tap
do
|
sort_values
|
sort_values
[
'id'
]
=
'desc'
if
sort_values
[
'updated_at'
]
sort_values
[
'id'
]
=
sort_values
.
delete
(
'created_at'
)
if
sort_values
[
'created_at'
]
# Sorting by `id` produces the same result as sorting by `created_at`
end
end
end
app/models/clusters/applications/prometheus.rb
View file @
dadfab0c
...
...
@@ -84,10 +84,10 @@
# ensures headers containing auth data are appended to original k8s client options
options
=
kube_client
.
rest_client
.
options
.
merge
(
headers:
kube_client
.
headers
)
Gitlab
::
PrometheusClient
.
new
(
proxy_url
,
options
)
rescue
Kubeclient
::
HttpError
rescue
Kubeclient
::
HttpError
,
Errno
::
ECONNRESET
,
Errno
::
ECONNREFUSED
# If users have mistakenly set parameters or removed the depended clusters,
# `proxy_url` could raise an exception because gitlab can not communicate with the cluster.
# Since `PrometheusAdapter#can_query?` is eargely loaded on environement pages in gitlab,
# we need to silence the exceptions
end
...
...
@@ -88,9 +88,13 @@
# If users have mistakenly set parameters or removed the depended clusters,
# `proxy_url` could raise an exception because gitlab can not communicate with the cluster.
# Since `PrometheusAdapter#can_query?` is eargely loaded on environement pages in gitlab,
# we need to silence the exceptions
end
def
configured?
kube_client
.
present?
&&
available?
end
private
def
disable_prometheus_integration
...
...
app/models/concerns/prometheus_adapter.rb
View file @
dadfab0c
...
...
@@ -16,6 +16,14 @@
raise
NotImplementedError
end
# This is a light-weight check if a prometheus client is properly configured.
def
configured?
raise
NotImplemented
end
# This is a heavy-weight check if a prometheus is properly configured and accesible from GitLab.
# This actually sends a request to an external service and often it could take a long time,
# Please consider using `configured?` instead if the process is running on unicorn/puma threads.
def
can_query?
prometheus_client
.
present?
end
...
...
app/models/environment.rb
View file @
dadfab0c
...
...
@@ -193,7 +193,7 @@
end
def
has_metrics?
available?
&&
prometheus_adapter
&
.
c
an_query
?
available?
&&
prometheus_adapter
&
.
c
onfigured
?
end
def
metrics
...
...
@@ -197,7 +197,7 @@
end
def
metrics
prometheus_adapter
.
query
(
:environment
,
self
)
if
has_metrics?
prometheus_adapter
.
query
(
:environment
,
self
)
if
has_metrics?
&&
prometheus_adapter
.
can_query?
end
def
prometheus_status
...
...
app/models/project.rb
View file @
dadfab0c
...
...
@@ -374,9 +374,17 @@
scope
:pending_delete
,
->
{
where
(
pending_delete:
true
)
}
scope
:without_deleted
,
->
{
where
(
pending_delete:
false
)
}
scope
:with_storage_feature
,
->
(
feature
)
{
where
(
'storage_version >= :version'
,
version:
HASHED_STORAGE_FEATURES
[
feature
])
}
scope
:without_storage_feature
,
->
(
feature
)
{
where
(
'storage_version < :version OR storage_version IS NULL'
,
version:
HASHED_STORAGE_FEATURES
[
feature
])
}
scope
:with_unmigrated_storage
,
->
{
where
(
'storage_version < :version OR storage_version IS NULL'
,
version:
LATEST_STORAGE_VERSION
)
}
scope
:with_storage_feature
,
->
(
feature
)
do
where
(
arel_table
[
:storage_version
].
gteq
(
HASHED_STORAGE_FEATURES
[
feature
]))
end
scope
:without_storage_feature
,
->
(
feature
)
do
where
(
arel_table
[
:storage_version
].
lt
(
HASHED_STORAGE_FEATURES
[
feature
])
.
or
(
arel_table
[
:storage_version
].
eq
(
nil
)))
end
scope
:with_unmigrated_storage
,
->
do
where
(
arel_table
[
:storage_version
].
lt
(
LATEST_STORAGE_VERSION
)
.
or
(
arel_table
[
:storage_version
].
eq
(
nil
)))
end
# last_activity_at is throttled every minute, but last_repository_updated_at is updated with every push
scope
:sorted_by_activity
,
->
{
reorder
(
Arel
.
sql
(
"GREATEST(COALESCE(last_activity_at, '1970-01-01'), COALESCE(last_repository_updated_at, '1970-01-01')) DESC"
))
}
...
...
app/models/project_services/prometheus_service.rb
View file @
dadfab0c
...
...
@@ -95,6 +95,10 @@
self_monitoring_project?
&&
internal_prometheus_url?
end
def
configured?
should_return_client?
end
private
def
self_monitoring_project?
...
...
app/models/upload.rb
View file @
dadfab0c
...
...
@@ -23,6 +23,21 @@
after_destroy
:delete_file!
,
if:
->
{
uploader_class
<=
FileUploader
}
class
<<
self
def
inner_join_local_uploads_projects
upload_table
=
Upload
.
arel_table
project_table
=
Project
.
arel_table
join_statement
=
upload_table
.
project
(
upload_table
[
Arel
.
star
])
.
join
(
project_table
)
.
on
(
upload_table
[
:model_type
].
eq
(
'Project'
)
.
and
(
upload_table
[
:model_id
].
eq
(
project_table
[
:id
]))
.
and
(
upload_table
[
:store
].
eq
(
ObjectStorage
::
Store
::
LOCAL
))
)
joins
(
join_statement
.
join_sources
)
end
##
# FastDestroyAll concerns
def
begin_fast_destroy
...
...
app/services/clusters/kubernetes/create_or_update_service_account_service.rb
View file @
dadfab0c
...
...
@@ -71,9 +71,9 @@
end
def
knative_serving_namespace
kubeclient
.
core_client
.
get_namespace
s
.
find
do
|
namespace
|
namespace
.
metadata
.
name
==
Clusters
::
Kubernetes
::
KNATIVE_SERVING_NAMESPACE
end
kubeclient
.
get_namespace
(
Clusters
::
Kubernetes
::
KNATIVE_SERVING_NAMESPACE
)
rescue
Kubeclient
::
ResourceNotFoundError
nil
end
def
create_role_or_cluster_role_binding
...
...
app/views/snippets/show.html.haml
View file @
dadfab0c
...
...
@@ -4,5 +4,8 @@
-
breadcrumb_title
@snippet
.
to_reference
-
page_title
"
#{
@snippet
.
title
}
(
#{
@snippet
.
to_reference
}
)"
,
_
(
"Snippets"
)
=
render
'shared/snippets/header'
-
if
Feature
.
enabled?
(
:snippets_vue
)
#js-snippet-view
{
'data-qa-selector'
:
'snippet_view'
}
-
else
=
render
'shared/snippets/header'
...
...
@@ -8,5 +11,5 @@
.personal-snippets
%article
.file-holder.snippet-file-content
=
render
'shared/snippets/blob'
.personal-snippets
%article
.file-holder.snippet-file-content
=
render
'shared/snippets/blob'
...
...
@@ -12,4 +15,4 @@
.row-content-block.top-block.content-component-block
=
render
'award_emoji/awards_block'
,
awardable:
@snippet
,
inline:
true
.row-content-block.top-block.content-component-block
=
render
'award_emoji/awards_block'
,
awardable:
@snippet
,
inline:
true
...
...
@@ -15,2 +18,2 @@
#notes
.limited-width-notes
=
render
"shared/notes/notes_with_form"
,
:autocomplete
=>
false
#notes
.limited-width-notes
=
render
"shared/notes/notes_with_form"
,
:autocomplete
=>
false
app/workers/hashed_storage/project_migrate_worker.rb
View file @
dadfab0c
...
...
@@ -14,7 +14,7 @@
try_obtain_lease
do
project
=
Project
.
without_deleted
.
find_by
(
id:
project_id
)
break
unless
project
break
unless
project
&&
project
.
storage_upgradable?
old_disk_path
||=
Storage
::
LegacyProject
.
new
(
project
).
disk_path
...
...
changelogs/unreleased/28075-error-while-fetching-envs.yml
0 → 100644
View file @
dadfab0c
---
title
:
Added lightweight check when retrieving Prometheus metrics.
merge_request
:
21099
author
:
type
:
performance
changelogs/unreleased/35789-hashed-storage-attachments-migration-object-storage.yml
0 → 100644
View file @
dadfab0c
---
title
:
'
Hashed
Storage
attachments
migration:
exclude
files
in
object
storage
as
they
are
all
hashed
already'
merge_request
:
20338
author
:
type
:
changed
changelogs/unreleased/36301-add-tie-breaker-id-sorting-to-deployments.yml
0 → 100644
View file @
dadfab0c
---
title
:
Optimize Deployments endpoint by preloading associations and make record ordering more consistent
merge_request
:
20848
author
:
type
:
changed
db/migrate/20191204070713_change_updated_at_index_and_add_index_to_id_on_deployments.rb
0 → 100644
View file @
dadfab0c
# frozen_string_literal: true
class
ChangeUpdatedAtIndexAndAddIndexToIdOnDeployments
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
DOWNTIME
=
false
PROJECT_ID_INDEX_PARAMS
=
[[
:project_id
,
:id
],
order:
{
id: :desc
}]
OLD_UPDATED_AT_INDEX_PARAMS
=
[[
:project_id
,
:updated_at
]]
NEW_UPDATED_AT_INDEX_PARAMS
=
[[
:project_id
,
:updated_at
,
:id
],
order:
{
updated_at: :desc
,
id: :desc
}]
def
up
add_concurrent_index
:deployments
,
*
NEW_UPDATED_AT_INDEX_PARAMS
remove_concurrent_index
:deployments
,
*
OLD_UPDATED_AT_INDEX_PARAMS
add_concurrent_index
:deployments
,
*
PROJECT_ID_INDEX_PARAMS
end
def
down
add_concurrent_index
:deployments
,
*
OLD_UPDATED_AT_INDEX_PARAMS
remove_concurrent_index
:deployments
,
*
NEW_UPDATED_AT_INDEX_PARAMS
remove_concurrent_index
:deployments
,
*
PROJECT_ID_INDEX_PARAMS
end
end
db/schema.rb
View file @
dadfab0c
...
...
@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
2019_12_0
2
_0
31812
)
do
ActiveRecord
::
Schema
.
define
(
version:
2019_12_0
4
_0
70713
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"pg_trgm"
...
...
@@ -1339,6 +1339,7 @@
t
.
index
[
"environment_id"
,
"iid"
,
"project_id"
],
name:
"index_deployments_on_environment_id_and_iid_and_project_id"
t
.
index
[
"environment_id"
,
"status"
],
name:
"index_deployments_on_environment_id_and_status"
t
.
index
[
"id"
],
name:
"partial_index_deployments_for_legacy_successful_deployments"
,
where:
"((finished_at IS NULL) AND (status = 2))"
t
.
index
[
"project_id"
,
"id"
],
name:
"index_deployments_on_project_id_and_id"
,
order:
{
id: :desc
}
t
.
index
[
"project_id"
,
"iid"
],
name:
"index_deployments_on_project_id_and_iid"
,
unique:
true
t
.
index
[
"project_id"
,
"status"
,
"created_at"
],
name:
"index_deployments_on_project_id_and_status_and_created_at"
t
.
index
[
"project_id"
,
"status"
],
name:
"index_deployments_on_project_id_and_status"
...
...
@@ -1342,7 +1343,7 @@
t
.
index
[
"project_id"
,
"iid"
],
name:
"index_deployments_on_project_id_and_iid"
,
unique:
true
t
.
index
[
"project_id"
,
"status"
,
"created_at"
],
name:
"index_deployments_on_project_id_and_status_and_created_at"
t
.
index
[
"project_id"
,
"status"
],
name:
"index_deployments_on_project_id_and_status"
t
.
index
[
"project_id"
,
"updated_at"
],
name:
"index_deployments_on_project_id_and_updated_at
"
t
.
index
[
"project_id"
,
"updated_at"
,
"id"
],
name:
"index_deployments_on_project_id_and_updated_at
_and_id"
,
order:
{
updated_at: :desc
,
id: :desc
}
end
create_table
"description_versions"
,
force: :cascade
do
|
t
|
...
...
lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb
View file @
dadfab0c
...
...
@@ -8,7 +8,7 @@
def
unmet?
deployment_cluster
.
present?
&&
deployment_cluster
.
managed?
&&
(
missing_namespace?
||
missing
_knative_version_role_binding?
)
(
missing_namespace?
||
need
_knative_version_role_binding?
)
end
def
complete!
...
...
@@ -23,8 +23,8 @@
kubernetes_namespace
.
nil?
||
kubernetes_namespace
.
service_account_token
.
blank?
end
def
missing
_knative_version_role_binding?
knative_version_role_binding
.
nil?
def
need
_knative_version_role_binding?
!
knative_serving_namespace
.
nil?
&&
knative_version_role_binding
.
nil?
end
def
deployment_cluster
...
...
@@ -35,6 +35,14 @@
build
.
deployment
.
environment
end
def
knative_serving_namespace
strong_memoize
(
:knative_serving_namespace
)
do
Clusters
::
KnativeServingNamespaceFinder
.
new
(
deployment_cluster
).
execute
end
end
def
knative_version_role_binding
strong_memoize
(
:knative_version_role_binding
)
do
Clusters
::
KnativeVersionRoleBindingFinder
.
new
(
...
...
lib/gitlab/gon_helper.rb
View file @
dadfab0c
...
...
@@ -42,6 +42,7 @@
# Initialize gon.features with any flags that should be
# made globally available to the frontend
push_frontend_feature_flag
(
:suppress_ajax_navigation_errors
,
default_enabled:
true
)
push_frontend_feature_flag
(
:snippets_vue
,
default_enabled:
false
)
end
# Exposes the state of a feature flag to the frontend code.
...
...
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