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 {
required: true,
},
shouldShowAutoStopDate: {
type: Boolean,
required: false,
default: false,
},
tableData: {
type: Object,
required: true,
......@@ -638,12 +632,7 @@ export default {
</span>
</div>
<div
v-if="!isFolder && shouldShowAutoStopDate"
class="table-section"
:class="tableData.autoStop.spacing"
role="gridcell"
>
<div v-if="!isFolder" class="table-section" :class="tableData.autoStop.spacing" role="gridcell">
<div role="rowheader" class="table-mobile-header">{{ tableData.autoStop.title }}</div>
<span
v-if="canShowAutoStopDate"
......@@ -662,10 +651,7 @@ export default {
role="gridcell"
>
<div class="btn-group table-action-buttons" role="group">
<pin-component
v-if="canShowAutoStopDate && shouldShowAutoStopDate"
:auto-stop-url="autoStopUrl"
/>
<pin-component v-if="canShowAutoStopDate" :auto-stop-url="autoStopUrl" />
<external-url-component
v-if="externalURL && canReadEnvironment"
......
......@@ -6,7 +6,6 @@ import { GlLoadingIcon } from '@gitlab/ui';
import { flow, reverse, sortBy } from 'lodash/fp';
import environmentTableMixin from 'ee_else_ce/environments/mixins/environments_table_mixin';
import { s__ } from '~/locale';
import glFeatureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
import EnvironmentItem from './environment_item.vue';
export default {
......@@ -17,7 +16,7 @@ export default {
CanaryDeploymentCallout: () =>
import('ee_component/environments/components/canary_deployment_callout.vue'),
},
mixins: [environmentTableMixin, glFeatureFlagsMixin()],
mixins: [environmentTableMixin],
props: {
environments: {
type: Array,
......@@ -43,9 +42,6 @@ export default {
: env,
);
},
shouldShowAutoStopDate() {
return this.glFeatures.autoStopEnvironments;
},
tableData() {
return {
// percent spacing for cols, should add up to 100
......@@ -74,7 +70,7 @@ export default {
spacing: 'section-5',
},
actions: {
spacing: this.shouldShowAutoStopDate ? 'section-25' : 'section-30',
spacing: 'section-25',
},
};
},
......@@ -131,12 +127,7 @@ export default {
<div class="table-section" :class="tableData.date.spacing" role="columnheader">
{{ tableData.date.title }}
</div>
<div
v-if="shouldShowAutoStopDate"
class="table-section"
:class="tableData.autoStop.spacing"
role="columnheader"
>
<div class="table-section" :class="tableData.autoStop.spacing" role="columnheader">
{{ tableData.autoStop.title }}
</div>
</div>
......@@ -146,7 +137,6 @@ export default {
:key="`environment-item-${i}`"
:model="model"
:can-read-environment="canReadEnvironment"
:should-show-auto-stop-date="shouldShowAutoStopDate"
:table-data="tableData"
/>
......
......@@ -15,9 +15,6 @@ class Projects::EnvironmentsController < Projects::ApplicationController
before_action only: [:metrics, :additional_metrics, :metrics_dashboard] do
push_frontend_feature_flag(:prometheus_computed_alerts)
end
before_action do
push_frontend_feature_flag(:auto_stop_environments, default_enabled: true)
end
after_action :expire_etag_cache, only: [:cancel_auto_stop]
def index
......
......@@ -30,7 +30,7 @@ module Environments
def stop_in_batch
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)
end
......
......@@ -8,8 +8,6 @@ module Environments
feature_category :continuous_delivery
def perform
return unless Feature.enabled?(:auto_stop_environments, default_enabled: true)
AutoStopService.new.execute
end
end
......
---
title: Add autostop check to folder table
merge_request: 28937
author:
type: fixed
......@@ -399,10 +399,12 @@ describe 'Environments page', :js do
describe 'environments folders' do
before do
create(:environment, project: project,
create(:environment, :will_auto_stop,
project: project,
name: 'staging/review-1',
state: :available)
create(:environment, project: project,
create(:environment, :will_auto_stop,
project: project,
name: 'staging/review-2',
state: :available)
end
......@@ -420,6 +422,14 @@ describe 'Environments page', :js do
expect(page).to have_content 'review-1'
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
......
......@@ -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'])
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
before do
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