Commit d86e27ee authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'ce-to-ee-2018-05-21' into 'master'

CE upstream - 2018-05-21 09:27 UTC

See merge request gitlab-org/gitlab-ee!5787
parents b50d9d3a 17255af2
......@@ -13,7 +13,7 @@ class PersonalProjectsFinder < UnionFinder
def execute(current_user = nil)
segments = all_projects(current_user)
find_union(segments, Project).includes(:namespace).order_id_desc
find_union(segments, Project).includes(:namespace).order_updated_desc
end
private
......
......@@ -49,6 +49,11 @@ module Clusters
# ensures headers containing auth data are appended to original k8s client options
options = kube_client.rest_client.options.merge(headers: kube_client.headers)
RestClient::Resource.new(proxy_url, options)
rescue Kubeclient::HttpError
# 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
private
......
---
title: Order UsersController#projects.json by updated_at
merge_request: 18227
author: Takuya Noguchi
type: other
---
title: Fix corrupted environment pages with unathorized proxy url
merge_request: 18989
author:
type: fixed
---
title: Workhorse will use Gitaly to create archives
merge_request:
author:
type: other
......@@ -403,10 +403,10 @@ module Gitlab
prefix = archive_prefix(ref, commit.id, append_sha: append_sha)
{
'RepoPath' => path,
'ArchivePrefix' => prefix,
'ArchivePath' => archive_file_path(storage_path, commit.id, prefix, format),
'CommitId' => commit.id
'CommitId' => commit.id,
'GitalyRepository' => gitaly_repository.to_h
}
end
......
......@@ -65,12 +65,7 @@ module Gitlab
params = repository.archive_metadata(ref, Gitlab.config.gitlab.repository_downloads_path, format, append_sha: append_sha)
raise "Repository or ref not found" if params.empty?
if Gitlab::GitalyClient.feature_enabled?(:workhorse_archive, status: Gitlab::GitalyClient::MigrationStatus::OPT_OUT)
params.merge!(
'GitalyServer' => gitaly_server_hash(repository),
'GitalyRepository' => repository.gitaly_repository.to_h
)
end
params['GitalyServer'] = gitaly_server_hash(repository)
# If present DisableCache must be a Boolean. Otherwise workhorse ignores it.
params['DisableCache'] = true if git_archive_cache_disabled?
......
......@@ -42,6 +42,22 @@ feature 'Environments page', :js do
expect(page).to have_content('You don\'t have any environments right now')
end
end
context 'when cluster is not reachable' do
let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let!(:application_prometheus) { create(:clusters_applications_prometheus, :installed, cluster: cluster) }
before do
allow_any_instance_of(Kubeclient::Client).to receive(:proxy_url).and_raise(Kubeclient::HttpError.new(401, 'Unauthorized', nil))
end
it 'should show one environment without error' do
visit_environments(project, scope: 'available')
expect(page).to have_css('.environments-container')
expect(page.all('.environment-name').length).to eq(1)
end
end
end
describe 'with one stopped environment' do
......
......@@ -27,8 +27,8 @@ describe 'Users > User browses projects on user page', :js do
end
it 'paginates projects', :js do
project = create(:project, namespace: user.namespace)
project2 = create(:project, namespace: user.namespace)
project = create(:project, namespace: user.namespace, updated_at: 2.minutes.since)
project2 = create(:project, namespace: user.namespace, updated_at: 1.minute.since)
allow(Project).to receive(:default_per_page).and_return(1)
sign_in(user)
......@@ -41,11 +41,11 @@ describe 'Users > User browses projects on user page', :js do
wait_for_requests
expect(page).to have_content(project2.name)
expect(page).to have_content(project.name)
click_link('Next')
expect(page).to have_content(project.name)
expect(page).to have_content(project2.name)
end
context 'when not signed in' do
......
......@@ -4,14 +4,16 @@ describe PersonalProjectsFinder do
let(:source_user) { create(:user) }
let(:current_user) { create(:user) }
let(:finder) { described_class.new(source_user) }
let!(:public_project) { create(:project, :public, namespace: source_user.namespace) }
let!(:public_project) do
create(:project, :public, namespace: source_user.namespace, updated_at: 1.hour.ago)
end
let!(:private_project) do
create(:project, :private, namespace: source_user.namespace, path: 'mepmep')
create(:project, :private, namespace: source_user.namespace, updated_at: 3.hours.ago, path: 'mepmep')
end
let!(:internal_project) do
create(:project, :internal, namespace: source_user.namespace, path: 'C')
create(:project, :internal, namespace: source_user.namespace, updated_at: 2.hours.ago, path: 'C')
end
before do
......@@ -28,7 +30,7 @@ describe PersonalProjectsFinder do
subject { finder.execute(current_user) }
context 'normal user' do
it { is_expected.to eq([internal_project, private_project, public_project]) }
it { is_expected.to eq([public_project, internal_project, private_project]) }
end
context 'external' do
......@@ -36,7 +38,7 @@ describe PersonalProjectsFinder do
current_user.update_attributes(external: true)
end
it { is_expected.to eq([private_project, public_project]) }
it { is_expected.to eq([public_project, private_project]) }
end
end
end
......@@ -249,10 +249,6 @@ describe Gitlab::Git::Repository, seed_helper: true do
subject(:metadata) { repository.archive_metadata(ref, storage_path, format, append_sha: append_sha) }
it 'sets RepoPath to the repository path' do
expect(metadata['RepoPath']).to eq(repository.path)
end
it 'sets CommitId to the commit SHA' do
expect(metadata['CommitId']).to eq(SeedRepo::LastCommit::ID)
end
......
require 'spec_helper'
describe Gitlab::Workhorse do
let(:project) { create(:project, :repository) }
set(:project) { create(:project, :repository) }
let(:repository) { project.repository }
def decode_workhorse_header(array)
......@@ -55,16 +55,6 @@ describe Gitlab::Workhorse do
end
end
context 'when Gitaly workhorse_archive feature is disabled', :disable_gitaly do
it 'sets the header correctly' do
key, command, params = decode_workhorse_header(subject)
expect(key).to eq('Gitlab-Workhorse-Send-Data')
expect(command).to eq('git-archive')
expect(params).to eq(base_params)
end
end
context "when the repository doesn't have an archive file path" do
before do
allow(project.repository).to receive(:archive_metadata).and_return(Hash.new)
......
......@@ -85,6 +85,16 @@ describe Clusters::Applications::Prometheus do
it 'copies options and headers from kube client to proxy client' do
expect(subject.prometheus_client.options).to eq(kube_client.rest_client.options.merge(headers: kube_client.headers))
end
context 'when cluster is not reachable' do
before do
allow(kube_client).to receive(:proxy_url).and_raise(Kubeclient::HttpError.new(401, 'Unauthorized', nil))
end
it 'returns nil' do
expect(subject.prometheus_client).to be_nil
end
end
end
end
......
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