Commit 0752354f authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent ae2aaa682e06
...@@ -449,7 +449,7 @@ group :ed25519 do ...@@ -449,7 +449,7 @@ group :ed25519 do
end end
# Gitaly GRPC protocol definitions # Gitaly GRPC protocol definitions
gem 'gitaly', '~> 1.65.0' gem 'gitaly', '~> 1.70.0'
gem 'grpc', '~> 1.24.0' gem 'grpc', '~> 1.24.0'
......
...@@ -358,7 +358,7 @@ GEM ...@@ -358,7 +358,7 @@ GEM
po_to_json (>= 1.0.0) po_to_json (>= 1.0.0)
rails (>= 3.2.0) rails (>= 3.2.0)
git (1.5.0) git (1.5.0)
gitaly (1.65.0) gitaly (1.70.0)
grpc (~> 1.0) grpc (~> 1.0)
github-markup (1.7.0) github-markup (1.7.0)
gitlab-labkit (0.7.0) gitlab-labkit (0.7.0)
...@@ -1167,7 +1167,7 @@ DEPENDENCIES ...@@ -1167,7 +1167,7 @@ DEPENDENCIES
gettext (~> 3.2.2) gettext (~> 3.2.2)
gettext_i18n_rails (~> 1.8.0) gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3) gettext_i18n_rails_js (~> 1.3)
gitaly (~> 1.65.0) gitaly (~> 1.70.0)
github-markup (~> 1.7.0) github-markup (~> 1.7.0)
gitlab-labkit (~> 0.5) gitlab-labkit (~> 0.5)
gitlab-license (~> 1.0) gitlab-license (~> 1.0)
......
...@@ -301,6 +301,7 @@ export default { ...@@ -301,6 +301,7 @@ export default {
v-if="showContentViewer" v-if="showContentViewer"
:content="file.content || file.raw" :content="file.content || file.raw"
:path="file.rawPath || file.path" :path="file.rawPath || file.path"
:file-path="file.path"
:file-size="file.size" :file-size="file.size"
:project-path="file.projectId" :project-path="file.projectId"
:type="fileType" :type="fileType"
......
...@@ -18,6 +18,11 @@ export default { ...@@ -18,6 +18,11 @@ export default {
required: false, required: false,
default: 0, default: 0,
}, },
filePath: {
type: String,
required: false,
default: '',
},
projectPath: { projectPath: {
type: String, type: String,
required: false, required: false,
...@@ -52,6 +57,7 @@ export default { ...@@ -52,6 +57,7 @@ export default {
<component <component
:is="viewer" :is="viewer"
:path="path" :path="path"
:file-path="filePath"
:file-size="fileSize" :file-size="fileSize"
:project-path="projectPath" :project-path="projectPath"
:content="content" :content="content"
......
...@@ -16,6 +16,11 @@ export default { ...@@ -16,6 +16,11 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
filePath: {
type: String,
required: false,
default: '',
},
projectPath: { projectPath: {
type: String, type: String,
required: true, required: true,
...@@ -48,6 +53,7 @@ export default { ...@@ -48,6 +53,7 @@ export default {
this.isLoading = true; this.isLoading = true;
const postBody = { const postBody = {
text: this.content, text: this.content,
path: this.filePath,
}; };
const postOptions = { const postOptions = {
cancelToken: axiosSource.token, cancelToken: axiosSource.token,
......
...@@ -7,17 +7,8 @@ module PreviewMarkdown ...@@ -7,17 +7,8 @@ module PreviewMarkdown
def preview_markdown def preview_markdown
result = PreviewMarkdownService.new(@project, current_user, markdown_service_params).execute result = PreviewMarkdownService.new(@project, current_user, markdown_service_params).execute
markdown_params =
case controller_name
when 'wikis' then { pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id] }
when 'snippets' then { skip_project_check: true }
when 'groups' then { group: group }
when 'projects' then projects_filter_params
else {}
end
render json: { render json: {
body: view_context.markdown(result[:text], markdown_params), body: view_context.markdown(result[:text], markdown_context_params),
references: { references: {
users: result[:users], users: result[:users],
suggestions: SuggestionSerializer.new.represent_diff(result[:suggestions]), suggestions: SuggestionSerializer.new.represent_diff(result[:suggestions]),
...@@ -38,5 +29,16 @@ def projects_filter_params ...@@ -38,5 +29,16 @@ def projects_filter_params
def markdown_service_params def markdown_service_params
params params
end end
def markdown_context_params
case controller_name
when 'wikis' then { pipeline: :wiki, project_wiki: @project_wiki, page_slug: params[:id] }
when 'snippets' then { skip_project_check: true }
when 'groups' then { group: group }
when 'projects' then projects_filter_params
else {}
end.merge(requested_path: params[:path])
end
# rubocop:enable Gitlab/ModuleWithInstanceVariables # rubocop:enable Gitlab/ModuleWithInstanceVariables
end end
...@@ -5,12 +5,15 @@ module Applications ...@@ -5,12 +5,15 @@ module Applications
class ElasticStack < ApplicationRecord class ElasticStack < ApplicationRecord
VERSION = '1.8.0' VERSION = '1.8.0'
ELASTICSEARCH_PORT = 9200
self.table_name = 'clusters_applications_elastic_stacks' self.table_name = 'clusters_applications_elastic_stacks'
include ::Clusters::Concerns::ApplicationCore include ::Clusters::Concerns::ApplicationCore
include ::Clusters::Concerns::ApplicationStatus include ::Clusters::Concerns::ApplicationStatus
include ::Clusters::Concerns::ApplicationVersion include ::Clusters::Concerns::ApplicationVersion
include ::Clusters::Concerns::ApplicationData include ::Clusters::Concerns::ApplicationData
include ::Gitlab::Utils::StrongMemoize
default_value_for :version, VERSION default_value_for :version, VERSION
...@@ -49,6 +52,28 @@ def uninstall_command ...@@ -49,6 +52,28 @@ def uninstall_command
) )
end end
def elasticsearch_client
strong_memoize(:elasticsearch_client) do
next unless kube_client
proxy_url = kube_client.proxy_url('service', 'elastic-stack-elasticsearch-client', ::Clusters::Applications::ElasticStack::ELASTICSEARCH_PORT, Gitlab::Kubernetes::Helm::NAMESPACE)
Elasticsearch::Client.new(url: proxy_url) do |faraday|
# ensures headers containing auth data are appended to original client options
faraday.headers.merge!(kube_client.headers)
# ensure TLS certs are properly verified
faraday.ssl[:verify] = kube_client.ssl_options[:verify_ssl]
faraday.ssl[:cert_store] = kube_client.ssl_options[:cert_store]
end
rescue Kubeclient::HttpError => error
# 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.
# We check for a nil client in downstream use and behaviour is equivalent to an empty state
log_exception(error, :failed_to_create_elasticsearch_client)
end
end
private private
def specification def specification
...@@ -74,6 +99,10 @@ def post_delete_script ...@@ -74,6 +99,10 @@ def post_delete_script
Gitlab::Kubernetes::KubectlCmd.delete("pvc", "--selector", "release=elastic-stack") Gitlab::Kubernetes::KubectlCmd.delete("pvc", "--selector", "release=elastic-stack")
].compact ].compact
end end
def kube_client
cluster&.kubeclient&.core_client
end
end end
end end
end end
...@@ -60,6 +60,24 @@ def post_uninstall ...@@ -60,6 +60,24 @@ def post_uninstall
# Override if your application needs any action after # Override if your application needs any action after
# being uninstalled by Helm # being uninstalled by Helm
end end
def logger
@logger ||= Gitlab::Kubernetes::Logger.build
end
def log_exception(error, event)
logger.error({
exception: error.class.name,
status_code: error.error_code,
cluster_id: cluster&.id,
application_id: id,
class_name: self.class.name,
event: event,
message: error.message
})
Gitlab::Sentry.track_acceptable_exception(error, extra: { cluster_id: cluster&.id, application_id: id })
end
end end
end end
end end
......
...@@ -12,7 +12,7 @@ class Environment < ApplicationRecord ...@@ -12,7 +12,7 @@ class Environment < ApplicationRecord
has_one :last_deployment, -> { success.order('deployments.id DESC') }, class_name: 'Deployment' has_one :last_deployment, -> { success.order('deployments.id DESC') }, class_name: 'Deployment'
has_one :last_deployable, through: :last_deployment, source: 'deployable', source_type: 'CommitStatus' has_one :last_deployable, through: :last_deployment, source: 'deployable', source_type: 'CommitStatus'
has_one :last_pipeline, through: :last_deployable, source: 'pipeline' has_one :last_pipeline, through: :last_deployable, source: 'pipeline'
has_one :last_visible_deployment, -> { visible.distinct_on_environment }, class_name: 'Deployment' has_one :last_visible_deployment, -> { visible.distinct_on_environment }, inverse_of: :environment, class_name: 'Deployment'
has_one :last_visible_deployable, through: :last_visible_deployment, source: 'deployable', source_type: 'CommitStatus' has_one :last_visible_deployable, through: :last_visible_deployment, source: 'deployable', source_type: 'CommitStatus'
has_one :last_visible_pipeline, through: :last_visible_deployable, source: 'pipeline' has_one :last_visible_pipeline, through: :last_visible_deployable, source: 'pipeline'
...@@ -66,6 +66,9 @@ class Environment < ApplicationRecord ...@@ -66,6 +66,9 @@ class Environment < ApplicationRecord
scope :for_project, -> (project) { where(project_id: project) } scope :for_project, -> (project) { where(project_id: project) }
scope :with_deployment, -> (sha) { where('EXISTS (?)', Deployment.select(1).where('deployments.environment_id = environments.id').where(sha: sha)) } scope :with_deployment, -> (sha) { where('EXISTS (?)', Deployment.select(1).where('deployments.environment_id = environments.id').where(sha: sha)) }
scope :unfoldered, -> { where(environment_type: nil) } scope :unfoldered, -> { where(environment_type: nil) }
scope :with_rank, -> do
select('environments.*, rank() OVER (PARTITION BY project_id ORDER BY id DESC)')
end
state_machine :state, initial: :available do state_machine :state, initial: :available do
event :start do event :start do
......
...@@ -287,7 +287,7 @@ class Project < ApplicationRecord ...@@ -287,7 +287,7 @@ class Project < ApplicationRecord
has_many :variables, class_name: 'Ci::Variable' has_many :variables, class_name: 'Ci::Variable'
has_many :triggers, class_name: 'Ci::Trigger' has_many :triggers, class_name: 'Ci::Trigger'
has_many :environments has_many :environments
has_many :unfoldered_environments, -> { unfoldered.available }, class_name: 'Environment' has_many :environments_for_dashboard, -> { from(with_rank.unfoldered.available, :environments).where('rank <= 3') }, class_name: 'Environment'
has_many :deployments has_many :deployments
has_many :pipeline_schedules, class_name: 'Ci::PipelineSchedule' has_many :pipeline_schedules, class_name: 'Ci::PipelineSchedule'
has_many :project_deploy_tokens has_many :project_deploy_tokens
......
...@@ -50,16 +50,24 @@ def visibility_level ...@@ -50,16 +50,24 @@ def visibility_level
private private
def error(message, http_status = nil) # Return a Hash with an `error` status
#
# message - Error message to include in the Hash
# http_status - Optional HTTP status code override (default: nil)
# pass_back - Additional attributes to be included in the resulting Hash
def error(message, http_status = nil, pass_back: {})
result = { result = {
message: message, message: message,
status: :error status: :error
} }.reverse_merge(pass_back)
result[:http_status] = http_status if http_status result[:http_status] = http_status if http_status
result result
end end
# Return a Hash with a `success` status
#
# pass_back - Additional attributes to be included in the resulting Hash
def success(pass_back = {}) def success(pass_back = {})
pass_back[:status] = :success pass_back[:status] = :success
pass_back pass_back
......
...@@ -23,14 +23,15 @@ def commit_change(action) ...@@ -23,14 +23,15 @@ def commit_change(action)
message, message,
start_project: @start_project, start_project: @start_project,
start_branch_name: @start_branch) start_branch_name: @start_branch)
rescue Gitlab::Git::Repository::CreateTreeError rescue Gitlab::Git::Repository::CreateTreeError => ex
act = action.to_s.dasherize act = action.to_s.dasherize
type = @commit.change_type_title(current_user) type = @commit.change_type_title(current_user)
error_msg = "Sorry, we cannot #{act} this #{type} automatically. " \ error_msg = "Sorry, we cannot #{act} this #{type} automatically. " \
"This #{type} may already have been #{act}ed, or a more recent " \ "This #{type} may already have been #{act}ed, or a more recent " \
"commit may have updated some of its content." "commit may have updated some of its content."
raise ChangeError, error_msg
raise ChangeError.new(error_msg, ex.error_code)
end end
end end
end end
...@@ -3,7 +3,15 @@ ...@@ -3,7 +3,15 @@
module Commits module Commits
class CreateService < ::BaseService class CreateService < ::BaseService
ValidationError = Class.new(StandardError) ValidationError = Class.new(StandardError)
ChangeError = Class.new(StandardError) class ChangeError < StandardError
attr_reader :error_code
def initialize(message, error_code = nil)
super(message)
@error_code = error_code
end
end
def initialize(*args) def initialize(*args)
super super
...@@ -21,8 +29,9 @@ def execute ...@@ -21,8 +29,9 @@ def execute
new_commit = create_commit! new_commit = create_commit!
success(result: new_commit) success(result: new_commit)
rescue ChangeError => ex
error(ex.message, pass_back: { error_code: ex.error_code })
rescue ValidationError, rescue ValidationError,
ChangeError,
Gitlab::Git::Index::IndexError, Gitlab::Git::Index::IndexError,
Gitlab::Git::CommitError, Gitlab::Git::CommitError,
Gitlab::Git::PreReceiveError, Gitlab::Git::PreReceiveError,
......
---
title: Enable environments dashboard by default
merge_request: 19838
author:
type: added
---
title: Fix broken images when previewing markdown files in Web IDE
merge_request: 18899
author:
type: fixed
---
title: Increase PumaWorkerKiller memory limit in development environment
merge_request: 20039
author:
type: performance
---
title: Helm v2.16.1
merge_request: 19981
author:
type: fixed
---
title: 'Add an `error_code` attribute to the API response when a cherry-pick or revert fails.'
merge_request: 19518
author:
type: added
...@@ -317,6 +317,21 @@ Example response: ...@@ -317,6 +317,21 @@ Example response:
} }
``` ```
In the event of a failed cherry-pick, the response will provide context about
why:
```json
{
"message": "Sorry, we cannot cherry-pick this commit automatically. This commit may already have been cherry-picked, or a more recent commit may have updated some of its content.",
"error_code": "empty"
}
```
In this case, the cherry-pick failed because the changeset was empty and likely
indicates that the commit already exists in the target branch. The other
possible error code is `conflict`, which indicates that there was a merge
conflict.
## Revert a commit ## Revert a commit
> [Introduced][ce-22919] in GitLab 11.5. > [Introduced][ce-22919] in GitLab 11.5.
...@@ -358,6 +373,19 @@ Example response: ...@@ -358,6 +373,19 @@ Example response:
} }
``` ```
In the event of a failed revert, the response will provide context about why:
```json
{
"message": "Sorry, we cannot revert this commit automatically. This commit may already have been reverted, or a more recent commit may have updated some of its content.",
"error_code": "conflict"
}
```
In this case, the revert failed because the attempted revert generated a merge
conflict. The other possible error code is `empty`, which indicates that the
changeset was empty, likely due to the change having already been reverted.
## Get the diff of a commit ## Get the diff of a commit
Get the diff of a commit in a project. Get the diff of a commit in a project.
......
...@@ -32,10 +32,23 @@ Management projects are restricted to the following: ...@@ -32,10 +32,23 @@ Management projects are restricted to the following:
## Usage ## Usage
To use a cluster management project for a cluster:
1. Select the project.
1. Configure your pipelines.
1. Set an environment scope.
### Selecting a cluster management project ### Selecting a cluster management project
You can select a management project for the cluster under **Advanced To select a cluster management project to use:
settings**.
1. Navigate to the appropriate configuration page. For a:
- [Project-level cluster](../project/clusters/index.md), navigate to your project's
**Operations > Kubernetes** page.
- [Group-level cluster](../group/clusters/index.md), navigate to your group's **Kubernetes**
page.
1. Select the project using **Cluster management project field** in the **Advanced settings**
section.
![Selecting a cluster management project under Advanced settings](img/advanced-settings-cluster-management-project-v12_5.png) ![Selecting a cluster management project under Advanced settings](img/advanced-settings-cluster-management-project-v12_5.png)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment