Commit c2932d40 authored by GitLab Bot's avatar GitLab Bot

Automatic merge of gitlab-org/gitlab-ce master

parents cf6afd09 112741ef
...@@ -747,7 +747,7 @@ static-analysis: ...@@ -747,7 +747,7 @@ static-analysis:
- tmp/rubocop_cache - tmp/rubocop_cache
# Documentation checks: # Documentation checks:
# - Check validity of relative links # - Check validity of relative links, and anchors
# - Make sure cURL examples in API docs use the full switches # - Make sure cURL examples in API docs use the full switches
docs lint: docs lint:
<<: *dedicated-runner <<: *dedicated-runner
...@@ -768,6 +768,8 @@ docs lint: ...@@ -768,6 +768,8 @@ docs lint:
- bundle exec nanoc - bundle exec nanoc
# Check the internal links # Check the internal links
- bundle exec nanoc check internal_links - bundle exec nanoc check internal_links
# Check the internal anchor links
- bundle exec nanoc check internal_anchors
downtime_check: downtime_check:
<<: *rake-exec <<: *rake-exec
......
...@@ -16,6 +16,7 @@ module Clusters ...@@ -16,6 +16,7 @@ module Clusters
error_code: error.respond_to?(:error_code) ? error.error_code : nil, error_code: error.respond_to?(:error_code) ? error.error_code : nil,
service: self.class.name, service: self.class.name,
app_id: app.id, app_id: app.id,
app_name: app.name,
project_ids: app.cluster.project_ids, project_ids: app.cluster.project_ids,
group_ids: app.cluster.group_ids group_ids: app.cluster.group_ids
} }
...@@ -30,6 +31,19 @@ module Clusters ...@@ -30,6 +31,19 @@ module Clusters
Gitlab::Sentry.track_acceptable_exception(error, extra: meta) Gitlab::Sentry.track_acceptable_exception(error, extra: meta)
end end
def log_event(event)
meta = {
service: self.class.name,
app_id: app.id,
app_name: app.name,
project_ids: app.cluster.project_ids,
group_ids: app.cluster.group_ids,
event: event
}
logger.info(meta)
end
def logger def logger
@logger ||= Gitlab::Kubernetes::Logger.build @logger ||= Gitlab::Kubernetes::Logger.build
end end
......
...@@ -7,8 +7,10 @@ module Clusters ...@@ -7,8 +7,10 @@ module Clusters
return unless app.scheduled? return unless app.scheduled?
app.make_installing! app.make_installing!
log_event(:begin_install)
helm_api.install(install_command) helm_api.install(install_command)
log_event(:schedule_wait_for_installation)
ClusterWaitForAppInstallationWorker.perform_in( ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id) ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e rescue Kubeclient::HttpError => e
......
...@@ -8,8 +8,10 @@ module Clusters ...@@ -8,8 +8,10 @@ module Clusters
app.make_updating! app.make_updating!
log_event(:begin_patch)
helm_api.update(update_command) helm_api.update(update_command)
log_event(:schedule_wait_for_patch)
ClusterWaitForAppInstallationWorker.perform_in( ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id) ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e rescue Kubeclient::HttpError => e
......
...@@ -9,10 +9,12 @@ module Clusters ...@@ -9,10 +9,12 @@ module Clusters
begin begin
app.make_updating! app.make_updating!
log_event(:begin_upgrade)
# install_command works with upgrades too # install_command works with upgrades too
# as it basically does `helm upgrade --install` # as it basically does `helm upgrade --install`
helm_api.update(install_command) helm_api.update(install_command)
log_event(:schedule_wait_for_upgrade)
ClusterWaitForAppInstallationWorker.perform_in( ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id) ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e rescue Kubeclient::HttpError => e
......
...@@ -11,7 +11,7 @@ One of the things it uses these credentials for is providing access to ...@@ -11,7 +11,7 @@ One of the things it uses these credentials for is providing access to
## How it works ## How it works
A detailed overview of the architecture of web terminals and how they work A detailed overview of the architecture of web terminals and how they work
can be found in [this document](https://gitlab.com/gitlab-org/gitlab-workhorse/blob/master/doc/terminal.md). can be found in [this document](https://gitlab.com/gitlab-org/gitlab-workhorse/blob/master/doc/channel.md).
In brief: In brief:
- GitLab relies on the user to provide their own Kubernetes credentials, and to - GitLab relies on the user to provide their own Kubernetes credentials, and to
......
...@@ -11,7 +11,7 @@ last_updated: 2019-03-06 ...@@ -11,7 +11,7 @@ last_updated: 2019-03-06
[Phoenix][phoenix-site] is a web development framework written in [Elixir][elixir-site], which is a [Phoenix][phoenix-site] is a web development framework written in [Elixir][elixir-site], which is a
functional language designed for productivity and maintainability that runs on the functional language designed for productivity and maintainability that runs on the
[Erlang VM][erlang-site]. Erlang VM is really really fast and can handle very large numbers of [Erlang VM](https://www.erlang.org). Erlang VM is really really fast and can handle very large numbers of
simultaneous users. simultaneous users.
That's why we're hearing so much about Phoenix today. That's why we're hearing so much about Phoenix today.
...@@ -27,7 +27,7 @@ and GitLab UI._ ...@@ -27,7 +27,7 @@ and GitLab UI._
### What is Phoenix? ### What is Phoenix?
[Phoenix][phoenix-site] is a web development framework written in [Elixir][elixir-site] very useful [Phoenix][phoenix-site] is a web development framework written in [Elixir][elixir-site] very useful
to build fast, reliable, and high-performance applications, as it uses [Erlang VM][erlang-site]. to build fast, reliable, and high-performance applications, as it uses [Erlang VM](https://www.erlang.org).
Many components and concepts are similar to Ruby on Rails or Python's Django. High developer Many components and concepts are similar to Ruby on Rails or Python's Django. High developer
productivity and high application performance are only a few advantages on learning how to use it. productivity and high application performance are only a few advantages on learning how to use it.
...@@ -406,7 +406,6 @@ other reasons][ci-reasons] to keep using GitLab CI/CD. The benefits to our teams ...@@ -406,7 +406,6 @@ other reasons][ci-reasons] to keep using GitLab CI/CD. The benefits to our teams
[elixir-site]: http://elixir-lang.org/ "Elixir" [elixir-site]: http://elixir-lang.org/ "Elixir"
[elixir-mix]: http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html "Introduction to mix" [elixir-mix]: http://elixir-lang.org/getting-started/mix-otp/introduction-to-mix.html "Introduction to mix"
[elixir-docs]: http://elixir-lang.org/getting-started/introduction.html "Elixir Documentation" [elixir-docs]: http://elixir-lang.org/getting-started/introduction.html "Elixir Documentation"
[erlang-site]: http://erlang.org "Erlang"
[elixir-install]: https://elixir-lang.org/install.html "Elixir Installation" [elixir-install]: https://elixir-lang.org/install.html "Elixir Installation"
[ecto]: http://hexdocs.pm/ecto "Ecto" [ecto]: http://hexdocs.pm/ecto "Ecto"
[ecto-repo]: https://hexdocs.pm/ecto/Ecto.html#module-repositories "Ecto Repositories" [ecto-repo]: https://hexdocs.pm/ecto/Ecto.html#module-repositories "Ecto Repositories"
......
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
Thank you for your interest in contributing to GitLab. This guide details how Thank you for your interest in contributing to GitLab. This guide details how
to contribute to GitLab in a way that is easy for everyone. to contribute to GitLab in a way that is easy for everyone.
We want to create a welcoming environment for everyone who is interested in contributing.
Please visit our [Code of Conduct page](https://about.gitlab.com/contributing/code-of-conduct) to learn more about our commitment to an open and welcoming environment.
For a first-time step-by-step guide to the contribution process, please see For a first-time step-by-step guide to the contribution process, please see
["Contributing to GitLab"](https://about.gitlab.com/contributing/). ["Contributing to GitLab"](https://about.gitlab.com/contributing/).
...@@ -33,8 +30,8 @@ vulnerabilities. ...@@ -33,8 +30,8 @@ vulnerabilities.
## Code of conduct ## Code of conduct
Our code of conduct can be found on the We want to create a welcoming environment for everyone who is interested in contributing.
["Contributing to GitLab"](https://about.gitlab.com/contributing/) page. Please visit our [Code of Conduct page](https://about.gitlab.com/community/contribute/code-of-conduct/) to learn more about our commitment to an open and welcoming environment.
## Closing policy for issues and merge requests ## Closing policy for issues and merge requests
......
...@@ -573,7 +573,7 @@ However, sometimes GitLab can not create them. In such instances, your job will ...@@ -573,7 +573,7 @@ However, sometimes GitLab can not create them. In such instances, your job will
This job failed because the necessary resources were not successfully created. This job failed because the necessary resources were not successfully created.
``` ```
To find the cause of this error when creating a namespace and service account, check the [logs](../../../administration/logs.md#sidekiqlog). To find the cause of this error when creating a namespace and service account, check the [logs](../../../administration/logs.md#kuberneteslog).
Common reasons for failure include: Common reasons for failure include:
......
...@@ -19,11 +19,40 @@ module Gitlab ...@@ -19,11 +19,40 @@ module Gitlab
def create! def create!
resource = ::Kubeclient::Resource.new(metadata: { name: name }) resource = ::Kubeclient::Resource.new(metadata: { name: name })
log_event(:begin_create)
@client.create_namespace(resource) @client.create_namespace(resource)
end end
def ensure_exists! def ensure_exists!
exists? || create! exists? || create!
rescue ::Kubeclient::HttpError => error
log_create_failed(error)
raise
end
private
def log_create_failed(error)
logger.error({
exception: error.class.name,
status_code: error.error_code,
namespace: name,
class_name: self.class.name,
event: :failed_to_create_namespace,
message: error.message
})
end
def log_event(event)
logger.info(
namespace: name,
class_name: self.class.name,
event: event
)
end
def logger
@logger ||= Gitlab::Kubernetes::Logger.build
end end
end end
end end
......
...@@ -62,5 +62,32 @@ describe Gitlab::Kubernetes::Namespace do ...@@ -62,5 +62,32 @@ describe Gitlab::Kubernetes::Namespace do
subject.ensure_exists! subject.ensure_exists!
end end
context 'when client errors' do
let(:exception) { Kubeclient::HttpError.new(500, 'system failure', nil) }
before do
allow(client).to receive(:get_namespace).with(name).once.and_raise(exception)
end
it 'raises the exception' do
expect { subject.ensure_exists! }.to raise_error(exception)
end
it 'logs the error' do
expect(subject.send(:logger)).to receive(:error).with(
hash_including(
exception: 'Kubeclient::HttpError',
status_code: 500,
namespace: 'a_namespace',
class_name: 'Gitlab::Kubernetes::Namespace',
event: :failed_to_create_namespace,
message: 'system failure'
)
)
expect { subject.ensure_exists! }.to raise_error(exception)
end
end
end end
end end
...@@ -20,7 +20,7 @@ shared_examples 'logs kubernetes errors' do ...@@ -20,7 +20,7 @@ shared_examples 'logs kubernetes errors' do
end end
it 'logs into kubernetes.log and Sentry' do it 'logs into kubernetes.log and Sentry' do
expect(service.send(:logger)).to receive(:error).with(logger_hash) expect(service.send(:logger)).to receive(:error).with(hash_including(logger_hash))
expect(Gitlab::Sentry).to receive(:track_acceptable_exception).with( expect(Gitlab::Sentry).to receive(:track_acceptable_exception).with(
error, error,
......
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