Skip to content

Commit 3dd5a54

Browse files
committed
We now gate the autoscaler status, pause/resume and events tab to users who have access
1 parent af95e3c commit 3dd5a54

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

shell/components/formatter/Autoscaler.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const stopPropagation = (event: Event) => {
4545
#heading-action="{close}"
4646
>
4747
<RcButton
48+
v-if="row.canPauseResumeAutoscaler"
4849
secondary
4950
small
5051
class="action"

shell/detail/provisioning.cattle.io.cluster.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ export default {
626626
},
627627
628628
showAutoScalerTab() {
629-
return isAutoscalerFeatureFlagEnabled(this.$store);
629+
return isAutoscalerFeatureFlagEnabled(this.$store) && this.value.hasAccessToAutoscalerConfigMap;
630630
}
631631
},
632632

shell/models/provisioning.cattle.io.cluster.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export default class ProvCluster extends SteveModel {
175175
action: 'toggleAutoscalerRunner',
176176
label: this.isAutoscalerPaused ? 'Resume Autoscaler' : 'Pause Autoscaler',
177177
icon: `icon ${ this.isAutoscalerPaused ? 'icon-play' : 'icon-pause' }`,
178-
enabled: this.isAutoscalerEnabled
178+
enabled: this.canPauseResumeAutoscaler
179179
},
180180
{ divider: true }];
181181

@@ -1082,17 +1082,30 @@ export default class ProvCluster extends SteveModel {
10821082
return events.filter((event) => event.involvedObject.name === 'cluster-autoscaler-status');
10831083
}
10841084

1085+
get hasAccessToAutoscalerConfigMap() {
1086+
// This may change but for now this is the best proxy we have for access to the configmap without attempting to access it and getting a 404.
1087+
return this.canEdit;
1088+
}
1089+
10851090
async loadAutoscalerConfigMap() {
10861091
const url = `/k8s/clusters/${ this.mgmtClusterId }/v1/${ CONFIG_MAP }/${ AUTOSCALER_CONFIG_MAP_ID }`;
10871092

10881093
return await this.$dispatch('cluster/request', { url }, { root: true });
10891094
}
10901095

1096+
get canPauseResumeAutoscaler() {
1097+
return this.isAutoscalerEnabled && this.canExplore && this.hasAccessToAutoscalerConfigMap;
1098+
}
1099+
10911100
async loadAutoscalerStatus() {
10921101
if (!this.canExplore) {
10931102
return AUTOSCALER_STATUS.PROVISIONING;
10941103
}
10951104

1105+
if (!this.hasAccessToAutoscalerConfigMap) {
1106+
return AUTOSCALER_STATUS.UNAVAILABLE;
1107+
}
1108+
10961109
try {
10971110
const configMap = await this.loadAutoscalerConfigMap();
10981111
const yaml = configMap?.data?.status || '';

0 commit comments

Comments
 (0)