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:
- tmp/rubocop_cache
# 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
docs lint:
<<: *dedicated-runner
......@@ -768,6 +768,8 @@ docs lint:
- bundle exec nanoc
# Check the internal links
- bundle exec nanoc check internal_links
# Check the internal anchor links
- bundle exec nanoc check internal_anchors
downtime_check:
<<: *rake-exec
......
......@@ -16,6 +16,7 @@ module Clusters
error_code: error.respond_to?(:error_code) ? error.error_code : nil,
service: self.class.name,
app_id: app.id,
app_name: app.name,
project_ids: app.cluster.project_ids,
group_ids: app.cluster.group_ids
}
......@@ -30,6 +31,19 @@ module Clusters
Gitlab::Sentry.track_acceptable_exception(error, extra: meta)
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
@logger ||= Gitlab::Kubernetes::Logger.build
end
......
......@@ -7,8 +7,10 @@ module Clusters
return unless app.scheduled?
app.make_installing!
log_event(:begin_install)
helm_api.install(install_command)
log_event(:schedule_wait_for_installation)
ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e
......
......@@ -8,8 +8,10 @@ module Clusters
app.make_updating!
log_event(:begin_patch)
helm_api.update(update_command)
log_event(:schedule_wait_for_patch)
ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e
......
......@@ -9,10 +9,12 @@ module Clusters
begin
app.make_updating!
log_event(:begin_upgrade)
# install_command works with upgrades too
# as it basically does `helm upgrade --install`
helm_api.update(install_command)
log_event(:schedule_wait_for_upgrade)
ClusterWaitForAppInstallationWorker.perform_in(
ClusterWaitForAppInstallationWorker::INTERVAL, app.name, app.id)
rescue Kubeclient::HttpError => e
......
......@@ -11,7 +11,7 @@ One of the things it uses these credentials for is providing access to
## How it works
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:
- GitLab relies on the user to provide their own Kubernetes credentials, and to
......
......@@ -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
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.
That's why we're hearing so much about Phoenix today.
......@@ -27,7 +27,7 @@ and GitLab UI._
### What is Phoenix?
[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
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
[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-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"
[ecto]: http://hexdocs.pm/ecto "Ecto"
[ecto-repo]: https://hexdocs.pm/ecto/Ecto.html#module-repositories "Ecto Repositories"
......
......@@ -3,9 +3,6 @@
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.
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
["Contributing to GitLab"](https://about.gitlab.com/contributing/).
......@@ -33,8 +30,8 @@ vulnerabilities.
## Code of conduct
Our code of conduct can be found on the
["Contributing to GitLab"](https://about.gitlab.com/contributing/) page.
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/community/contribute/code-of-conduct/) to learn more about our commitment to an open and welcoming environment.
## Closing policy for issues and merge requests
......
......@@ -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.
```
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:
......
......@@ -19,11 +19,40 @@ module Gitlab
def create!
resource = ::Kubeclient::Resource.new(metadata: { name: name })
log_event(:begin_create)
@client.create_namespace(resource)
end
def ensure_exists!
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
......
......@@ -62,5 +62,32 @@ describe Gitlab::Kubernetes::Namespace do
subject.ensure_exists!
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
......@@ -20,7 +20,7 @@ shared_examples 'logs kubernetes errors' do
end
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(
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