From 2dd7339c0149034aa5faa4029cff1a82aef35d21 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 4 Oct 2018 17:52:36 +0900 Subject: Add scheduled actions in deployment entity --- app/models/ci/build.rb | 6 +++++- app/models/deployment.rb | 6 +++++- app/serializers/deployment_entity.rb | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 8f1547463ba..9b0bb2e05fc 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -245,10 +245,14 @@ module Ci .fabricate! end - def other_actions + def other_manual_actions pipeline.manual_actions.where.not(name: name) end + def other_scheduled_actions + pipeline.scheduled_actions.where.not(name: name) + end + def pages_generator? Gitlab.config.pages.enabled && self.name == 'pages' diff --git a/app/models/deployment.rb b/app/models/deployment.rb index 6962b54441b..ed61135cb47 100644 --- a/app/models/deployment.rb +++ b/app/models/deployment.rb @@ -44,7 +44,11 @@ class Deployment < ActiveRecord::Base end def manual_actions - @manual_actions ||= deployable.try(:other_actions) + @manual_actions ||= deployable.try(:other_manual_actions) + end + + def scheduled_actions + @scheduled_actions ||= deployable.try(:other_scheduled_actions) end def includes_commit?(commit) diff --git a/app/serializers/deployment_entity.rb b/app/serializers/deployment_entity.rb index 344148a1fb7..aa1d9e6292c 100644 --- a/app/serializers/deployment_entity.rb +++ b/app/serializers/deployment_entity.rb @@ -25,4 +25,5 @@ class DeploymentEntity < Grape::Entity expose :commit, using: CommitEntity expose :deployable, using: JobEntity expose :manual_actions, using: JobEntity + expose :scheduled_actions, using: JobEntity end -- cgit v1.2.1 From 9a13c250af7b6f3f81167a8f313bbe6cd90502d2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 5 Oct 2018 16:21:27 +0200 Subject: Add packages section to CE config file Signed-off-by: Dmitriy Zaporozhets --- config/gitlab.yml.example | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 67337f4b82f..5417f3d448b 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -207,6 +207,10 @@ production: &base # endpoint: 'http://127.0.0.1:9000' # default: nil # path_style: true # Use 'host/bucket_name/object' instead of 'bucket_name.host/object' + ## Packages (maven repository so far) + packages: + enabled: false + ## GitLab Pages pages: enabled: false -- cgit v1.2.1 From c12a78969315a8e25128653df2a7515861010b12 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 8 Oct 2018 15:06:00 +0200 Subject: Display scheduled job actions on environments list --- .../components/environment_actions.vue | 30 ++++++++++-- .../environments/components/environment_item.vue | 53 ++++++++-------------- app/assets/stylesheets/pages/environments.scss | 5 -- 3 files changed, 45 insertions(+), 43 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index e1f9248bc4c..f4db968b882 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -1,4 +1,6 @@ @@ -77,12 +93,16 @@ export default { :class="{ disabled: isActionDisabled(action) }" :disabled="isActionDisabled(action)" type="button" - class="js-manual-action-link no-btn btn" - @click="onClickAction(action.play_path)" + class="js-manual-action-link no-btn btn d-flex align-items-center" + @click="onClickAction(action)" > - + {{ action.name }} + + + {{ remainingTime(action) }} + diff --git a/app/assets/javascripts/environments/components/environment_item.vue b/app/assets/javascripts/environments/components/environment_item.vue index 11e3b781e5a..ff50e75dbda 100644 --- a/app/assets/javascripts/environments/components/environment_item.vue +++ b/app/assets/javascripts/environments/components/environment_item.vue @@ -12,6 +12,7 @@ import TerminalButtonComponent from './environment_terminal_button.vue'; import MonitoringButtonComponent from './environment_monitoring.vue'; import CommitComponent from '../../vue_shared/components/commit.vue'; import eventHub from '../event_hub'; +import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; /** * Envrionment Item Component @@ -71,21 +72,6 @@ export default { return false; }, - /** - * Verifies is the given environment has manual actions. - * Used to verify if we should render them or nor. - * - * @returns {Boolean|Undefined} - */ - hasManualActions() { - return ( - this.model && - this.model.last_deployment && - this.model.last_deployment.manual_actions && - this.model.last_deployment.manual_actions.length > 0 - ); - }, - /** * Checkes whether the environment is protected. * (`is_protected` currently only set in EE) @@ -152,23 +138,24 @@ export default { return ''; }, - /** - * Returns the manual actions with the name parsed. - * - * @returns {Array.|Undefined} - */ - manualActions() { - if (this.hasManualActions) { - return this.model.last_deployment.manual_actions.map(action => { - const parsedAction = { - name: humanize(action.name), - play_path: action.play_path, - playable: action.playable, - }; - return parsedAction; - }); + actions() { + if (!this.model || !this.model.last_deployment) { + return []; + } + + const { manualActions, scheduledActions } = convertObjectPropsToCamelCase( + this.model.last_deployment, + { deep: true }, + ); + let combinedActions = []; + if (this.canCreateDeployment) { + combinedActions = combinedActions.concat(manualActions || []); } - return []; + combinedActions = combinedActions.concat(scheduledActions || []); + return combinedActions.map(action => ({ + ...action, + name: humanize(action.name), + })); }, /** @@ -624,8 +611,8 @@ export default { /> Date: Tue, 9 Oct 2018 19:54:16 +0200 Subject: Add component test for scheduled jobs in environments actions component --- .../environments/environment_actions_spec.js | 122 +++++++++++++++------ 1 file changed, 88 insertions(+), 34 deletions(-) diff --git a/spec/javascripts/environments/environment_actions_spec.js b/spec/javascripts/environments/environment_actions_spec.js index ea40a1fcd4b..0fbfe95915e 100644 --- a/spec/javascripts/environments/environment_actions_spec.js +++ b/spec/javascripts/environments/environment_actions_spec.js @@ -1,15 +1,19 @@ import Vue from 'vue'; -import actionsComp from '~/environments/components/environment_actions.vue'; +import eventHub from '~/environments/event_hub'; +import EnvironmentActions from '~/environments/components/environment_actions.vue'; +import mountComponent from 'spec/helpers/vue_mount_component_helper'; +import { TEST_HOST } from 'spec/test_constants'; -describe('Actions Component', () => { - let ActionsComponent; - let actionsMock; - let component; +describe('EnvironmentActions Component', () => { + const Component = Vue.extend(EnvironmentActions); + let vm; - beforeEach(() => { - ActionsComponent = Vue.extend(actionsComp); + afterEach(() => { + vm.$destroy(); + }); - actionsMock = [ + describe('manual actions', () => { + const actions = [ { name: 'bar', play_path: 'https://gitlab.com/play', @@ -25,38 +29,88 @@ describe('Actions Component', () => { }, ]; - component = new ActionsComponent({ - propsData: { - actions: actionsMock, - }, - }).$mount(); - }); + beforeEach(() => { + vm = mountComponent(Component, { actions }); + }); - describe('computed', () => { - it('title', () => { - expect(component.title).toEqual('Deploy to...'); + it('should render a dropdown button with icon and title attribute', () => { + expect(vm.$el.querySelector('.fa-caret-down')).toBeDefined(); + expect(vm.$el.querySelector('.dropdown-new').getAttribute('data-original-title')).toEqual( + 'Deploy to...', + ); + expect(vm.$el.querySelector('.dropdown-new').getAttribute('aria-label')).toEqual( + 'Deploy to...', + ); }); - }); - it('should render a dropdown button with icon and title attribute', () => { - expect(component.$el.querySelector('.fa-caret-down')).toBeDefined(); - expect(component.$el.querySelector('.dropdown-new').getAttribute('data-original-title')).toEqual('Deploy to...'); - expect(component.$el.querySelector('.dropdown-new').getAttribute('aria-label')).toEqual('Deploy to...'); - }); + it('should render a dropdown with the provided list of actions', () => { + expect(vm.$el.querySelectorAll('.dropdown-menu li').length).toEqual(actions.length); + }); + + it("should render a disabled action when it's not playable", () => { + expect( + vm.$el.querySelector('.dropdown-menu li:last-child button').getAttribute('disabled'), + ).toEqual('disabled'); - it('should render a dropdown with the provided list of actions', () => { - expect( - component.$el.querySelectorAll('.dropdown-menu li').length, - ).toEqual(actionsMock.length); + expect( + vm.$el.querySelector('.dropdown-menu li:last-child button').classList.contains('disabled'), + ).toEqual(true); + }); }); - it('should render a disabled action when it\'s not playable', () => { - expect( - component.$el.querySelector('.dropdown-menu li:last-child button').getAttribute('disabled'), - ).toEqual('disabled'); + describe('scheduled jobs', () => { + const scheduledJobAction = { + name: 'scheduled action', + playPath: `${TEST_HOST}/scheduled/job/action`, + playable: true, + scheduledAt: '2063-04-05T00:42:00Z', + }; + const expiredJobAction = { + name: 'expired action', + playPath: `${TEST_HOST}/expired/job/action`, + playable: true, + scheduledAt: '2018-10-05T08:23:00Z', + }; + const findDropdownItem = action => { + const buttons = vm.$el.querySelectorAll('.dropdown-menu li button'); + return Array.prototype.find.call(buttons, element => + element.innerText.trim().startsWith(action.name), + ); + }; + + beforeEach(() => { + spyOn(Date, 'now').and.callFake(() => new Date('2063-04-04T00:42:00Z').getTime()); + vm = mountComponent(Component, { actions: [scheduledJobAction, expiredJobAction] }); + }); + + it('emits postAction event after confirming', () => { + const emitSpy = jasmine.createSpy('emit'); + eventHub.$on('postAction', emitSpy); + spyOn(window, 'confirm').and.callFake(() => true); + + findDropdownItem(scheduledJobAction).click(); + + expect(window.confirm).toHaveBeenCalled(); + expect(emitSpy).toHaveBeenCalledWith({ endpoint: scheduledJobAction.playPath }); + }); + + it('does not emit postAction event if confirmation is cancelled', () => { + const emitSpy = jasmine.createSpy('emit'); + eventHub.$on('postAction', emitSpy); + spyOn(window, 'confirm').and.callFake(() => false); + + findDropdownItem(scheduledJobAction).click(); - expect( - component.$el.querySelector('.dropdown-menu li:last-child button').classList.contains('disabled'), - ).toEqual(true); + expect(window.confirm).toHaveBeenCalled(); + expect(emitSpy).not.toHaveBeenCalled(); + }); + + it('displays the remaining time in the dropdown', () => { + expect(findDropdownItem(scheduledJobAction)).toContainText('24:00:00'); + }); + + it('displays 00:00:00 for expired jobs in the dropdown', () => { + expect(findDropdownItem(expiredJobAction)).toContainText('00:00:00'); + }); }); }); -- cgit v1.2.1 From 760fd6751940b0b681800110992b8100dfd10379 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Tue, 9 Oct 2018 22:04:56 +0200 Subject: Add feature flags for scheduled jobs in environments list --- .../components/environment_actions.vue | 2 +- .../projects/environments/environments_spec.rb | 68 +++++++++++++++++++++- 2 files changed, 67 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index f4db968b882..1fc571b57fb 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -70,7 +70,7 @@ export default { :aria-label="title" :disabled="isLoading" type="button" - class="dropdown btn btn-default dropdown-new js-dropdown-play-icon-container" + class="dropdown btn btn-default dropdown-new js-environment-actions-dropdown" data-container="body" data-toggle="dropdown" > diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index f0890018286..5671d4b907d 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -162,7 +162,7 @@ describe 'Environments page', :js do end it 'shows a play button' do - find('.js-dropdown-play-icon-container').click + find('.js-environment-actions-dropdown').click expect(page).to have_content(action.name.humanize) end @@ -170,7 +170,7 @@ describe 'Environments page', :js do it 'allows to play a manual action', :js do expect(action).to be_manual - find('.js-dropdown-play-icon-container').click + find('.js-environment-actions-dropdown').click expect(page).to have_content(action.name.humanize) expect { find('.js-manual-action-link').click } @@ -260,6 +260,70 @@ describe 'Environments page', :js do end end end + + context 'when there is a delayed job' do + let!(:pipeline) { create(:ci_pipeline, project: project) } + let!(:build) { create(:ci_build, pipeline: pipeline) } + + let!(:delayed_job) do + create(:ci_build, :scheduled, + pipeline: pipeline, + name: 'delayed job', + stage: 'test', + commands: 'test') + end + + let!(:deployment) do + create(:deployment, + environment: environment, + deployable: build, + sha: project.commit.id) + end + + before do + visit_environments(project) + end + + it 'has a dropdown for actionable jobs' do + expect(page).to have_selector('.dropdown-new.btn.btn-default .ic-play') + end + + it "has link to the delayed job's action" do + find('.js-environment-actions-dropdown').click + + time_diff = [0, delayed_job.scheduled_at - Time.now].max + expect(page).to have_button('Delayed job') + expect(page).to have_content(Time.at(time_diff).utc.strftime("%H:%M:%S")) + end + + context 'when delayed job is expired already' do + let!(:delayed_job) do + create(:ci_build, :expired_scheduled, + pipeline: pipeline, + name: 'delayed job', + stage: 'test', + commands: 'test') + end + + it "shows 00:00:00 as the remaining time" do + find('.js-environment-actions-dropdown').click + + expect(page).to have_content("00:00:00") + end + end + + context 'when user played a delayed job immediately' do + before do + find('.js-environment-actions-dropdown').click + page.accept_confirm { click_button('Delayed job') } + wait_for_requests + end + + it 'enqueues the delayed job', :js do + expect(delayed_job.reload).to be_pending + end + end + end end end -- cgit v1.2.1 From 4f49f54af5b49e28801f0934547ff3159161759b Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Tue, 9 Oct 2018 20:07:48 +0000 Subject: Fix issue URL of TODO in environment_actions.vue --- app/assets/javascripts/environments/components/environment_actions.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index 1fc571b57fb..3cebf68ea93 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -33,7 +33,7 @@ export default { onClickAction(action) { if (action.scheduledAt) { const confirmationMessage = sprintf(s__("DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes."), { jobName: action.name }); - // https://gitlab.com/gitlab-org/gitlab-ce/issues/52099 + // https://gitlab.com/gitlab-org/gitlab-ce/issues/52156 // eslint-disable-next-line no-alert if (!window.confirm(confirmationMessage)) { return; -- cgit v1.2.1 From 1f3f06668b273265a96f526039e139629959a890 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 10 Oct 2018 10:47:31 +0900 Subject: Fix and add spec --- spec/models/ci/build_spec.rb | 46 ++++++++++++++++++++++++++++-- spec/models/deployment_spec.rb | 1 + spec/serializers/deployment_entity_spec.rb | 22 ++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index a046541031e..df0851c1b6c 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1523,11 +1523,11 @@ describe Ci::Build do end end - describe '#other_actions' do + describe '#other_manual_actions' do let(:build) { create(:ci_build, :manual, pipeline: pipeline) } let!(:other_build) { create(:ci_build, :manual, pipeline: pipeline, name: 'other action') } - subject { build.other_actions } + subject { build.other_manual_actions } before do project.add_developer(user) @@ -1558,6 +1558,48 @@ describe Ci::Build do end end + describe '#other_scheduled_actions' do + let(:build) { create(:ci_build, :scheduled, pipeline: pipeline) } + + subject { build.other_scheduled_actions } + + before do + project.add_developer(user) + end + + context "when other build's status is success" do + let!(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: 'other action') } + + it 'returns other actions' do + is_expected.to contain_exactly(other_build) + end + end + + context "when other build's status is failed" do + let!(:other_build) { create(:ci_build, :schedulable, :failed, pipeline: pipeline, name: 'other action') } + + it 'returns other actions' do + is_expected.to contain_exactly(other_build) + end + end + + context "when other build's status is running" do + let!(:other_build) { create(:ci_build, :schedulable, :running, pipeline: pipeline, name: 'other action') } + + it 'does not return other actions' do + is_expected.to be_empty + end + end + + context "when other build's status is scheduled" do + let!(:other_build) { create(:ci_build, :scheduled, pipeline: pipeline, name: 'other action') } + + it 'does not return other actions' do + is_expected.to contain_exactly(other_build) + end + end + end + describe '#persisted_environment' do let!(:environment) do create(:environment, project: project, name: "foo-#{project.default_branch}") diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index b335e0fbeb3..86518c632df 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -12,6 +12,7 @@ describe Deployment do it { is_expected.to delegate_method(:commit).to(:project) } it { is_expected.to delegate_method(:commit_title).to(:commit).as(:try) } it { is_expected.to delegate_method(:manual_actions).to(:deployable).as(:try) } + it { is_expected.to delegate_method(:scheduled_actions).to(:deployable).as(:try) } it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:sha) } diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb index 522c92ce295..698fbd818c0 100644 --- a/spec/serializers/deployment_entity_spec.rb +++ b/spec/serializers/deployment_entity_spec.rb @@ -22,4 +22,26 @@ describe DeploymentEntity do it 'exposes creation date' do expect(subject).to include(:created_at) end + + describe 'scheduled_actions' do + let(:project) { create(:project, :repository) } + let(:pipeline) { create(:ci_pipeline, project: project, user: user) } + let(:build) { create(:ci_build, :success, pipeline: pipeline) } + let(:deployment) { create(:deployment, deployable: build) } + + context 'when deployment has another action' do + let(:other_build) { create(:ci_build, :scheduled, pipeline: pipeline, name: 'other build') } + let!(:other_deployment) { create(:deployment, deployable: other_build) } + + it 'returns other actions' do + expect(subject[:scheduled_actions][0][:name]).to eq 'other build' + end + end + + context 'when deployment does not have other actions' do + it 'does not return other actions' do + expect(subject[:scheduled_actions]).to be_empty + end + end + end end -- cgit v1.2.1 From 4f46fadd7e970b24d13f271596a8f3fd8c774aba Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Wed, 10 Oct 2018 13:58:30 +0900 Subject: Add changelog --- .../unreleased/scheduled-manual-jobs-environment-play-buttons.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/scheduled-manual-jobs-environment-play-buttons.yml diff --git a/changelogs/unreleased/scheduled-manual-jobs-environment-play-buttons.yml b/changelogs/unreleased/scheduled-manual-jobs-environment-play-buttons.yml new file mode 100644 index 00000000000..c89af78d989 --- /dev/null +++ b/changelogs/unreleased/scheduled-manual-jobs-environment-play-buttons.yml @@ -0,0 +1,5 @@ +--- +title: Add the Play button for delayed jobs in environment page +merge_request: 22106 +author: +type: added -- cgit v1.2.1 From f056bb1da97d01d6db822b52b733aace8887a588 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 12 Oct 2018 11:22:19 +0900 Subject: Improve deployment entity spec --- spec/serializers/deployment_entity_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/serializers/deployment_entity_spec.rb b/spec/serializers/deployment_entity_spec.rb index 698fbd818c0..8793a762f9d 100644 --- a/spec/serializers/deployment_entity_spec.rb +++ b/spec/serializers/deployment_entity_spec.rb @@ -29,16 +29,16 @@ describe DeploymentEntity do let(:build) { create(:ci_build, :success, pipeline: pipeline) } let(:deployment) { create(:deployment, deployable: build) } - context 'when deployment has another action' do - let(:other_build) { create(:ci_build, :scheduled, pipeline: pipeline, name: 'other build') } + context 'when the same pipeline has a scheduled action' do + let(:other_build) { create(:ci_build, :schedulable, :success, pipeline: pipeline, name: 'other build') } let!(:other_deployment) { create(:deployment, deployable: other_build) } - it 'returns other actions' do + it 'returns other scheduled actions' do expect(subject[:scheduled_actions][0][:name]).to eq 'other build' end end - context 'when deployment does not have other actions' do + context 'when the same pipeline does not have a scheduled action' do it 'does not return other actions' do expect(subject[:scheduled_actions]).to be_empty end -- cgit v1.2.1 From 8622763e6cbba52037964d573a8b40ae78abe747 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 12 Oct 2018 11:34:15 +0900 Subject: Use regex for the extecped time --- spec/features/projects/environments/environments_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/features/projects/environments/environments_spec.rb b/spec/features/projects/environments/environments_spec.rb index 5671d4b907d..89e21fcd56b 100644 --- a/spec/features/projects/environments/environments_spec.rb +++ b/spec/features/projects/environments/environments_spec.rb @@ -291,9 +291,8 @@ describe 'Environments page', :js do it "has link to the delayed job's action" do find('.js-environment-actions-dropdown').click - time_diff = [0, delayed_job.scheduled_at - Time.now].max expect(page).to have_button('Delayed job') - expect(page).to have_content(Time.at(time_diff).utc.strftime("%H:%M:%S")) + expect(page).to have_content(/\d{2}:\d{2}:\d{2}/) end context 'when delayed job is expired already' do -- cgit v1.2.1 From c8c01bbe0229128f898df167aa7fcc3ef927c4d0 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 15 Oct 2018 12:27:59 +0200 Subject: Make frontend files prettier --- .../javascripts/environments/components/environment_actions.vue | 7 ++++++- app/assets/stylesheets/pages/environments.scss | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index 3cebf68ea93..7ee2bb61007 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -32,7 +32,12 @@ export default { methods: { onClickAction(action) { if (action.scheduledAt) { - const confirmationMessage = sprintf(s__("DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes."), { jobName: action.name }); + const confirmationMessage = sprintf( + s__( + "DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes.", + ), + { jobName: action.name }, + ); // https://gitlab.com/gitlab-org/gitlab-ce/issues/52156 // eslint-disable-next-line no-alert if (!window.confirm(confirmationMessage)) { diff --git a/app/assets/stylesheets/pages/environments.scss b/app/assets/stylesheets/pages/environments.scss index 6f64f1d1d24..676438969b5 100644 --- a/app/assets/stylesheets/pages/environments.scss +++ b/app/assets/stylesheets/pages/environments.scss @@ -360,7 +360,7 @@ } .arrow-shadow { - content: ""; + content: ''; position: absolute; width: 7px; height: 7px; -- cgit v1.2.1 From 3fb7a1f97a812b7b2b5e80a8a0575cb7bfd2d3c4 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Thu, 18 Oct 2018 15:47:30 +0900 Subject: Add spec for Deployment#scheduled_actions --- spec/models/deployment_spec.rb | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 86518c632df..9007418ac35 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -12,11 +12,26 @@ describe Deployment do it { is_expected.to delegate_method(:commit).to(:project) } it { is_expected.to delegate_method(:commit_title).to(:commit).as(:try) } it { is_expected.to delegate_method(:manual_actions).to(:deployable).as(:try) } - it { is_expected.to delegate_method(:scheduled_actions).to(:deployable).as(:try) } it { is_expected.to validate_presence_of(:ref) } it { is_expected.to validate_presence_of(:sha) } + describe '#scheduled_actions' do + subject { deployment.scheduled_actions } + + let(:project) { create(:project, :repository) } + let(:pipeline) { create(:ci_pipeline, project: project) } + let(:build) { create(:ci_build, :success, pipeline: pipeline) } + let(:deployment) { create(:deployment, deployable: build) } + + it 'delegates to other_scheduled_actions' do + expect_any_instance_of(Ci::Build) + .to receive(:other_scheduled_actions) + + subject + end + end + describe 'modules' do it_behaves_like 'AtomicInternalId' do let(:internal_id_attribute) { :iid } -- cgit v1.2.1 From 8ab27e64fe307ec75032a0597fd96caa80e40b67 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 22 Oct 2018 21:43:47 +0200 Subject: Update confirmation modal text for starting delayed jobs immediately --- app/assets/javascripts/environments/components/environment_actions.vue | 2 +- app/assets/javascripts/pipelines/components/pipelines_actions.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index 2d51a13d8a0..6f729676f89 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -34,7 +34,7 @@ export default { if (action.scheduledAt) { const confirmationMessage = sprintf( s__( - "DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes.", + "DelayedJobs|Are you sure you want to run %{jobName} immediately? Otherwise this job will run automatically after it's timer finishes.", ), { jobName: action.name }, ); diff --git a/app/assets/javascripts/pipelines/components/pipelines_actions.vue b/app/assets/javascripts/pipelines/components/pipelines_actions.vue index 16e69759091..83f16c0ffdb 100644 --- a/app/assets/javascripts/pipelines/components/pipelines_actions.vue +++ b/app/assets/javascripts/pipelines/components/pipelines_actions.vue @@ -28,7 +28,7 @@ export default { if (action.scheduled_at) { const confirmationMessage = sprintf( s__( - "DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes.", + "DelayedJobs|Are you sure you want to run %{jobName} immediately? Otherwise this job will run automatically after it's timer finishes.", ), { jobName: action.name }, ); -- cgit v1.2.1 From fc0e99df9f1c232a1d292137000e8ffebea1b259 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 22 Oct 2018 21:45:45 +0200 Subject: Add permission check for delayed job actions --- .../javascripts/environments/components/environment_item.vue | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/environments/components/environment_item.vue b/app/assets/javascripts/environments/components/environment_item.vue index f2fb0074ea1..eb51118dcf2 100644 --- a/app/assets/javascripts/environments/components/environment_item.vue +++ b/app/assets/javascripts/environments/components/environment_item.vue @@ -141,7 +141,7 @@ export default { }, actions() { - if (!this.model || !this.model.last_deployment) { + if (!this.model || !this.model.last_deployment || !this.canCreateDeployment) { return []; } @@ -149,11 +149,7 @@ export default { this.model.last_deployment, { deep: true }, ); - let combinedActions = []; - if (this.canCreateDeployment) { - combinedActions = combinedActions.concat(manualActions || []); - } - combinedActions = combinedActions.concat(scheduledActions || []); + const combinedActions = (manualActions || []).concat(scheduledActions || []); return combinedActions.map(action => ({ ...action, name: humanize(action.name), -- cgit v1.2.1 From 3cb6607aeadfc53a418d3f8acaa5384d62b912d3 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Mon, 22 Oct 2018 22:00:09 +0200 Subject: Use secondary text color for delayed job timer --- .../javascripts/environments/components/environment_actions.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/environments/components/environment_actions.vue b/app/assets/javascripts/environments/components/environment_actions.vue index 6f729676f89..0a3ae384afa 100644 --- a/app/assets/javascripts/environments/components/environment_actions.vue +++ b/app/assets/javascripts/environments/components/environment_actions.vue @@ -102,7 +102,10 @@ export default { {{ action.name }} - + {{ remainingTime(action) }} -- cgit v1.2.1 From 098c722542cce93046bf6012f089dac48251d091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Rodr=C3=ADguez?= Date: Tue, 2 Oct 2018 17:11:07 -0300 Subject: Add gitlab:gitaly:check task for Gitaly health check Also, since Gitaly now takes care of checking for storage paths existence/accessibility, we can remove those check from the gitlab:gitlab_shell_check task and advance further into 0 direct disk approach on gitlab-rails --- changelogs/unreleased/rake-gitaly-check.yml | 5 + doc/administration/raketasks/maintenance.md | 3 +- lib/tasks/gitlab/check.rake | 139 +++++----------------------- 3 files changed, 29 insertions(+), 118 deletions(-) create mode 100644 changelogs/unreleased/rake-gitaly-check.yml diff --git a/changelogs/unreleased/rake-gitaly-check.yml b/changelogs/unreleased/rake-gitaly-check.yml new file mode 100644 index 00000000000..90fbd62d203 --- /dev/null +++ b/changelogs/unreleased/rake-gitaly-check.yml @@ -0,0 +1,5 @@ +--- +title: Add gitlab:gitaly:check task for Gitaly health check +merge_request: 22063 +author: +type: other diff --git a/doc/administration/raketasks/maintenance.md b/doc/administration/raketasks/maintenance.md index 29af07d12dc..0d863594fc7 100644 --- a/doc/administration/raketasks/maintenance.md +++ b/doc/administration/raketasks/maintenance.md @@ -53,6 +53,7 @@ Git: /usr/bin/git Runs the following rake tasks: - `gitlab:gitlab_shell:check` +- `gitlab:gitaly:check` - `gitlab:sidekiq:check` - `gitlab:app:check` @@ -252,7 +253,7 @@ clear it. To clear all exclusive leases: -DANGER: **DANGER**: +DANGER: **DANGER**: Don't run it while GitLab or Sidekiq is running ```bash diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake index e5b5f3548e4..663bebfe71a 100644 --- a/lib/tasks/gitlab/check.rake +++ b/lib/tasks/gitlab/check.rake @@ -1,6 +1,7 @@ namespace :gitlab do desc 'GitLab | Check the configuration of GitLab and its environment' task check: %w{gitlab:gitlab_shell:check + gitlab:gitaly:check gitlab:sidekiq:check gitlab:incoming_email:check gitlab:ldap:check @@ -44,13 +45,7 @@ namespace :gitlab do start_checking "GitLab Shell" check_gitlab_shell - Gitlab::GitalyClient::StorageSettings.allow_disk_access do - check_repo_base_exists - check_repo_base_is_not_symlink - check_repo_base_user_and_group - check_repo_base_permissions - check_repos_hooks_directory_is_link - end + check_repos_hooks_directory_is_link check_gitlab_shell_self_test finished_checking "GitLab Shell" @@ -59,116 +54,6 @@ namespace :gitlab do # Checks ######################## - def check_repo_base_exists - puts "Repo base directory exists?" - - Gitlab.config.repositories.storages.each do |name, repository_storage| - repo_base_path = repository_storage.legacy_disk_path - print "#{name}... " - - if File.exist?(repo_base_path) - puts "yes".color(:green) - else - puts "no".color(:red) - puts "#{repo_base_path} is missing".color(:red) - try_fixing_it( - "This should have been created when setting up GitLab Shell.", - "Make sure it's set correctly in config/gitlab.yml", - "Make sure GitLab Shell is installed correctly." - ) - for_more_information( - see_installation_guide_section "GitLab Shell" - ) - fix_and_rerun - end - end - end - - def check_repo_base_is_not_symlink - puts "Repo storage directories are symlinks?" - - Gitlab.config.repositories.storages.each do |name, repository_storage| - repo_base_path = repository_storage.legacy_disk_path - print "#{name}... " - - unless File.exist?(repo_base_path) - puts "can't check because of previous errors".color(:magenta) - break - end - - unless File.symlink?(repo_base_path) - puts "no".color(:green) - else - puts "yes".color(:red) - try_fixing_it( - "Make sure it's set to the real directory in config/gitlab.yml" - ) - fix_and_rerun - end - end - end - - def check_repo_base_permissions - puts "Repo paths access is drwxrws---?" - - Gitlab.config.repositories.storages.each do |name, repository_storage| - repo_base_path = repository_storage.legacy_disk_path - print "#{name}... " - - unless File.exist?(repo_base_path) - puts "can't check because of previous errors".color(:magenta) - break - end - - if File.stat(repo_base_path).mode.to_s(8).ends_with?("2770") - puts "yes".color(:green) - else - puts "no".color(:red) - try_fixing_it( - "sudo chmod -R ug+rwX,o-rwx #{repo_base_path}", - "sudo chmod -R ug-s #{repo_base_path}", - "sudo find #{repo_base_path} -type d -print0 | sudo xargs -0 chmod g+s" - ) - for_more_information( - see_installation_guide_section "GitLab Shell" - ) - fix_and_rerun - end - end - end - - def check_repo_base_user_and_group - gitlab_shell_ssh_user = Gitlab.config.gitlab_shell.ssh_user - puts "Repo paths owned by #{gitlab_shell_ssh_user}:root, or #{gitlab_shell_ssh_user}:#{Gitlab.config.gitlab_shell.owner_group}?" - - Gitlab.config.repositories.storages.each do |name, repository_storage| - repo_base_path = repository_storage.legacy_disk_path - print "#{name}... " - - unless File.exist?(repo_base_path) - puts "can't check because of previous errors".color(:magenta) - break - end - - user_id = uid_for(gitlab_shell_ssh_user) - root_group_id = gid_for('root') - group_ids = [root_group_id, gid_for(Gitlab.config.gitlab_shell.owner_group)] - if File.stat(repo_base_path).uid == user_id && group_ids.include?(File.stat(repo_base_path).gid) - puts "yes".color(:green) - else - puts "no".color(:red) - puts " User id for #{gitlab_shell_ssh_user}: #{user_id}. Groupd id for root: #{root_group_id}".color(:blue) - try_fixing_it( - "sudo chown -R #{gitlab_shell_ssh_user}:root #{repo_base_path}" - ) - for_more_information( - see_installation_guide_section "GitLab Shell" - ) - fix_and_rerun - end - end - end - def check_repos_hooks_directory_is_link print "hooks directories in repos are links: ... " @@ -247,6 +132,26 @@ namespace :gitlab do end end + namespace :gitaly do + desc 'GitLab | Check the health of Gitaly' + task check: :gitlab_environment do + warn_user_is_not_gitlab + start_checking 'Gitaly' + + Gitlab::HealthChecks::GitalyCheck.readiness.each do |result| + print "#{result.labels[:shard]} ... " + + if result.success + puts 'OK'.color(:green) + else + puts "FAIL: #{result.message}".color(:red) + end + end + + finished_checking 'Gitaly' + end + end + namespace :sidekiq do desc "GitLab | Check the configuration of Sidekiq" task check: :gitlab_environment do -- cgit v1.2.1 From 408d08151a3db9f0feac4fa9aa8562f917d5629e Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Wed, 24 Oct 2018 09:47:12 +0200 Subject: Update translations in locale/gitlab.pot --- locale/gitlab.pot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/locale/gitlab.pot b/locale/gitlab.pot index bb18d4eccd8..767db59f5ef 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -2166,7 +2166,7 @@ msgstr "" msgid "Define a custom pattern with cron syntax" msgstr "" -msgid "DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes." +msgid "DelayedJobs|Are you sure you want to run %{jobName} immediately? Otherwise this job will run automatically after it's timer finishes." msgstr "" msgid "DelayedJobs|Are you sure you want to run %{job_name} immediately? This job will run automatically after it's timer finishes." -- cgit v1.2.1 From d520338ad4941c6cdfaca25fdcca9a087db12c83 Mon Sep 17 00:00:00 2001 From: Winnie Hellmann Date: Wed, 24 Oct 2018 10:00:58 +0200 Subject: Add scheduled_actions to JSON schema --- spec/fixtures/api/schemas/deployment.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/fixtures/api/schemas/deployment.json b/spec/fixtures/api/schemas/deployment.json index 44835386cfc..0828f113495 100644 --- a/spec/fixtures/api/schemas/deployment.json +++ b/spec/fixtures/api/schemas/deployment.json @@ -48,6 +48,10 @@ "manual_actions": { "type": "array", "items": { "$ref": "job/job.json" } + }, + "scheduled_actions": { + "type": "array", + "items": { "$ref": "job/job.json" } } }, "additionalProperties": false -- cgit v1.2.1 From 9e48cbf89d86e85868eb9a6496adb53d593dcacb Mon Sep 17 00:00:00 2001 From: James Edwards-Jones Date: Wed, 24 Oct 2018 21:11:34 +0100 Subject: EE render_if_exists for SSO badge in _member view --- app/views/shared/members/_member.html.haml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/shared/members/_member.html.haml b/app/views/shared/members/_member.html.haml index 2682d92fc56..b4b3f4a6b7e 100644 --- a/app/views/shared/members/_member.html.haml +++ b/app/views/shared/members/_member.html.haml @@ -14,6 +14,8 @@ = user_status(user) %span.cgray= user.to_reference + = render_if_exists 'shared/members/ee/sso_badge', member: member + - if user == current_user %span.badge.badge-success.prepend-left-5 It's you -- cgit v1.2.1 From 661fd213de41d06ebdbecb92f37668f0009c838d Mon Sep 17 00:00:00 2001 From: Chris Baumbauer Date: Wed, 24 Oct 2018 15:13:33 -0700 Subject: Update helm version 1.7.2 -> 2.11.0 --- app/models/clusters/platforms/kubernetes.rb | 6 ++++++ changelogs/unreleased/update-helm-version.yml | 4 ++++ lib/gitlab/kubernetes/helm.rb | 2 +- lib/gitlab/kubernetes/helm/base_command.rb | 2 +- lib/gitlab/kubernetes/helm/install_command.rb | 23 +++++++++++++++++++--- .../gitlab/kubernetes/helm/install_command_spec.rb | 4 ++++ .../shared_examples/helm_generated_script.rb | 4 ++-- 7 files changed, 38 insertions(+), 7 deletions(-) create mode 100644 changelogs/unreleased/update-helm-version.yml diff --git a/app/models/clusters/platforms/kubernetes.rb b/app/models/clusters/platforms/kubernetes.rb index e8e943872de..263b7d9d01e 100644 --- a/app/models/clusters/platforms/kubernetes.rb +++ b/app/models/clusters/platforms/kubernetes.rb @@ -25,6 +25,7 @@ module Clusters algorithm: 'aes-256-cbc' before_validation :enforce_namespace_to_lower_case + before_validation :enforce_ca_whitespace_trimming validates :namespace, allow_blank: true, @@ -191,6 +192,11 @@ module Clusters self.namespace = self.namespace&.downcase end + def enforce_ca_whitespace_trimming + self.ca_pem = self.ca_pem&.strip + self.token = self.token&.strip + end + def prevent_modification return unless managed? diff --git a/changelogs/unreleased/update-helm-version.yml b/changelogs/unreleased/update-helm-version.yml new file mode 100644 index 00000000000..092e8f9a9d6 --- /dev/null +++ b/changelogs/unreleased/update-helm-version.yml @@ -0,0 +1,4 @@ +--- +title: Update Helm version to 2.11.0 +author: Chris Baumbauer +type: changed diff --git a/lib/gitlab/kubernetes/helm.rb b/lib/gitlab/kubernetes/helm.rb index 4a1bdf34c3e..a53c2c9e5cb 100644 --- a/lib/gitlab/kubernetes/helm.rb +++ b/lib/gitlab/kubernetes/helm.rb @@ -1,7 +1,7 @@ module Gitlab module Kubernetes module Helm - HELM_VERSION = '2.7.2'.freeze + HELM_VERSION = '2.11.0'.freeze NAMESPACE = 'gitlab-managed-apps'.freeze SERVICE_ACCOUNT = 'tiller'.freeze CLUSTER_ROLE_BINDING = 'tiller-admin'.freeze diff --git a/lib/gitlab/kubernetes/helm/base_command.rb b/lib/gitlab/kubernetes/helm/base_command.rb index 6752f2cff43..74efe4bc8bb 100644 --- a/lib/gitlab/kubernetes/helm/base_command.rb +++ b/lib/gitlab/kubernetes/helm/base_command.rb @@ -14,7 +14,7 @@ module Gitlab ALPINE_VERSION=$(cat /etc/alpine-release | cut -d '.' -f 1,2) echo http://mirror.clarkson.edu/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories echo http://mirror1.hs-esslingen.de/pub/Mirrors/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories - apk add -U wget ca-certificates openssl >/dev/null + apk add -U wget ca-certificates openssl git >/dev/null wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v#{Gitlab::Kubernetes::Helm::HELM_VERSION}-linux-amd64.tar.gz | tar zxC /tmp >/dev/null mv /tmp/linux-amd64/helm /usr/bin/ HEREDOC diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb index 1be7924d6ac..e7907c033c0 100644 --- a/lib/gitlab/kubernetes/helm/install_command.rb +++ b/lib/gitlab/kubernetes/helm/install_command.rb @@ -4,21 +4,23 @@ module Gitlab class InstallCommand include BaseCommand - attr_reader :name, :files, :chart, :version, :repository + attr_reader :name, :files, :chart, :version, :repository, :setargs - def initialize(name:, chart:, files:, rbac:, version: nil, repository: nil) + def initialize(name:, chart:, files:, rbac:, version: nil, repository: nil, setargs: nil) @name = name @chart = chart @version = version @rbac = rbac @files = files @repository = repository + @setargs = setargs end def generate_script super + [ init_command, repository_command, + repository_update_command, script_command ].compact.join("\n") end @@ -37,6 +39,10 @@ module Gitlab ['helm', 'repo', 'add', name, repository].shelljoin if repository end + def repository_update_command + 'helm repo update >/dev/null' if repository + end + def script_command command = ['helm', 'install', chart] + install_command_flags @@ -47,13 +53,15 @@ module Gitlab name_flag = ['--name', name] namespace_flag = ['--namespace', Gitlab::Kubernetes::Helm::NAMESPACE] value_flag = ['-f', "/data/helm/#{name}/config/values.yaml"] + args_flag = optional_install_set_args_flag name_flag + optional_tls_flags + optional_version_flag + optional_rbac_create_flag + namespace_flag + - value_flag + value_flag + + args_flag end def optional_rbac_create_flag @@ -64,6 +72,15 @@ module Gitlab %w[--set rbac.create=true,rbac.enabled=true] end + def optional_install_set_args_flag + return [] unless setargs + + args = [] + setargs.each do |s| + args.push("--set", s) + end + end + def optional_version_flag return [] unless version diff --git a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb index f28941ce58f..bbe7cbe05c5 100644 --- a/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb +++ b/spec/lib/gitlab/kubernetes/helm/install_command_spec.rb @@ -24,6 +24,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do <<~EOS helm init --client-only >/dev/null helm repo add app-name https://repository.example.com + helm repo update >/dev/null #{helm_install_comand} EOS end @@ -51,6 +52,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do <<~EOS helm init --client-only >/dev/null helm repo add app-name https://repository.example.com + helm repo update >/dev/null #{helm_install_command} EOS end @@ -107,6 +109,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do <<~EOS helm init --client-only >/dev/null helm repo add app-name https://repository.example.com + helm repo update >/dev/null #{helm_install_command} EOS end @@ -131,6 +134,7 @@ describe Gitlab::Kubernetes::Helm::InstallCommand do <<~EOS helm init --client-only >/dev/null helm repo add app-name https://repository.example.com + helm repo update >/dev/null #{helm_install_command} EOS end diff --git a/spec/support/shared_examples/helm_generated_script.rb b/spec/support/shared_examples/helm_generated_script.rb index ef9bb7f5533..a1f92c64d38 100644 --- a/spec/support/shared_examples/helm_generated_script.rb +++ b/spec/support/shared_examples/helm_generated_script.rb @@ -6,8 +6,8 @@ shared_examples 'helm commands' do ALPINE_VERSION=$(cat /etc/alpine-release | cut -d '.' -f 1,2) echo http://mirror.clarkson.edu/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories echo http://mirror1.hs-esslingen.de/pub/Mirrors/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories - apk add -U wget ca-certificates openssl >/dev/null - wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v2.7.2-linux-amd64.tar.gz | tar zxC /tmp >/dev/null + apk add -U wget ca-certificates openssl git >/dev/null + wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v2.11.0-linux-amd64.tar.gz | tar zxC /tmp >/dev/null mv /tmp/linux-amd64/helm /usr/bin/ EOS end -- cgit v1.2.1 From b5155b90ee233e2824c168fbb06b3ce5d3aeb194 Mon Sep 17 00:00:00 2001 From: Chris Baumbauer Date: Wed, 24 Oct 2018 22:38:44 -0700 Subject: Knative support --- app/assets/images/cluster_app_logos/knative.png | Bin 0 -> 11259 bytes app/assets/javascripts/clusters/clusters_bundle.js | 2 + .../clusters/components/applications.vue | 58 ++++++++++++++++++++- .../clusters/services/clusters_service.js | 1 + .../javascripts/clusters/stores/clusters_store.js | 8 +++ .../projects/clusters/applications_controller.rb | 1 + app/models/clusters/applications/knative.rb | 52 ++++++++++++++++++ app/models/clusters/cluster.rb | 7 ++- app/serializers/cluster_application_entity.rb | 1 + .../clusters/applications/create_service.rb | 7 ++- app/views/projects/clusters/show.html.haml | 1 + changelogs/unreleased/update-helm-version.yml | 4 +- .../20180912111628_add_knative_application.rb | 42 +++++++++++++++ db/schema.rb | 12 +++++ doc/user/project/clusters/index.md | 13 ++++- lib/gitlab/kubernetes/helm/install_command.rb | 1 + locale/gitlab.pot | 9 ++++ spec/factories/clusters/applications/helm.rb | 4 ++ .../clusters/components/applications_spec.js | 12 +++++ spec/javascripts/clusters/services/mock_data.js | 11 ++++ .../clusters/stores/clusters_store_spec.js | 8 +++ spec/models/clusters/cluster_spec.rb | 3 +- .../clusters/gcp/finalize_creation_service_spec.rb | 4 +- vendor/knative/values.yaml | 1 + 24 files changed, 252 insertions(+), 10 deletions(-) create mode 100644 app/assets/images/cluster_app_logos/knative.png create mode 100644 app/models/clusters/applications/knative.rb create mode 100644 db/migrate/20180912111628_add_knative_application.rb create mode 100644 vendor/knative/values.yaml diff --git a/app/assets/images/cluster_app_logos/knative.png b/app/assets/images/cluster_app_logos/knative.png new file mode 100644 index 00000000000..0a2510c8549 Binary files /dev/null and b/app/assets/images/cluster_app_logos/knative.png differ diff --git a/app/assets/javascripts/clusters/clusters_bundle.js b/app/assets/javascripts/clusters/clusters_bundle.js index ebf76af5966..02dfe1c7d6f 100644 --- a/app/assets/javascripts/clusters/clusters_bundle.js +++ b/app/assets/javascripts/clusters/clusters_bundle.js @@ -28,6 +28,7 @@ export default class Clusters { installIngressPath, installRunnerPath, installJupyterPath, + installKnativePath, installPrometheusPath, managePrometheusPath, clusterStatus, @@ -49,6 +50,7 @@ export default class Clusters { installRunnerEndpoint: installRunnerPath, installPrometheusEndpoint: installPrometheusPath, installJupyterEndpoint: installJupyterPath, + installKnativeEndpoint: installKnativePath, }); this.installApplication = this.installApplication.bind(this); diff --git a/app/assets/javascripts/clusters/components/applications.vue b/app/assets/javascripts/clusters/components/applications.vue index 6e7b5eb5526..183d265851c 100644 --- a/app/assets/javascripts/clusters/components/applications.vue +++ b/app/assets/javascripts/clusters/components/applications.vue @@ -7,6 +7,7 @@ import helmLogo from 'images/cluster_app_logos/helm.png'; import jeagerLogo from 'images/cluster_app_logos/jeager.png'; import jupyterhubLogo from 'images/cluster_app_logos/jupyterhub.png'; import kubernetesLogo from 'images/cluster_app_logos/kubernetes.png'; +import knativeLogo from 'images/cluster_app_logos/knative.png'; import meltanoLogo from 'images/cluster_app_logos/meltano.png'; import prometheusLogo from 'images/cluster_app_logos/prometheus.png'; import { s__, sprintf } from '../../locale'; @@ -53,6 +54,7 @@ export default { jeagerLogo, jupyterhubLogo, kubernetesLogo, + knativeLogo, meltanoLogo, prometheusLogo, }), @@ -136,6 +138,9 @@ export default { jupyterHostname() { return this.applications.jupyter.hostname; }, + knativeInstalled() { + return this.applications.knative.status === APPLICATION_STATUS.INSTALLED; + }, }, created() { this.helmInstallIllustration = helmInstallIllustration; @@ -321,7 +326,6 @@ export default { :request-reason="applications.jupyter.requestReason" :install-application-request-params="{ hostname: applications.jupyter.hostname }" :disabled="!helmInstalled" - class="hide-bottom-border rounded-bottom" title-link="https://jupyterhub.readthedocs.io/en/stable/" >
@@ -371,6 +375,58 @@ export default {
+ +
+

+ {{ s__(`ClusterIntegration||A Knative build extends Kubernetes + and utilizes existing Kubernetes primitives to provide you with + the ability to run on-cluster container builds from source. + For example, you can write a build that uses Kubernetes-native + resources to obtain your source code from a repository, + build it into container a image, and then run that image.`) }} +

+ + + +
+
diff --git a/app/assets/javascripts/clusters/services/clusters_service.js b/app/assets/javascripts/clusters/services/clusters_service.js index a7d82292ba9..da562b09ee5 100644 --- a/app/assets/javascripts/clusters/services/clusters_service.js +++ b/app/assets/javascripts/clusters/services/clusters_service.js @@ -9,6 +9,7 @@ export default class ClusterService { runner: this.options.installRunnerEndpoint, prometheus: this.options.installPrometheusEndpoint, jupyter: this.options.installJupyterEndpoint, + knative: this.options.installKnativeEndpoint, }; } diff --git a/app/assets/javascripts/clusters/stores/clusters_store.js b/app/assets/javascripts/clusters/stores/clusters_store.js index d90db7b103c..c54a49eedd0 100644 --- a/app/assets/javascripts/clusters/stores/clusters_store.js +++ b/app/assets/javascripts/clusters/stores/clusters_store.js @@ -46,6 +46,14 @@ export default class ClusterStore { requestReason: null, hostname: null, }, + knative: { + title: s__('ClusterIntegration|Knative'), + status: null, + statusReason: null, + requestStatus: null, + requestReason: null, + domainname: '' + }, }, }; } diff --git a/app/controllers/projects/clusters/applications_controller.rb b/app/controllers/projects/clusters/applications_controller.rb index bcea96bce94..2e45e47b55d 100644 --- a/app/controllers/projects/clusters/applications_controller.rb +++ b/app/controllers/projects/clusters/applications_controller.rb @@ -25,5 +25,6 @@ class Projects::Clusters::ApplicationsController < Projects::ApplicationControll def create_cluster_application_params params.permit(:application, :hostname) + params.permit(:application, :domainname) end end diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb new file mode 100644 index 00000000000..be196331be5 --- /dev/null +++ b/app/models/clusters/applications/knative.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true + +module Clusters + module Applications + class Knative < ActiveRecord::Base + VERSION = '0.1.2'.freeze + REPOSITORY = 'https://storage.googleapis.com/triggermesh-charts'.freeze + + self.table_name = 'clusters_applications_knative' + + include ::Clusters::Concerns::ApplicationCore + include ::Clusters::Concerns::ApplicationStatus + include ::Clusters::Concerns::ApplicationVersion + include ::Clusters::Concerns::ApplicationData + include AfterCommitQueue + + default_value_for :version, VERSION + default_value_for :domainname, '' + + def set_initial_status + return unless not_installable? + + self.status = 'installable' if cluster&.platform_kubernetes_active? + end + + def chart + 'knative/knative' + end + + def install_command + args = [] + if !domainname.nil? && !domainname.eql?('') + args = ["domain=" + domainname] + end + + Gitlab::Kubernetes::Helm::InstallCommand.new( + name: name, + version: VERSION, + rbac: cluster.platform_kubernetes_rbac?, + chart: chart, + files: files, + repository: REPOSITORY, + setargs: args + ) + end + + def client + cluster&.platform_kubernetes&.kubeclient&.core_client + end + end + end +end diff --git a/app/models/clusters/cluster.rb b/app/models/clusters/cluster.rb index 95efecfc41d..9909ff355e5 100644 --- a/app/models/clusters/cluster.rb +++ b/app/models/clusters/cluster.rb @@ -11,7 +11,8 @@ module Clusters Applications::Ingress.application_name => Applications::Ingress, Applications::Prometheus.application_name => Applications::Prometheus, Applications::Runner.application_name => Applications::Runner, - Applications::Jupyter.application_name => Applications::Jupyter + Applications::Jupyter.application_name => Applications::Jupyter, + Applications::Knative.application_name => Applications::Knative }.freeze DEFAULT_ENVIRONMENT = '*'.freeze @@ -30,6 +31,7 @@ module Clusters has_one :application_prometheus, class_name: 'Clusters::Applications::Prometheus' has_one :application_runner, class_name: 'Clusters::Applications::Runner' has_one :application_jupyter, class_name: 'Clusters::Applications::Jupyter' + has_one :application_knative, class_name: 'Clusters::Applications::Knative' has_many :kubernetes_namespaces has_one :kubernetes_namespace, -> { order(id: :desc) }, class_name: 'Clusters::KubernetesNamespace' @@ -85,7 +87,8 @@ module Clusters application_ingress || build_application_ingress, application_prometheus || build_application_prometheus, application_runner || build_application_runner, - application_jupyter || build_application_jupyter + application_jupyter || build_application_jupyter, + application_knative || build_application_knative ] end diff --git a/app/serializers/cluster_application_entity.rb b/app/serializers/cluster_application_entity.rb index 2bd17e58086..d2f3e6ad130 100644 --- a/app/serializers/cluster_application_entity.rb +++ b/app/serializers/cluster_application_entity.rb @@ -6,4 +6,5 @@ class ClusterApplicationEntity < Grape::Entity expose :status_reason expose :external_ip, if: -> (e, _) { e.respond_to?(:external_ip) } expose :hostname, if: -> (e, _) { e.respond_to?(:hostname) } + expose :domainname, if: -> (e, _) { e.respond_to?(:domainname) } end diff --git a/app/services/clusters/applications/create_service.rb b/app/services/clusters/applications/create_service.rb index 55f917798de..50107578bd5 100644 --- a/app/services/clusters/applications/create_service.rb +++ b/app/services/clusters/applications/create_service.rb @@ -19,6 +19,10 @@ module Clusters application.hostname = params[:hostname] end + if application.has_attribute?(:domainname) + application.domainname = params[:domainname] + end + if application.respond_to?(:oauth_application) application.oauth_application = create_oauth_application(application, request) end @@ -45,7 +49,8 @@ module Clusters "ingress" => -> (cluster) { cluster.application_ingress || cluster.build_application_ingress }, "prometheus" => -> (cluster) { cluster.application_prometheus || cluster.build_application_prometheus }, "runner" => -> (cluster) { cluster.application_runner || cluster.build_application_runner }, - "jupyter" => -> (cluster) { cluster.application_jupyter || cluster.build_application_jupyter } + "jupyter" => -> (cluster) { cluster.application_jupyter || cluster.build_application_jupyter }, + "knative" => -> (cluster) { cluster.application_knative || cluster.build_application_knative } } end diff --git a/app/views/projects/clusters/show.html.haml b/app/views/projects/clusters/show.html.haml index eddd3613c5f..c79d3f67706 100644 --- a/app/views/projects/clusters/show.html.haml +++ b/app/views/projects/clusters/show.html.haml @@ -12,6 +12,7 @@ install_prometheus_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :prometheus), install_runner_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :runner), install_jupyter_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :jupyter), + install_knative_path: install_applications_namespace_project_cluster_path(@cluster.project.namespace, @cluster.project, @cluster, :knative), toggle_status: @cluster.enabled? ? 'true': 'false', cluster_status: @cluster.status_name, cluster_status_reason: @cluster.status_reason, diff --git a/changelogs/unreleased/update-helm-version.yml b/changelogs/unreleased/update-helm-version.yml index 092e8f9a9d6..37ba2aeb64c 100644 --- a/changelogs/unreleased/update-helm-version.yml +++ b/changelogs/unreleased/update-helm-version.yml @@ -1,4 +1,4 @@ --- -title: Update Helm version to 2.11.0 +title: Update Helm version to 2.11.0 and introduce Knative support author: Chris Baumbauer -type: changed +type: added diff --git a/db/migrate/20180912111628_add_knative_application.rb b/db/migrate/20180912111628_add_knative_application.rb new file mode 100644 index 00000000000..aa3ddf84b1c --- /dev/null +++ b/db/migrate/20180912111628_add_knative_application.rb @@ -0,0 +1,42 @@ +# frozen_string_literal: true + +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class AddKnativeApplication < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # Set this constant to true if this migration requires downtime. + DOWNTIME = false + + # When a migration requires downtime you **must** uncomment the following + # constant and define a short and easy to understand explanation as to why the + # migration requires downtime. + # DOWNTIME_REASON = '' + + # When using the methods "add_concurrent_index", "remove_concurrent_index" or + # "add_column_with_default" you must disable the use of transactions + # as these methods can not run in an existing transaction. + # When using "add_concurrent_index" or "remove_concurrent_index" methods make sure + # that either of them is the _only_ method called in the migration, + # any other changes should go in a separate migration. + # This ensures that upon failure _only_ the index creation or removing fails + # and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + + def change + create_table "clusters_applications_knative" do |t| + t.references :cluster, null: false, unique: true, foreign_key: { on_delete: :cascade } + + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.integer "status", null: false + t.string "version", null: false + t.string "domainname", null: false + t.text "status_reason" + end + end +end diff --git a/db/schema.rb b/db/schema.rb index ddfccbba678..7bea6db5958 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -668,6 +668,16 @@ ActiveRecord::Schema.define(version: 20181013005024) do t.text "status_reason" end + create_table "clusters_applications_knative", force: :cascade do |t| + t.integer "cluster_id", null: false + t.datetime_with_timezone "created_at", null: false + t.datetime_with_timezone "updated_at", null: false + t.integer "status", null: false + t.string "version", null: false + t.string "domainname", null: false + t.text "status_reason" + end + create_table "clusters_applications_prometheus", force: :cascade do |t| t.integer "cluster_id", null: false t.integer "status", null: false @@ -1805,6 +1815,7 @@ ActiveRecord::Schema.define(version: 20181013005024) do end add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree + add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree create_table "releases", force: :cascade do |t| @@ -2349,6 +2360,7 @@ ActiveRecord::Schema.define(version: 20181013005024) do add_foreign_key "clusters_applications_ingress", "clusters", name: "fk_753a7b41c1", on_delete: :cascade add_foreign_key "clusters_applications_jupyter", "clusters", on_delete: :cascade add_foreign_key "clusters_applications_jupyter", "oauth_applications", on_delete: :nullify + add_foreign_key "clusters_applications_knative", "clusters", on_delete: :cascade add_foreign_key "clusters_applications_prometheus", "clusters", name: "fk_557e773639", on_delete: :cascade add_foreign_key "clusters_applications_runners", "ci_runners", column: "runner_id", name: "fk_02de2ded36", on_delete: :nullify add_foreign_key "clusters_applications_runners", "clusters", on_delete: :cascade diff --git a/doc/user/project/clusters/index.md b/doc/user/project/clusters/index.md index 48004471f0a..852ce807e1d 100644 --- a/doc/user/project/clusters/index.md +++ b/doc/user/project/clusters/index.md @@ -203,7 +203,7 @@ added directly to your configured cluster. Those applications are needed for [Review Apps](../../../ci/review_apps/index.md) and [deployments](../../../ci/environments.md). NOTE: **Note:** -The applications will be installed in a dedicated namespace called +With the exception of Knative, the applications will be installed in a dedicated namespace called `gitlab-managed-apps`. In case you have added an existing Kubernetes cluster with Tiller already installed, you should be careful as GitLab cannot detect it. By installing it via the applications will result into having it @@ -216,6 +216,7 @@ twice, which can lead to confusion during deployments. | [Prometheus](https://prometheus.io/docs/introduction/overview/) | 10.4+ | Prometheus is an open-source monitoring and alerting system useful to supervise your deployed applications. | [stable/prometheus](https://github.com/helm/charts/tree/master/stable/prometheus) | | [GitLab Runner](https://docs.gitlab.com/runner/) | 10.6+ | GitLab Runner is the open source project that is used to run your jobs and send the results back to GitLab. It is used in conjunction with [GitLab CI/CD](https://about.gitlab.com/features/gitlab-ci-cd/), the open-source continuous integration service included with GitLab that coordinates the jobs. When installing the GitLab Runner via the applications, it will run in **privileged mode** by default. Make sure you read the [security implications](#security-implications) before doing so. | [runner/gitlab-runner](https://gitlab.com/charts/gitlab-runner) | | [JupyterHub](http://jupyter.org/) | 11.0+ | [JupyterHub](https://jupyterhub.readthedocs.io/en/stable/) is a multi-user service for managing notebooks across a team. [Jupyter Notebooks](https://jupyter-notebook.readthedocs.io/en/latest/) provide a web-based interactive programming environment used for data analysis, visualization, and machine learning. We use [this](https://gitlab.com/gitlab-org/jupyterhub-user-image/blob/master/Dockerfile) custom Jupyter image that installs additional useful packages on top of the base Jupyter. You will also see ready-to-use DevOps Runbooks built with Nurtch's [Rubix library](https://github.com/amit1rrr/rubix). More information on creating executable runbooks can be found at [Nurtch Documentation](http://docs.nurtch.com/en/latest). **Note**: Authentication will be enabled for any user of the GitLab server via OAuth2. HTTPS will be supported in a future release. | [jupyter/jupyterhub](https://jupyterhub.github.io/helm-chart/) | +| [Knative](https://cloud.google.com/knative) | 0.1.2 | Knative provides a platform to create, deploy, and manage serverless workloads from a Kubernetes cluster. It is used in conjunction with, and includes [Istio](https://istio.io) to provide an external IP address for all programs hosted by Knative. You will be prompted to enter a wildcard domain where your applications will be available as. Configure your DNS server to use the external IP address for that domain. For any application created and installed, they will be accessible as ... **Note**: This will require your kubernetes cluster to have RBAC enabled. | [knative/knative](https://storage.googleapis.com/triggermesh-charts) ## Getting the external IP address @@ -224,6 +225,10 @@ You need a load balancer installed in your cluster in order to obtain the external IP address with the following procedure. It can be deployed using the [**Ingress** application](#installing-applications). +NOTE: **Note:** +Knative will include its own load balancer in the form of [Istio](https://istio.io). +At this time, to determine the external IP address, you will need to follow the manual approach. + In order to publish your web application, you first need to find the external IP address associated to your load balancer. @@ -254,6 +259,12 @@ run the following command: kubectl get svc --namespace=gitlab-managed-apps ingress-nginx-ingress-controller -o jsonpath='{.status.loadBalancer.ingress[0].ip} ' ``` +NOTE: **Note:** +For Istio/Knative, the command will be different: +```bash +kubectl get svc --namespace=istio-system knative-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip} ' +``` + Otherwise, you can list the IP addresses of all load balancers: ```bash diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb index e7907c033c0..904bcd4470d 100644 --- a/lib/gitlab/kubernetes/helm/install_command.rb +++ b/lib/gitlab/kubernetes/helm/install_command.rb @@ -79,6 +79,7 @@ module Gitlab setargs.each do |s| args.push("--set", s) end + args end def optional_version_flag diff --git a/locale/gitlab.pot b/locale/gitlab.pot index 40d45d0dee9..e7bea1ce2cb 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -1493,6 +1493,12 @@ msgstr "" msgid "ClusterIntegration|JupyterHub, a multi-user Hub, spawns, manages, and proxies multiple instances of the single-user Jupyter notebook server. JupyterHub can be used to serve notebooks to a class of students, a corporate data science group, or a scientific research group." msgstr "" +msgid "ClusterIntegration|Knative" +msgstr "" + +msgid "ClusterIntegration|Knative Domain Name:" +msgstr "" + msgid "ClusterIntegration|Kubernetes cluster" msgstr "" @@ -1709,6 +1715,9 @@ msgstr "" msgid "ClusterIntegration|sign up" msgstr "" +msgid "ClusterIntegration||A Knative build extends Kubernetes and utilizes existing Kubernetes primitives to provide you with the ability to run on-cluster container builds from source. For example, you can write a build that uses Kubernetes-native resources to obtain your source code from a repository, build it into container a image, and then run that image." +msgstr "" + msgid "Cohorts" msgstr "" diff --git a/spec/factories/clusters/applications/helm.rb b/spec/factories/clusters/applications/helm.rb index 3c9ca22a051..3fe088d47cc 100644 --- a/spec/factories/clusters/applications/helm.rb +++ b/spec/factories/clusters/applications/helm.rb @@ -57,6 +57,10 @@ FactoryBot.define do cluster factory: %i(cluster with_installed_helm provided_by_gcp) end + factory :clusters_applications_knative, class: Clusters::Applications::Knative do + cluster factory: %i(cluster with_installed_helm provided_by_gcp) + end + factory :clusters_applications_jupyter, class: Clusters::Applications::Jupyter do oauth_application factory: :oauth_application cluster factory: %i(cluster with_installed_helm provided_by_gcp project) diff --git a/spec/javascripts/clusters/components/applications_spec.js b/spec/javascripts/clusters/components/applications_spec.js index a70138c7eee..3946e1bccf9 100644 --- a/spec/javascripts/clusters/components/applications_spec.js +++ b/spec/javascripts/clusters/components/applications_spec.js @@ -23,6 +23,7 @@ describe('Applications', () => { runner: { title: 'GitLab Runner' }, prometheus: { title: 'Prometheus' }, jupyter: { title: 'JupyterHub' }, + knative: { title: 'Knative' }, }, }); }); @@ -46,6 +47,10 @@ describe('Applications', () => { it('renders a row for Jupyter', () => { expect(vm.$el.querySelector('.js-cluster-application-row-jupyter')).not.toBe(null); }); + + it('renders a row for Knative', () => { + expect(vm.$el.querySelector('.js-cluster-application-row-knative')).not.toBe(null); + }); }); describe('Ingress application', () => { @@ -63,6 +68,7 @@ describe('Applications', () => { runner: { title: 'GitLab Runner' }, prometheus: { title: 'Prometheus' }, jupyter: { title: 'JupyterHub', hostname: '' }, + knative: { title: 'Knative', domainname: '' }, }, }); @@ -86,6 +92,7 @@ describe('Applications', () => { runner: { title: 'GitLab Runner' }, prometheus: { title: 'Prometheus' }, jupyter: { title: 'JupyterHub', hostname: '' }, + knative: { title: 'Knative', domainname: '' }, }, }); @@ -105,6 +112,7 @@ describe('Applications', () => { runner: { title: 'GitLab Runner' }, prometheus: { title: 'Prometheus' }, jupyter: { title: 'JupyterHub', hostname: '' }, + knative: { title: 'Knative', domainname: '' }, }, }); @@ -123,6 +131,7 @@ describe('Applications', () => { runner: { title: 'GitLab Runner' }, prometheus: { title: 'Prometheus' }, jupyter: { title: 'JupyterHub', hostname: '', status: 'installable' }, + knative: { title: 'Knative', domainname: '', status: 'installable' }, }, }); @@ -139,6 +148,7 @@ describe('Applications', () => { runner: { title: 'GitLab Runner' }, prometheus: { title: 'Prometheus' }, jupyter: { title: 'JupyterHub', hostname: '', status: 'installable' }, + knative: { title: 'Knative', domainname: '', status: 'installable' }, }, }); @@ -155,6 +165,7 @@ describe('Applications', () => { runner: { title: 'GitLab Runner' }, prometheus: { title: 'Prometheus' }, jupyter: { title: 'JupyterHub', status: 'installed', hostname: '' }, + knative: { title: 'Knative', status: 'installed', domainname: '' }, }, }); @@ -171,6 +182,7 @@ describe('Applications', () => { runner: { title: 'GitLab Runner' }, prometheus: { title: 'Prometheus' }, jupyter: { title: 'JupyterHub', status: 'not_installable' }, + knative: { title: 'Knative' }, }, }); }); diff --git a/spec/javascripts/clusters/services/mock_data.js b/spec/javascripts/clusters/services/mock_data.js index 4e6ad11cd92..73abf6504c0 100644 --- a/spec/javascripts/clusters/services/mock_data.js +++ b/spec/javascripts/clusters/services/mock_data.js @@ -33,6 +33,11 @@ const CLUSTERS_MOCK_DATA = { status: APPLICATION_STATUS.INSTALLING, status_reason: 'Cannot connect', }, + { + name: 'knative', + status: APPLICATION_STATUS.INSTALLING, + status_reason: 'Cannot connect', + }, ], }, }, @@ -67,6 +72,11 @@ const CLUSTERS_MOCK_DATA = { status: APPLICATION_STATUS.INSTALLABLE, status_reason: 'Cannot connect', }, + { + name: 'knative', + status: APPLICATION_STATUS.INSTALLABLE, + status_reason: 'Cannot connect', + }, ], }, }, @@ -77,6 +87,7 @@ const CLUSTERS_MOCK_DATA = { '/gitlab-org/gitlab-shell/clusters/1/applications/runner': {}, '/gitlab-org/gitlab-shell/clusters/1/applications/prometheus': {}, '/gitlab-org/gitlab-shell/clusters/1/applications/jupyter': {}, + '/gitlab-org/gitlab-shell/clusters/1/applications/knative': {}, }, }; diff --git a/spec/javascripts/clusters/stores/clusters_store_spec.js b/spec/javascripts/clusters/stores/clusters_store_spec.js index e0f55a12fca..3757d83f01e 100644 --- a/spec/javascripts/clusters/stores/clusters_store_spec.js +++ b/spec/javascripts/clusters/stores/clusters_store_spec.js @@ -100,6 +100,14 @@ describe('Clusters Store', () => { requestReason: null, hostname: '', }, + knative: { + title: 'Knative', + status: mockResponseData.applications[5].status, + statusReason: mockResponseData.applications[5].status_reason, + requestStatus: null, + requestReason: null, + domainname: '', + }, }, }); }); diff --git a/spec/models/clusters/cluster_spec.rb b/spec/models/clusters/cluster_spec.rb index f5c4b0b66ae..eed298b433c 100644 --- a/spec/models/clusters/cluster_spec.rb +++ b/spec/models/clusters/cluster_spec.rb @@ -246,9 +246,10 @@ describe Clusters::Cluster do let!(:prometheus) { create(:clusters_applications_prometheus, cluster: cluster) } let!(:runner) { create(:clusters_applications_runner, cluster: cluster) } let!(:jupyter) { create(:clusters_applications_jupyter, cluster: cluster) } + let!(:knative) { create(:clusters_applications_knative, cluster: cluster) } it 'returns a list of created applications' do - is_expected.to contain_exactly(helm, ingress, prometheus, runner, jupyter) + is_expected.to contain_exactly(helm, ingress, prometheus, runner, jupyter, knative) end end end diff --git a/spec/services/clusters/gcp/finalize_creation_service_spec.rb b/spec/services/clusters/gcp/finalize_creation_service_spec.rb index 0f484222228..02983bea072 100644 --- a/spec/services/clusters/gcp/finalize_creation_service_spec.rb +++ b/spec/services/clusters/gcp/finalize_creation_service_spec.rb @@ -80,7 +80,7 @@ describe Clusters::Gcp::FinalizeCreationService do expect(provider.endpoint).to eq(endpoint) expect(platform.api_url).to eq(api_url) - expect(platform.ca_cert).to eq(Base64.decode64(load_sample_cert)) + expect(platform.ca_cert).to eq(Base64.decode64(load_sample_cert).chomp) expect(platform.username).to eq(username) expect(platform.password).to eq(password) expect(platform).to be_abac @@ -110,7 +110,7 @@ describe Clusters::Gcp::FinalizeCreationService do expect(provider.endpoint).to eq(endpoint) expect(platform.api_url).to eq(api_url) - expect(platform.ca_cert).to eq(Base64.decode64(load_sample_cert)) + expect(platform.ca_cert).to eq(Base64.decode64(load_sample_cert).chomp) expect(platform.username).to eq(username) expect(platform.password).to eq(password) expect(platform).to be_rbac diff --git a/vendor/knative/values.yaml b/vendor/knative/values.yaml new file mode 100644 index 00000000000..b3472660fb0 --- /dev/null +++ b/vendor/knative/values.yaml @@ -0,0 +1 @@ +domain: example.com -- cgit v1.2.1 From 98692e39a53c85b98a0695545d8951955d214483 Mon Sep 17 00:00:00 2001 From: Chris Baumbauer Date: Wed, 24 Oct 2018 23:30:13 -0700 Subject: Resolve error with duplicate index_redirect_routes_on_path_text_pattern_ops --- db/schema.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index 7bea6db5958..f695e70339d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1815,7 +1815,6 @@ ActiveRecord::Schema.define(version: 20181013005024) do end add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path", unique: true, using: :btree - add_index "redirect_routes", ["path"], name: "index_redirect_routes_on_path_text_pattern_ops", using: :btree, opclasses: {"path"=>"varchar_pattern_ops"} add_index "redirect_routes", ["source_type", "source_id"], name: "index_redirect_routes_on_source_type_and_source_id", using: :btree create_table "releases", force: :cascade do |t| -- cgit v1.2.1 From 50a708f50715c01e8bcbb4b930813d26475d1049 Mon Sep 17 00:00:00 2001 From: Chris Baumbauer Date: Thu, 25 Oct 2018 00:06:24 -0700 Subject: Resolve error with missing attribute in spec fixture --- spec/fixtures/api/schemas/cluster_status.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/fixtures/api/schemas/cluster_status.json b/spec/fixtures/api/schemas/cluster_status.json index ccef17a6615..bc59198bd4d 100644 --- a/spec/fixtures/api/schemas/cluster_status.json +++ b/spec/fixtures/api/schemas/cluster_status.json @@ -32,7 +32,8 @@ }, "status_reason": { "type": ["string", "null"] }, "external_ip": { "type": ["string", "null"] }, - "hostname": { "type": ["string", "null"] } + "hostname": { "type": ["string", "null"] }, + "domainname": { "type": ["string", "null"] } }, "required" : [ "name", "status" ] } -- cgit v1.2.1 From 1c7c1400165fff3c6648a44051620c72fdcf11a7 Mon Sep 17 00:00:00 2001 From: "Balasankar \"Balu\" C" Date: Thu, 25 Oct 2018 21:23:17 +0530 Subject: Remove asset_sync gem and related code Reverting https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/15734 . We are not using asset sync currently. --- Gemfile | 3 --- Gemfile.lock | 6 ------ Gemfile.rails5.lock | 6 ------ changelogs/unreleased/remove-asset-sync.yml | 5 +++++ config/initializers/asset_sync.rb | 31 ----------------------------- 5 files changed, 5 insertions(+), 46 deletions(-) create mode 100644 changelogs/unreleased/remove-asset-sync.yml delete mode 100644 config/initializers/asset_sync.rb diff --git a/Gemfile b/Gemfile index c442ed9065e..b03f7153013 100644 --- a/Gemfile +++ b/Gemfile @@ -429,6 +429,3 @@ gem 'flipper-active_support_cache_store', '~> 0.13.0' # Structured logging gem 'lograge', '~> 0.5' gem 'grape_logging', '~> 1.7' - -# Asset synchronization -gem 'asset_sync', '~> 2.4' diff --git a/Gemfile.lock b/Gemfile.lock index bf16bef4f32..6dcf0f83848 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -58,11 +58,6 @@ GEM asciidoctor (1.5.6.2) asciidoctor-plantuml (0.0.8) asciidoctor (~> 1.5) - asset_sync (2.4.0) - activemodel (>= 4.1.0) - fog-core - mime-types (>= 2.99) - unf ast (2.4.0) atomic (1.1.99) attr_encrypted (3.1.0) @@ -936,7 +931,6 @@ DEPENDENCIES asana (~> 0.6.0) asciidoctor (~> 1.5.6) asciidoctor-plantuml (= 0.0.8) - asset_sync (~> 2.4) attr_encrypted (~> 3.1.0) awesome_print babosa (~> 1.0.2) diff --git a/Gemfile.rails5.lock b/Gemfile.rails5.lock index 81547303ed2..0389da5d8ff 100644 --- a/Gemfile.rails5.lock +++ b/Gemfile.rails5.lock @@ -61,11 +61,6 @@ GEM asciidoctor (1.5.6.2) asciidoctor-plantuml (0.0.8) asciidoctor (~> 1.5) - asset_sync (2.4.0) - activemodel (>= 4.1.0) - fog-core - mime-types (>= 2.99) - unf ast (2.4.0) atomic (1.1.99) attr_encrypted (3.1.0) @@ -945,7 +940,6 @@ DEPENDENCIES asana (~> 0.6.0) asciidoctor (~> 1.5.6) asciidoctor-plantuml (= 0.0.8) - asset_sync (~> 2.4) attr_encrypted (~> 3.1.0) awesome_print babosa (~> 1.0.2) diff --git a/changelogs/unreleased/remove-asset-sync.yml b/changelogs/unreleased/remove-asset-sync.yml new file mode 100644 index 00000000000..ddb82212975 --- /dev/null +++ b/changelogs/unreleased/remove-asset-sync.yml @@ -0,0 +1,5 @@ +--- +title: Remove asset_sync gem from Gemfile and related code from codebase +merge_request: 22610 +author: +type: other diff --git a/config/initializers/asset_sync.rb b/config/initializers/asset_sync.rb deleted file mode 100644 index 7f3934853fa..00000000000 --- a/config/initializers/asset_sync.rb +++ /dev/null @@ -1,31 +0,0 @@ -AssetSync.configure do |config| - # Disable the asset_sync gem by default. If it is enabled, but not configured, - # asset_sync will cause the build to fail. - config.enabled = if ENV.has_key?('ASSET_SYNC_ENABLED') - ENV['ASSET_SYNC_ENABLED'] == 'true' - else - false - end - - # Pulled from https://github.com/AssetSync/asset_sync/blob/v2.2.0/lib/asset_sync/engine.rb#L15-L40 - # This allows us to disable asset_sync by default and configure through environment variables - # Updates to asset_sync gem should be checked - config.fog_provider = ENV['FOG_PROVIDER'] if ENV.has_key?('FOG_PROVIDER') - config.fog_directory = ENV['FOG_DIRECTORY'] if ENV.has_key?('FOG_DIRECTORY') - config.fog_region = ENV['FOG_REGION'] if ENV.has_key?('FOG_REGION') - - config.aws_access_key_id = ENV['ASSETS_AWS_ACCESS_KEY_ID'] if ENV.has_key?('ASSETS_AWS_ACCESS_KEY_ID') - config.aws_secret_access_key = ENV['ASSETS_AWS_SECRET_ACCESS_KEY'] if ENV.has_key?('ASSETS_AWS_SECRET_ACCESS_KEY') - config.aws_reduced_redundancy = ENV['AWS_REDUCED_REDUNDANCY'] == true if ENV.has_key?('AWS_REDUCED_REDUNDANCY') - - config.rackspace_username = ENV['RACKSPACE_USERNAME'] if ENV.has_key?('RACKSPACE_USERNAME') - config.rackspace_api_key = ENV['RACKSPACE_API_KEY'] if ENV.has_key?('RACKSPACE_API_KEY') - - config.google_storage_access_key_id = ENV['GOOGLE_STORAGE_ACCESS_KEY_ID'] if ENV.has_key?('GOOGLE_STORAGE_ACCESS_KEY_ID') - config.google_storage_secret_access_key = ENV['GOOGLE_STORAGE_SECRET_ACCESS_KEY'] if ENV.has_key?('GOOGLE_STORAGE_SECRET_ACCESS_KEY') - - config.existing_remote_files = ENV['ASSET_SYNC_EXISTING_REMOTE_FILES'] || "keep" - - config.gzip_compression = (ENV['ASSET_SYNC_GZIP_COMPRESSION'] == 'true') if ENV.has_key?('ASSET_SYNC_GZIP_COMPRESSION') - config.manifest = (ENV['ASSET_SYNC_MANIFEST'] == 'true') if ENV.has_key?('ASSET_SYNC_MANIFEST') -end -- cgit v1.2.1 From 6f4c1fd5a5310e49b4471800a09eb150eacba60a Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Wed, 24 Oct 2018 11:22:32 +0200 Subject: Regenerate Gitaly's config.toml each rspec run This behaviour I removed in 08cdf65b9e1f, but this reverts this specific line. In case storages, or other options changes which are set by the Rails environment, this will easier to migrate to. Storage paths is kept in plural, to support multiple storage in later release for just testing purposes. But its probable that multi Gitaly scenarios need to be tested. --- spec/support/helpers/test_env.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/support/helpers/test_env.rb b/spec/support/helpers/test_env.rb index 71d72ff27e9..293538d759d 100644 --- a/spec/support/helpers/test_env.rb +++ b/spec/support/helpers/test_env.rb @@ -158,8 +158,9 @@ module TestEnv version: Gitlab::GitalyClient.expected_server_version, task: "gitlab:gitaly:install[#{gitaly_dir},#{repos_path}]") do - start_gitaly(gitaly_dir) - end + Gitlab::SetupHelper.create_gitaly_configuration(gitaly_dir, { 'default' => repos_path }, force: true) + start_gitaly(gitaly_dir) + end end def start_gitaly(gitaly_dir) -- cgit v1.2.1 From d9b56bc13b94bdc69a14a2b4201e25e141a62ce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Fri, 26 Oct 2018 22:02:09 +0200 Subject: Add parallel keyword to CI config --- lib/gitlab/ci/config/entry/job.rb | 14 +++++++----- spec/lib/gitlab/ci/config/entry/job_spec.rb | 33 +++++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 7 deletions(-) diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb index f290ff3a565..368b5eb2a89 100644 --- a/lib/gitlab/ci/config/entry/job.rb +++ b/lib/gitlab/ci/config/entry/job.rb @@ -12,7 +12,7 @@ module Gitlab ALLOWED_KEYS = %i[tags script only except type image services allow_failure type stage when start_in artifacts cache dependencies before_script after_script variables - environment coverage retry extends].freeze + environment coverage retry parallel extends].freeze validations do validates :config, allowed_keys: ALLOWED_KEYS @@ -27,6 +27,8 @@ module Gitlab validates :retry, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 2 } + validates :parallel, numericality: { only_integer: true, + greater_than_or_equal_to: 1 } validates :when, inclusion: { in: %w[on_success on_failure always manual delayed], message: 'should be on_success, on_failure, ' \ @@ -77,17 +79,18 @@ module Gitlab description: 'Artifacts configuration for this job.' entry :environment, Entry::Environment, - description: 'Environment configuration for this job.' + description: 'Environment configuration for this job.' entry :coverage, Entry::Coverage, - description: 'Coverage configuration for this job.' + description: 'Coverage configuration for this job.' helpers :before_script, :script, :stage, :type, :after_script, :cache, :image, :services, :only, :except, :variables, - :artifacts, :commands, :environment, :coverage, :retry + :artifacts, :commands, :environment, :coverage, :retry, + :parallel attributes :script, :tags, :allow_failure, :when, :dependencies, - :retry, :extends, :start_in + :retry, :parallel, :extends, :start_in def compose!(deps = nil) super do @@ -156,6 +159,7 @@ module Gitlab environment_name: environment_defined? ? environment_value[:name] : nil, coverage: coverage_defined? ? coverage_value : nil, retry: retry_defined? ? retry_value.to_i : nil, + parallel: parallel_defined? ? parallel_value.to_i : nil, artifacts: artifacts_value, after_script: after_script_value, ignore: ignored? } diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index 1169938b80c..718098c364e 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -1,5 +1,4 @@ -require 'fast_spec_helper' -require_dependency 'active_model' +require 'spec_helper' describe Gitlab::Ci::Config::Entry::Job do let(:entry) { described_class.new(config, name: :rspec) } @@ -138,6 +137,36 @@ describe Gitlab::Ci::Config::Entry::Job do end end + context 'when parallel value is not correct' do + context 'when it is not a numeric value' do + let(:config) { { parallel: true } } + + it 'returns error about invalid type' do + expect(entry).not_to be_valid + expect(entry.errors).to include 'job parallel is not a number' + end + end + + context 'when it is lower than one' do + let(:config) { { parallel: 0 } } + + it 'returns error about value too low' do + expect(entry).not_to be_valid + expect(entry.errors) + .to include 'job parallel must be greater than or equal to 1' + end + end + + context 'when it is not an integer' do + let(:config) { { parallel: 1.5 } } + + it 'returns error about wrong value' do + expect(entry).not_to be_valid + expect(entry.errors).to include 'job parallel must be an integer' + end + end + end + context 'when delayed job' do context 'when start_in is specified' do let(:config) { { script: 'echo', when: 'delayed', start_in: '1 day' } } -- cgit v1.2.1 From 44b740f99dfe6a4344c918fd4c94972aa6f9237e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Fri, 26 Oct 2018 23:23:58 +0200 Subject: Implement POC for job parallelization --- lib/gitlab/ci/pipeline/seed/build.rb | 24 +++++++++++++++++++++++- lib/gitlab/ci/yaml_processor.rb | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/gitlab/ci/pipeline/seed/build.rb b/lib/gitlab/ci/pipeline/seed/build.rb index 6980b0b7aff..c302acdf073 100644 --- a/lib/gitlab/ci/pipeline/seed/build.rb +++ b/lib/gitlab/ci/pipeline/seed/build.rb @@ -24,6 +24,24 @@ module Gitlab end end + def parallelized? + @attributes[:options].include?(:parallel) + end + + def parallelize_build + builds = [] + + total = @attributes[:options][:parallel] + + total.times do |i| + build = ::Ci::Build.new(attributes.merge(options: { variables: { CI_NODE_INDEX: i + 1, CI_NODE_TOTAL: total } })) + build.name = build.name + "_#{i + 1}/#{total}" + builds << build + end + + builds + end + def attributes @attributes.merge( pipeline: @pipeline, @@ -38,7 +56,11 @@ module Gitlab def to_resource strong_memoize(:resource) do - ::Ci::Build.new(attributes) + if parallelized? + parallelize_build + else + ::Ci::Build.new(attributes) + end end end end diff --git a/lib/gitlab/ci/yaml_processor.rb b/lib/gitlab/ci/yaml_processor.rb index a427aa30683..612d733ad49 100644 --- a/lib/gitlab/ci/yaml_processor.rb +++ b/lib/gitlab/ci/yaml_processor.rb @@ -50,6 +50,7 @@ module Gitlab after_script: job[:after_script], environment: job[:environment], retry: job[:retry], + parallel: job[:parallel], start_in: job[:start_in] }.compact } end -- cgit v1.2.1 From 72430483ded51e9a7d01ef70c3dce3dda174fac1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Sat, 27 Oct 2018 03:38:36 +0200 Subject: Refactor parallelization implementation * Move the variables to ::Ci::Build#predefined_variables * Tweak pipeline build seed implementation --- app/models/ci/build.rb | 6 ++++++ lib/gitlab/ci/pipeline/seed/build.rb | 22 +++++----------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index cdfe8175a42..21e2f289e1e 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -801,10 +801,16 @@ module Ci variables.append(key: "CI_COMMIT_TAG", value: ref) if tag? variables.append(key: "CI_PIPELINE_TRIGGERED", value: 'true') if trigger_request variables.append(key: "CI_JOB_MANUAL", value: 'true') if action? + variables.append(key: "CI_NODE_INDEX", value: node_index.to_s) if self.options[:parallel] + variables.append(key: "CI_NODE_TOTAL", value: self.options.fetch(:parallel, 1).to_s) variables.concat(legacy_variables) end end + def node_index + name.match(%r{(\d+)/\d+$}).captures[0] + end + def gitlab_version_info @gitlab_version_info ||= Gitlab::VersionInfo.parse(Gitlab::VERSION) end diff --git a/lib/gitlab/ci/pipeline/seed/build.rb b/lib/gitlab/ci/pipeline/seed/build.rb index c302acdf073..4b1116ced92 100644 --- a/lib/gitlab/ci/pipeline/seed/build.rb +++ b/lib/gitlab/ci/pipeline/seed/build.rb @@ -24,22 +24,14 @@ module Gitlab end end - def parallelized? - @attributes[:options].include?(:parallel) + def parallel? + !!@attributes.dig(:options, :parallel) end def parallelize_build - builds = [] - total = @attributes[:options][:parallel] - - total.times do |i| - build = ::Ci::Build.new(attributes.merge(options: { variables: { CI_NODE_INDEX: i + 1, CI_NODE_TOTAL: total } })) - build.name = build.name + "_#{i + 1}/#{total}" - builds << build - end - - builds + Array.new(total) { ::Ci::Build.new(attributes) } + .each_with_index { |build, idx| build.name = "#{build.name} #{idx + 1}/#{total}" } end def attributes @@ -56,11 +48,7 @@ module Gitlab def to_resource strong_memoize(:resource) do - if parallelized? - parallelize_build - else - ::Ci::Build.new(attributes) - end + parallel? ? parallelize_build : ::Ci::Build.new(attributes) end end end -- cgit v1.2.1 From c2d49565cf787c592c4f8bd9f24843babd2a6c9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Sat, 27 Oct 2018 18:04:09 +0200 Subject: Add build specs --- app/models/ci/build.rb | 4 ++-- spec/models/ci/build_spec.rb | 48 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index 21e2f289e1e..86569f9a9c3 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -801,8 +801,8 @@ module Ci variables.append(key: "CI_COMMIT_TAG", value: ref) if tag? variables.append(key: "CI_PIPELINE_TRIGGERED", value: 'true') if trigger_request variables.append(key: "CI_JOB_MANUAL", value: 'true') if action? - variables.append(key: "CI_NODE_INDEX", value: node_index.to_s) if self.options[:parallel] - variables.append(key: "CI_NODE_TOTAL", value: self.options.fetch(:parallel, 1).to_s) + variables.append(key: "CI_NODE_INDEX", value: node_index.to_s) if self.options&.include?(:parallel) + variables.append(key: "CI_NODE_TOTAL", value: (self.options&.dig(:parallel) || 1).to_s) variables.concat(legacy_variables) end end diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index a046541031e..41c3c37a7f2 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1880,6 +1880,7 @@ describe Ci::Build do { key: 'CI_COMMIT_BEFORE_SHA', value: build.before_sha, public: true }, { key: 'CI_COMMIT_REF_NAME', value: build.ref, public: true }, { key: 'CI_COMMIT_REF_SLUG', value: build.ref_slug, public: true }, + { key: 'CI_NODE_TOTAL', value: '1', public: true }, { key: 'CI_BUILD_REF', value: build.sha, public: true }, { key: 'CI_BUILD_BEFORE_SHA', value: build.before_sha, public: true }, { key: 'CI_BUILD_REF_NAME', value: build.ref, public: true }, @@ -2341,6 +2342,28 @@ describe Ci::Build do end end + context 'when build is parallelized' do + let(:total) { 5 } + let(:index) { 3 } + + before do + build.options[:parallel] = total + build.name = "#{build.name} #{index}/#{total}" + end + + it 'includes CI_NODE_INDEX' do + is_expected.to include( + { key: 'CI_NODE_INDEX', value: index.to_s, public: true } + ) + end + + it 'includes correct CI_NODE_TOTAL' do + is_expected.to include( + { key: 'CI_NODE_TOTAL', value: total.to_s, public: true } + ) + end + end + describe 'variables ordering' do context 'when variables hierarchy is stubbed' do let(:build_pre_var) { { key: 'build', value: 'value', public: true } } @@ -2447,6 +2470,31 @@ describe Ci::Build do end end end + + describe '#node_index' do + subject { build.send(:node_index) } + let(:index) { 4 } + + context 'when build has only one index' do + before do + build.name = "#{build.name} #{index}/5" + end + + it 'returns the index' do + expect(subject).to eq(index.to_s) + end + end + + context 'when build has more than one one index' do + before do + build.name = "test_build 1/3 #{index}/5" + end + + it 'returns the last index' do + expect(subject).to eq(index.to_s) + end + end + end end describe '#scoped_variables' do -- cgit v1.2.1 From a12da215c96fc15fb27753f18ab2106c6714bbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Sat, 27 Oct 2018 18:19:58 +0200 Subject: Add YamlProcessor specs --- spec/lib/gitlab/ci/yaml_processor_spec.rb | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 85b23edce9f..544e421d571 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -136,6 +136,19 @@ module Gitlab end end end + + describe 'parallel entry' do + context 'when parallel is defined' do + let(:config) do + YAML.dump(rspec: { script: 'rspec', + parallel: 1 }) + end + + it 'has the attributes' do + expect(subject[:options][:parallel]).to eq 1 + end + end + end end describe '#stages_attributes' do @@ -645,6 +658,25 @@ module Gitlab end end + describe 'Parallel' do + context 'when job is parallelized' do + let(:parallel) { 5 } + + let(:config) do + YAML.dump(rspec: { script: 'rspec', + parallel: parallel }) + end + + it 'returns parallelized job' do + config_processor = Gitlab::Ci::YamlProcessor.new(config) + builds = config_processor.stage_builds_attributes("test") + + expect(builds.size).to eq(1) + expect(builds.first[:options][:parallel]).to eq(parallel) + end + end + end + describe 'cache' do context 'when cache definition has unknown keys' do it 'raises relevant validation error' do -- cgit v1.2.1 From 03bc722ea1797a6b2b09f2897215477f5b269632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Sat, 27 Oct 2018 18:52:47 +0200 Subject: Add Build seed specs --- spec/lib/gitlab/ci/pipeline/seed/build_spec.rb | 59 ++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 3 deletions(-) diff --git a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb index fffa727c2ed..d75f385f368 100644 --- a/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb +++ b/spec/lib/gitlab/ci/pipeline/seed/build_spec.rb @@ -13,6 +13,46 @@ describe Gitlab::Ci::Pipeline::Seed::Build do described_class.new(pipeline, attributes) end + describe '#parallel?' do + context 'when build is not parallelized' do + it 'should be false' do + expect(subject.parallel?).to eq(false) + end + end + + context 'when build is parallelized' do + before do + attributes[:options] = { parallel: 5 } + end + + it 'should be true' do + expect(subject.parallel?).to eq(true) + end + end + end + + describe '#parallelize_build' do + let(:total) { 5 } + + before do + attributes[:options] = { parallel: total } + end + + it 'returns duplicated builds' do + builds = subject.parallelize_build + + expect(builds.size).to eq(total) + end + + it 'returns builds with indexed names' do + builds = subject.parallelize_build + + base_name = builds.first.name.split(' ')[0] + names = builds.map(&:name) + expect(names).to all(match(%r{^#{base_name} \d+/\d+$})) + end + end + describe '#attributes' do it 'returns hash attributes of a build' do expect(subject.attributes).to be_a Hash @@ -22,9 +62,22 @@ describe Gitlab::Ci::Pipeline::Seed::Build do end describe '#to_resource' do - it 'returns a valid build resource' do - expect(subject.to_resource).to be_a(::Ci::Build) - expect(subject.to_resource).to be_valid + context 'when build is not parallelized' do + it 'returns a valid build resource' do + expect(subject.to_resource).to be_a(::Ci::Build) + expect(subject.to_resource).to be_valid + end + end + + context 'when build is parallelized' do + before do + attributes[:options] = { parallel: 5 } + end + + it 'returns a group of valid build resources' do + expect(subject.to_resource).to all(be_a(::Ci::Build)) + expect(subject.to_resource).to all(be_valid) + end end it 'memoizes a resource object' do -- cgit v1.2.1 From ff1795713e7029e40b11888debe577294dd9754f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Sat, 27 Oct 2018 18:53:23 +0200 Subject: Add CHANGELOG entry --- changelogs/unreleased/21480-parallel-job-keyword-mvc.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/21480-parallel-job-keyword-mvc.yml diff --git a/changelogs/unreleased/21480-parallel-job-keyword-mvc.yml b/changelogs/unreleased/21480-parallel-job-keyword-mvc.yml new file mode 100644 index 00000000000..7ac2410b18c --- /dev/null +++ b/changelogs/unreleased/21480-parallel-job-keyword-mvc.yml @@ -0,0 +1,5 @@ +--- +title: Implement parallel job keyword. +merge_request: 22631 +author: +type: added -- cgit v1.2.1 From 9ba72fe09aaf3bf903494f09fe8896012e962c98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Sat, 27 Oct 2018 19:06:46 +0200 Subject: Change minimum parallel value to 2 --- lib/gitlab/ci/config/entry/job.rb | 2 +- spec/lib/gitlab/ci/config/entry/job_spec.rb | 6 +++--- spec/lib/gitlab/ci/yaml_processor_spec.rb | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/gitlab/ci/config/entry/job.rb b/lib/gitlab/ci/config/entry/job.rb index 368b5eb2a89..c73c88583b0 100644 --- a/lib/gitlab/ci/config/entry/job.rb +++ b/lib/gitlab/ci/config/entry/job.rb @@ -28,7 +28,7 @@ module Gitlab greater_than_or_equal_to: 0, less_than_or_equal_to: 2 } validates :parallel, numericality: { only_integer: true, - greater_than_or_equal_to: 1 } + greater_than_or_equal_to: 2 } validates :when, inclusion: { in: %w[on_success on_failure always manual delayed], message: 'should be on_success, on_failure, ' \ diff --git a/spec/lib/gitlab/ci/config/entry/job_spec.rb b/spec/lib/gitlab/ci/config/entry/job_spec.rb index 718098c364e..f1a2946acda 100644 --- a/spec/lib/gitlab/ci/config/entry/job_spec.rb +++ b/spec/lib/gitlab/ci/config/entry/job_spec.rb @@ -147,13 +147,13 @@ describe Gitlab::Ci::Config::Entry::Job do end end - context 'when it is lower than one' do - let(:config) { { parallel: 0 } } + context 'when it is lower than two' do + let(:config) { { parallel: 1 } } it 'returns error about value too low' do expect(entry).not_to be_valid expect(entry.errors) - .to include 'job parallel must be greater than or equal to 1' + .to include 'job parallel must be greater than or equal to 2' end end diff --git a/spec/lib/gitlab/ci/yaml_processor_spec.rb b/spec/lib/gitlab/ci/yaml_processor_spec.rb index 544e421d571..8289a6b000b 100644 --- a/spec/lib/gitlab/ci/yaml_processor_spec.rb +++ b/spec/lib/gitlab/ci/yaml_processor_spec.rb @@ -141,11 +141,11 @@ module Gitlab context 'when parallel is defined' do let(:config) do YAML.dump(rspec: { script: 'rspec', - parallel: 1 }) + parallel: 2 }) end it 'has the attributes' do - expect(subject[:options][:parallel]).to eq 1 + expect(subject[:options][:parallel]).to eq 2 end end end -- cgit v1.2.1 From 3c2acb3acfcc95eead03403f6593201391ead8d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Sat, 27 Oct 2018 19:12:48 +0200 Subject: Add documentation entries --- doc/ci/variables/README.md | 2 ++ doc/ci/yaml/README.md | 26 +++++++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md index 2d23bf6d2fd..0ddbc828d1a 100644 --- a/doc/ci/variables/README.md +++ b/doc/ci/variables/README.md @@ -65,6 +65,8 @@ future GitLab releases.** | **CI_JOB_NAME** | 9.0 | 0.5 | The name of the job as defined in `.gitlab-ci.yml` | | **CI_JOB_STAGE** | 9.0 | 0.5 | The name of the stage as defined in `.gitlab-ci.yml` | | **CI_JOB_TOKEN** | 9.0 | 1.2 | Token used for authenticating with the [GitLab Container Registry][registry] and downloading [dependent repositories][dependent-repositories] | +| **CI_NODE_INDEX** | 11.5 | all | The index of the job in the whole set. If the job is not paralellized, this is not set. | +| **CI_NODE_TOTAL** | 11.5 | all | The total number of instances of this job running in parallel. If the job is not paralellized, this is set to 1. | | **CI_JOB_URL** | 11.1 | 0.5 | Job details URL | | **CI_REPOSITORY_URL** | 9.0 | all | The URL to clone the Git repository | | **CI_RUNNER_DESCRIPTION** | 8.10 | 0.5 | The description of the runner as saved in GitLab | diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 981aa101dd3..4801d5d42e7 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -75,6 +75,7 @@ A job is defined by a list of parameters that define the job behavior. | environment | no | Defines a name of environment to which deployment is done by this job | | coverage | no | Define code coverage settings for a given job | | retry | no | Define how many times a job can be auto-retried in case of a failure | +| parallel | no | Define how many duplicates of a job should be run in parallel | ### `extends` @@ -1451,6 +1452,28 @@ test: retry: 2 ``` +## `parallel` + +> [Introduced][ce-22631] in GitLab 11.5. + +`parallel` allows you to configure how many duplicates of a job will be run in +parallel. This value has to be greater or equal to two (2). + +This creates N duplicates of the same job that run in parallel. They're named +sequentially from `job_name 1/N` to `job_name N/N`. + +For every job `CI_NODE_INDEX` and `CI_NODE_TOTAL` environment variables are set. +`CI_NODE_TOTAL` represents the total number of jobs while `CI_NODE_INDEX` is the +index of the job in the whole set. + +A simple example: + +```yaml +test: + script: rspec + parallel: 5 +``` + ## `include` > Introduced in [GitLab Edition Premium][ee] 10.5. @@ -2031,7 +2054,8 @@ CI with various languages. [ce-7983]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7983 [ce-7447]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7447 [ce-12909]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12909 +[ce-22631]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22631 [schedules]: ../../user/project/pipelines/schedules.md [variables-expressions]: ../variables/README.md#variables-expressions [ee]: https://about.gitlab.com/gitlab-ee/ -[gitlab-versions]: https://about.gitlab.com/products/ \ No newline at end of file +[gitlab-versions]: https://about.gitlab.com/products/ -- cgit v1.2.1 From 623940bfa11b7b35613645bf3c4264605f0d33c0 Mon Sep 17 00:00:00 2001 From: Chris Baumbauer Date: Sun, 28 Oct 2018 17:36:26 -0700 Subject: Add knative model tests --- app/models/clusters/applications/knative.rb | 13 ++- spec/models/clusters/applications/knative_spec.rb | 102 ++++++++++++++++++++++ 2 files changed, 107 insertions(+), 8 deletions(-) create mode 100644 spec/models/clusters/applications/knative_spec.rb diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb index be196331be5..916dabdd0db 100644 --- a/app/models/clusters/applications/knative.rb +++ b/app/models/clusters/applications/knative.rb @@ -3,26 +3,23 @@ module Clusters module Applications class Knative < ActiveRecord::Base - VERSION = '0.1.2'.freeze + VERSION = '0.1.3'.freeze REPOSITORY = 'https://storage.googleapis.com/triggermesh-charts'.freeze + # This is required for helm version <= 2.10.x in order to support + # Setting up CRDs + ISTIO_CRDS = 'http://cabnetworks.net/triggermesh-charts/istio-crds.yaml'.freeze + self.table_name = 'clusters_applications_knative' include ::Clusters::Concerns::ApplicationCore include ::Clusters::Concerns::ApplicationStatus include ::Clusters::Concerns::ApplicationVersion include ::Clusters::Concerns::ApplicationData - include AfterCommitQueue default_value_for :version, VERSION default_value_for :domainname, '' - def set_initial_status - return unless not_installable? - - self.status = 'installable' if cluster&.platform_kubernetes_active? - end - def chart 'knative/knative' end diff --git a/spec/models/clusters/applications/knative_spec.rb b/spec/models/clusters/applications/knative_spec.rb new file mode 100644 index 00000000000..78124c13be9 --- /dev/null +++ b/spec/models/clusters/applications/knative_spec.rb @@ -0,0 +1,102 @@ +require 'rails_helper' + +describe Clusters::Applications::Knative do + let(:knative) { create(:clusters_applications_knative) } + + include_examples 'cluster application core specs', :clusters_applications_knative + include_examples 'cluster application status specs', :clusters_applications_knative + + describe '.installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_knative, :installed) } + + before do + create(:clusters_applications_knative, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + + describe '#make_installing!' do + before do + application.make_installing! + end + + context 'application install previously errored with older version' do + let(:application) { create(:clusters_applications_knative, :scheduled, version: '0.1.3') } + + it 'updates the application version' do + expect(application.reload.version).to eq('0.1.3') + end + end + end + + describe '#make_installed' do + subject { described_class.installed } + + let!(:cluster) { create(:clusters_applications_knative, :installed) } + + before do + create(:clusters_applications_knative, :errored) + end + + it { is_expected.to contain_exactly(cluster) } + end + + describe '#install_command' do + subject { knative.install_command } + + it { is_expected.to be_an_instance_of(Gitlab::Kubernetes::Helm::InstallCommand) } + + it 'should be initialized with knative arguments' do + expect(subject.name).to eq('knative') + expect(subject.chart).to eq('knative/knative') + expect(subject.version).to eq('0.1.3') + expect(subject.files).to eq(knative.files) + expect(subject.setargs).to eq([]) + end + + context 'application failed to install previously' do + let(:knative) { create(:clusters_applications_knative, :errored, version: 'knative') } + + it 'should be initialized with the locked version' do + expect(subject.version).to eq('0.1.3') + end + end + end + + describe '#files' do + let(:application) { knative } + let(:values) { subject[:'values.yaml'] } + + subject { application.files } + + it 'should include knative valid keys in values' do + expect(values).to include('domain') + end + + context 'when the helm application does not have a ca_cert' do + before do + application.cluster.application_helm.ca_cert = nil + end + + it 'should not include cert files' do + expect(subject[:'ca.pem']).not_to be_present + expect(subject[:'cert.pem']).not_to be_present + expect(subject[:'key.pem']).not_to be_present + end + end + + it 'should include cert files' do + expect(subject[:'ca.pem']).to be_present + expect(subject[:'ca.pem']).to eq(application.cluster.application_helm.ca_cert) + + expect(subject[:'cert.pem']).to be_present + expect(subject[:'key.pem']).to be_present + + cert = OpenSSL::X509::Certificate.new(subject[:'cert.pem']) + expect(cert.not_after).to be < 60.minutes.from_now + end + end +end -- cgit v1.2.1 From 3cbea3b95d2d20de7b65ef0775959c1c153c4e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Mon, 29 Oct 2018 16:58:35 +0100 Subject: Copyedit documentation updates --- doc/ci/variables/README.md | 4 ++-- doc/ci/yaml/README.md | 15 ++++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/doc/ci/variables/README.md b/doc/ci/variables/README.md index 0ddbc828d1a..bdbcf8c9435 100644 --- a/doc/ci/variables/README.md +++ b/doc/ci/variables/README.md @@ -65,8 +65,8 @@ future GitLab releases.** | **CI_JOB_NAME** | 9.0 | 0.5 | The name of the job as defined in `.gitlab-ci.yml` | | **CI_JOB_STAGE** | 9.0 | 0.5 | The name of the stage as defined in `.gitlab-ci.yml` | | **CI_JOB_TOKEN** | 9.0 | 1.2 | Token used for authenticating with the [GitLab Container Registry][registry] and downloading [dependent repositories][dependent-repositories] | -| **CI_NODE_INDEX** | 11.5 | all | The index of the job in the whole set. If the job is not paralellized, this is not set. | -| **CI_NODE_TOTAL** | 11.5 | all | The total number of instances of this job running in parallel. If the job is not paralellized, this is set to 1. | +| **CI_NODE_INDEX** | 11.5 | all | Index of the job in the job set. If the job is not parallelized, this variable is not set. | +| **CI_NODE_TOTAL** | 11.5 | all | Total number of instances of this job running in parallel. If the job is not parallelized, this variable is set to `1`. | | **CI_JOB_URL** | 11.1 | 0.5 | Job details URL | | **CI_REPOSITORY_URL** | 9.0 | all | The URL to clone the Git repository | | **CI_RUNNER_DESCRIPTION** | 8.10 | 0.5 | The description of the runner as saved in GitLab | diff --git a/doc/ci/yaml/README.md b/doc/ci/yaml/README.md index 4801d5d42e7..b3a55e48f4e 100644 --- a/doc/ci/yaml/README.md +++ b/doc/ci/yaml/README.md @@ -75,7 +75,7 @@ A job is defined by a list of parameters that define the job behavior. | environment | no | Defines a name of environment to which deployment is done by this job | | coverage | no | Define code coverage settings for a given job | | retry | no | Define how many times a job can be auto-retried in case of a failure | -| parallel | no | Define how many duplicates of a job should be run in parallel | +| parallel | no | Defines how many instances of a job should be run in parallel | ### `extends` @@ -1454,17 +1454,15 @@ test: ## `parallel` -> [Introduced][ce-22631] in GitLab 11.5. +> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22631) in GitLab 11.5. -`parallel` allows you to configure how many duplicates of a job will be run in -parallel. This value has to be greater or equal to two (2). +`parallel` allows you to configure how many instances of a job to run in +parallel. This value has to be greater than or equal to two (2). -This creates N duplicates of the same job that run in parallel. They're named +This creates N instances of the same job that run in parallel. They're named sequentially from `job_name 1/N` to `job_name N/N`. -For every job `CI_NODE_INDEX` and `CI_NODE_TOTAL` environment variables are set. -`CI_NODE_TOTAL` represents the total number of jobs while `CI_NODE_INDEX` is the -index of the job in the whole set. +For every job, `CI_NODE_INDEX` and `CI_NODE_TOTAL` [environment variables](../variables/README.html#predefined-variables-environment-variables) are set. A simple example: @@ -2054,7 +2052,6 @@ CI with various languages. [ce-7983]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7983 [ce-7447]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/7447 [ce-12909]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12909 -[ce-22631]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/22631 [schedules]: ../../user/project/pipelines/schedules.md [variables-expressions]: ../variables/README.md#variables-expressions [ee]: https://about.gitlab.com/gitlab-ee/ -- cgit v1.2.1 From 0ddff09385fa74760fdbeff3e29d5ff7f7e94ebb Mon Sep 17 00:00:00 2001 From: Chris Baumbauer Date: Mon, 29 Oct 2018 10:56:46 -0700 Subject: Revert Helm version bump --- app/models/clusters/applications/knative.rb | 9 +++++++-- lib/gitlab/kubernetes/helm.rb | 2 +- lib/gitlab/kubernetes/helm/base_command.rb | 8 ++++++++ lib/gitlab/kubernetes/helm/install_command.rb | 16 ++++++++++++---- spec/support/shared_examples/helm_generated_script.rb | 10 +++++++++- 5 files changed, 37 insertions(+), 8 deletions(-) diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb index 916dabdd0db..0c64bde73ae 100644 --- a/app/models/clusters/applications/knative.rb +++ b/app/models/clusters/applications/knative.rb @@ -8,7 +8,7 @@ module Clusters # This is required for helm version <= 2.10.x in order to support # Setting up CRDs - ISTIO_CRDS = 'http://cabnetworks.net/triggermesh-charts/istio-crds.yaml'.freeze + ISTIO_CRDS = 'https://storage.googleapis.com/triggermesh-charts/istio-crds.yaml'.freeze self.table_name = 'clusters_applications_knative' @@ -37,10 +37,15 @@ module Clusters chart: chart, files: files, repository: REPOSITORY, - setargs: args + setargs: args, + script: install_script ) end + def install_script + ['/usr/bin/kubectl', 'apply', '-f', ISTIO_CRDS] + end + def client cluster&.platform_kubernetes&.kubeclient&.core_client end diff --git a/lib/gitlab/kubernetes/helm.rb b/lib/gitlab/kubernetes/helm.rb index a53c2c9e5cb..4a1bdf34c3e 100644 --- a/lib/gitlab/kubernetes/helm.rb +++ b/lib/gitlab/kubernetes/helm.rb @@ -1,7 +1,7 @@ module Gitlab module Kubernetes module Helm - HELM_VERSION = '2.11.0'.freeze + HELM_VERSION = '2.7.2'.freeze NAMESPACE = 'gitlab-managed-apps'.freeze SERVICE_ACCOUNT = 'tiller'.freeze CLUSTER_ROLE_BINDING = 'tiller-admin'.freeze diff --git a/lib/gitlab/kubernetes/helm/base_command.rb b/lib/gitlab/kubernetes/helm/base_command.rb index 74efe4bc8bb..1a928fb351f 100644 --- a/lib/gitlab/kubernetes/helm/base_command.rb +++ b/lib/gitlab/kubernetes/helm/base_command.rb @@ -17,6 +17,14 @@ module Gitlab apk add -U wget ca-certificates openssl git >/dev/null wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v#{Gitlab::Kubernetes::Helm::HELM_VERSION}-linux-amd64.tar.gz | tar zxC /tmp >/dev/null mv /tmp/linux-amd64/helm /usr/bin/ + + wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub + wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk + apk add glibc-2.28-r0.apk > /dev/null + rm glibc-2.28-r0.apk + wget -q https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/linux/amd64/kubectl + chmod +x kubectl + mv kubectl /usr/bin/ HEREDOC end diff --git a/lib/gitlab/kubernetes/helm/install_command.rb b/lib/gitlab/kubernetes/helm/install_command.rb index 904bcd4470d..aa5fddf1b44 100644 --- a/lib/gitlab/kubernetes/helm/install_command.rb +++ b/lib/gitlab/kubernetes/helm/install_command.rb @@ -4,9 +4,9 @@ module Gitlab class InstallCommand include BaseCommand - attr_reader :name, :files, :chart, :version, :repository, :setargs + attr_reader :name, :files, :chart, :version, :repository, :setargs, :script - def initialize(name:, chart:, files:, rbac:, version: nil, repository: nil, setargs: nil) + def initialize(name:, chart:, files:, rbac:, version: nil, repository: nil, setargs: nil, script: nil) @name = name @chart = chart @version = version @@ -14,6 +14,7 @@ module Gitlab @files = files @repository = repository @setargs = setargs + @script = script end def generate_script @@ -21,7 +22,8 @@ module Gitlab init_command, repository_command, repository_update_command, - script_command + script_command, + install_command ].compact.join("\n") end @@ -43,12 +45,18 @@ module Gitlab 'helm repo update >/dev/null' if repository end - def script_command + def install_command command = ['helm', 'install', chart] + install_command_flags command.shelljoin + " >/dev/null\n" end + def script_command + unless script.nil? + script.shelljoin + " >/dev/null\n" + end + end + def install_command_flags name_flag = ['--name', name] namespace_flag = ['--namespace', Gitlab::Kubernetes::Helm::NAMESPACE] diff --git a/spec/support/shared_examples/helm_generated_script.rb b/spec/support/shared_examples/helm_generated_script.rb index a1f92c64d38..5cfbce84706 100644 --- a/spec/support/shared_examples/helm_generated_script.rb +++ b/spec/support/shared_examples/helm_generated_script.rb @@ -7,8 +7,16 @@ shared_examples 'helm commands' do echo http://mirror.clarkson.edu/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories echo http://mirror1.hs-esslingen.de/pub/Mirrors/alpine/v$ALPINE_VERSION/main >> /etc/apk/repositories apk add -U wget ca-certificates openssl git >/dev/null - wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v2.11.0-linux-amd64.tar.gz | tar zxC /tmp >/dev/null + wget -q -O - https://kubernetes-helm.storage.googleapis.com/helm-v2.7.2-linux-amd64.tar.gz | tar zxC /tmp >/dev/null mv /tmp/linux-amd64/helm /usr/bin/ + + wget -q -O /etc/apk/keys/sgerrand.rsa.pub https://alpine-pkgs.sgerrand.com/sgerrand.rsa.pub + wget -q https://github.com/sgerrand/alpine-pkg-glibc/releases/download/2.28-r0/glibc-2.28-r0.apk + apk add glibc-2.28-r0.apk > /dev/null + rm glibc-2.28-r0.apk + wget -q https://storage.googleapis.com/kubernetes-release/release/v1.11.0/bin/linux/amd64/kubectl + chmod +x kubectl + mv kubectl /usr/bin/ EOS end -- cgit v1.2.1 From 25b658cf6545f1ab7b1aecc902e6f833af3e3949 Mon Sep 17 00:00:00 2001 From: "at.ramya" Date: Wed, 17 Oct 2018 10:40:26 +0530 Subject: QA Selectors for Batch Comment E2E Automation --- .../diffs/components/diff_line_gutter_content.vue | 2 +- .../diffs/components/parallel_diff_table_row.vue | 2 +- .../javascripts/notes/components/comment_form.vue | 4 ++-- .../javascripts/notes/components/note_form.vue | 2 +- .../notes/components/noteable_discussion.vue | 2 +- app/views/projects/merge_requests/show.html.haml | 4 ++-- qa/qa/page/merge_request/show.rb | 26 ++++++++++++++++++++++ 7 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/diffs/components/diff_line_gutter_content.vue b/app/assets/javascripts/diffs/components/diff_line_gutter_content.vue index 6eff3013dcd..f4a9be19496 100644 --- a/app/assets/javascripts/diffs/components/diff_line_gutter_content.vue +++ b/app/assets/javascripts/diffs/components/diff_line_gutter_content.vue @@ -167,7 +167,7 @@ export default {