Commit 46e43451 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch '213299-env-autostop-bug' into 'master'

Add autostop check to folder table

See merge request gitlab-org/gitlab!28937
parents 9e8614c4 03c9590b
...@@ -58,12 +58,6 @@ export default { ...@@ -58,12 +58,6 @@ export default {
required: true, required: true,
}, },
shouldShowAutoStopDate: {
type: Boolean,
required: false,
default: false,
},
tableData: { tableData: {
type: Object, type: Object,
required: true, required: true,
...@@ -638,12 +632,7 @@ export default { ...@@ -638,12 +632,7 @@ export default {
</span> </span>
</div> </div>
<div <div v-if="!isFolder" class="table-section" :class="tableData.autoStop.spacing" role="gridcell">
v-if="!isFolder && shouldShowAutoStopDate"
class="table-section"
:class="tableData.autoStop.spacing"
role="gridcell"
>
<div role="rowheader" class="table-mobile-header">{{ tableData.autoStop.title }}</div> <div role="rowheader" class="table-mobile-header">{{ tableData.autoStop.title }}</div>
<span <span
v-if="canShowAutoStopDate" v-if="canShowAutoStopDate"
...@@ -662,10 +651,7 @@ export default { ...@@ -662,10 +651,7 @@ export default {
role="gridcell" role="gridcell"
> >
<div class="btn-group table-action-buttons" role="group"> <div class="btn-group table-action-buttons" role="group">
<pin-component <pin-component v-if="canShowAutoStopDate" :auto-stop-url="autoStopUrl" />
v-if="canShowAutoStopDate && shouldShowAutoStopDate"
:auto-stop-url="autoStopUrl"
/>
<external-url-component <external-url-component
v-if="externalURL && canReadEnvironment" v-if="externalURL && canReadEnvironment"
......
...@@ -6,7 +6,6 @@ import { GlLoadingIcon } from '@gitlab/ui'; ...@@ -6,7 +6,6 @@ import { GlLoadingIcon } from '@gitlab/ui';
import { flow, reverse, sortBy } from 'lodash/fp'; import { flow, reverse, sortBy } from 'lodash/fp';
import environmentTableMixin from 'ee_else_ce/environments/mixins/environments_table_mixin'; import environmentTableMixin from 'ee_else_ce/environments/mixins/environments_table_mixin';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import EnvironmentItem from './environment_item.vue'; import EnvironmentItem from './environment_item.vue';
export default { export default {
...@@ -17,7 +16,7 @@ export default { ...@@ -17,7 +16,7 @@ export default {
CanaryDeploymentCallout: () => CanaryDeploymentCallout: () =>
import('ee_component/environments/components/canary_deployment_callout.vue'), import('ee_component/environments/components/canary_deployment_callout.vue'),
}, },
mixins: [environmentTableMixin, glFeatureFlagsMixin()], mixins: [environmentTableMixin],
props: { props: {
environments: { environments: {
type: Array, type: Array,
...@@ -43,9 +42,6 @@ export default { ...@@ -43,9 +42,6 @@ export default {
: env, : env,
); );
}, },
shouldShowAutoStopDate() {
return this.glFeatures.autoStopEnvironments;
},
tableData() { tableData() {
return { return {
// percent spacing for cols, should add up to 100 // percent spacing for cols, should add up to 100
...@@ -74,7 +70,7 @@ export default { ...@@ -74,7 +70,7 @@ export default {
spacing: 'section-5', spacing: 'section-5',
}, },
actions: { actions: {
spacing: this.shouldShowAutoStopDate ? 'section-25' : 'section-30', spacing: 'section-25',
}, },
}; };
}, },
...@@ -131,12 +127,7 @@ export default { ...@@ -131,12 +127,7 @@ export default {
<div class="table-section" :class="tableData.date.spacing" role="columnheader"> <div class="table-section" :class="tableData.date.spacing" role="columnheader">
{{ tableData.date.title }} {{ tableData.date.title }}
</div> </div>
<div <div class="table-section" :class="tableData.autoStop.spacing" role="columnheader">
v-if="shouldShowAutoStopDate"
class="table-section"
:class="tableData.autoStop.spacing"
role="columnheader"
>
{{ tableData.autoStop.title }} {{ tableData.autoStop.title }}
</div> </div>
</div> </div>
...@@ -146,7 +137,6 @@ export default { ...@@ -146,7 +137,6 @@ export default {
:key="`environment-item-${i}`" :key="`environment-item-${i}`"
:model="model" :model="model"
:can-read-environment="canReadEnvironment" :can-read-environment="canReadEnvironment"
:should-show-auto-stop-date="shouldShowAutoStopDate"
:table-data="tableData" :table-data="tableData"
/> />
......
...@@ -15,9 +15,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController ...@@ -15,9 +15,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
before_action only: [:metrics, :additional_metrics, :metrics_dashboard] do before_action only: [:metrics, :additional_metrics, :metrics_dashboard] do
push_frontend_feature_flag(:prometheus_computed_alerts) push_frontend_feature_flag(:prometheus_computed_alerts)
end end
before_action do
push_frontend_feature_flag(:auto_stop_environments, default_enabled: true)
end
after_action :expire_etag_cache, only: [:cancel_auto_stop] after_action :expire_etag_cache, only: [:cancel_auto_stop]
def index def index
......
...@@ -30,7 +30,7 @@ module Environments ...@@ -30,7 +30,7 @@ module Environments
def stop_in_batch def stop_in_batch
environments = Environment.auto_stoppable(BATCH_SIZE) environments = Environment.auto_stoppable(BATCH_SIZE)
return false unless environments.exists? && Feature.enabled?(:auto_stop_environments, default_enabled: true) return false unless environments.exists?
Ci::StopEnvironmentsService.execute_in_batch(environments) Ci::StopEnvironmentsService.execute_in_batch(environments)
end end
......
...@@ -8,8 +8,6 @@ module Environments ...@@ -8,8 +8,6 @@ module Environments
feature_category :continuous_delivery feature_category :continuous_delivery
def perform def perform
return unless Feature.enabled?(:auto_stop_environments, default_enabled: true)
AutoStopService.new.execute AutoStopService.new.execute
end end
end end
......
---
title: Add autostop check to folder table
merge_request: 28937
author:
type: fixed
...@@ -399,10 +399,12 @@ describe 'Environments page', :js do ...@@ -399,10 +399,12 @@ describe 'Environments page', :js do
describe 'environments folders' do describe 'environments folders' do
before do before do
create(:environment, project: project, create(:environment, :will_auto_stop,
project: project,
name: 'staging/review-1', name: 'staging/review-1',
state: :available) state: :available)
create(:environment, project: project, create(:environment, :will_auto_stop,
project: project,
name: 'staging/review-2', name: 'staging/review-2',
state: :available) state: :available)
end end
...@@ -420,6 +422,14 @@ describe 'Environments page', :js do ...@@ -420,6 +422,14 @@ describe 'Environments page', :js do
expect(page).to have_content 'review-1' expect(page).to have_content 'review-1'
expect(page).to have_content 'review-2' expect(page).to have_content 'review-2'
within('.ci-table') do
within('.gl-responsive-table-row:nth-child(3)') do
expect(find('.js-auto-stop').text).not_to be_empty
end
within('.gl-responsive-table-row:nth-child(4)') do
expect(find('.js-auto-stop').text).not_to be_empty
end
end
end end
end end
......
...@@ -40,18 +40,6 @@ describe Environments::AutoStopService, :clean_gitlab_redis_shared_state do ...@@ -40,18 +40,6 @@ describe Environments::AutoStopService, :clean_gitlab_redis_shared_state do
expect(Ci::Build.where(name: 'stop_review_app').map(&:status).uniq).to eq(['pending']) expect(Ci::Build.where(name: 'stop_review_app').map(&:status).uniq).to eq(['pending'])
end end
context 'when auto_stop_environments feature flag is disabled' do
before do
stub_feature_flags(auto_stop_environments: false)
end
it 'does not execute Ci::StopEnvironmentsService' do
expect(Ci::StopEnvironmentsService).not_to receive(:execute_in_batch)
subject
end
end
context 'when the other sidekiq worker has already been running' do context 'when the other sidekiq worker has already been running' do
before do before do
stub_exclusive_lease_taken(described_class::EXCLUSIVE_LOCK_KEY) stub_exclusive_lease_taken(described_class::EXCLUSIVE_LOCK_KEY)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment