Skip to content

Commit abf3540

Browse files
committed
Fixed create disabled for some scenarios
Added alert with error message in case no nodes are available to schedule terminal
1 parent 51f0f1f commit abf3540

4 files changed

Lines changed: 50 additions & 24 deletions

File tree

backend/lib/services/terminals/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,8 @@ async function getTerminalConfig ({ user, namespace, name, target }) {
774774
},
775775
}
776776

777-
if (target === TargetEnum.SHOOT) {
777+
if (target === TargetEnum.SHOOT ||
778+
(target === TargetEnum.GARDEN && !isAdmin)) {
778779
const shootRef = {
779780
namespace,
780781
name,

frontend/src/components/dialogs/GCreateTerminalSessionDialog.vue

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ SPDX-License-Identifier: Apache-2.0
3939
<g-terminal-target
4040
v-model="targetTab.selectedTarget"
4141
:disabled="targetTab.configLoading"
42-
@update:model-value="updateSettings"
4342
/>
4443
<v-expansion-panels
4544
v-model="targetTab.value"
@@ -57,7 +56,7 @@ SPDX-License-Identifier: Apache-2.0
5756
<g-terminal-settings
5857
v-show="!targetTab.configLoading"
5958
ref="settings"
60-
:runtime-settings-hidden="!hasShootWorkerGroups || targetTab.selectedTarget !== 'shoot'"
59+
:runtime-settings-hidden="!hasShootWorkerGroups || targetTab.selectedTarget !== TargetEnum.SHOOT"
6160
/>
6261
</v-expansion-panel-text>
6362
</v-expansion-panel>
@@ -91,10 +90,8 @@ SPDX-License-Identifier: Apache-2.0
9190
</template>
9291
<template #footer>
9392
<v-alert
94-
v-if="!isAdmin
95-
&& targetTab.selectedTarget === 'garden'"
96-
class="mt-2 mb-2"
97-
:value="true"
93+
v-if="showUserGardenTerminalAlert"
94+
class="ma-2"
9895
type="info"
9996
color="primary"
10097
variant="tonal"
@@ -103,19 +100,24 @@ SPDX-License-Identifier: Apache-2.0
103100
Make sure that only gardener project members with <span class="font-family-monospace">admin</span> role have privileged access to the <span class="font-family-monospace">{{ shootName }}</span> cluster before creating this terminal session.
104101
</v-alert>
105102
<v-alert
106-
v-if="isAdmin
107-
&& targetTab.selectedTarget === 'shoot'
108-
&& !targetTab.configLoading
109-
&& state.runtime === 'shoot'"
110-
class="ml-6 mt-6 mb-2"
111-
:model-value="true"
103+
v-if="showAdminShootTerminalAlert"
104+
class="ma-2"
112105
type="info"
113106
color="primary"
114107
variant="tonal"
115108
>
116109
<strong>Terminal will be running in an untrusted environment!</strong><br>
117110
Do not enter credentials or sensitive data within the terminal session that cluster owners should not have access to, as the terminal will be running on one of the worker nodes.
118111
</v-alert>
112+
<v-alert
113+
v-if="createDisabledNoNodes"
114+
class="ma-2"
115+
type="error"
116+
variant="tonal"
117+
>
118+
<strong>Cannot schedule terminal on<span class="font-family-monospace">{{ shootName }}</span> cluster</strong><br>
119+
No worker nodes available in the cluster. Please check the cluster status and try again.
120+
</v-alert>
119121
</template>
120122
</g-dialog>
121123
</template>
@@ -189,6 +191,7 @@ export default {
189191
config,
190192
state,
191193
updateState,
194+
TargetEnum,
192195
}
193196
},
194197
data () {
@@ -223,11 +226,8 @@ export default {
223226
return false
224227
}
225228
226-
if (this.targetTab.selectedTarget === 'shoot') {
227-
if (this.config.preferredHost === 'shoot' &&
228-
!this.state.shootNodes.length) {
229-
return false
230-
}
229+
if (this.createDisabledNoNodes) {
230+
return false
231231
}
232232
return !this.v$.$invalid
233233
}
@@ -264,6 +264,26 @@ export default {
264264
}
265265
}
266266
},
267+
showUserGardenTerminalAlert () {
268+
return !this.isAdmin && this.targetTab.selectedTarget === TargetEnum.GARDEN
269+
},
270+
showAdminShootTerminalAlert () {
271+
return this.isAdmin &&
272+
this.targetTab.selectedTarget === TargetEnum.SHOOT &&
273+
!this.targetTab.configLoading &&
274+
this.state.runtime === TargetEnum.SHOOT
275+
},
276+
createDisabledNoNodes () {
277+
if (this.state.runtime !== TargetEnum.SHOOT && this.state.runtime !== TargetEnum.GARDEN) {
278+
return false
279+
}
280+
if (this.isAdmin && this.targetTab.selectedTarget === TargetEnum.GARDEN) {
281+
// Admin Garden Terminal always scheduled on dedicated managed seed
282+
return false
283+
}
284+
285+
return !this.targetTab.configLoading && !this.state.shootNodes.length
286+
},
267287
},
268288
watch: {
269289
isSettingsExpanded () {
@@ -279,6 +299,8 @@ export default {
279299
},
280300
defaultTarget (value) {
281301
this.targetTab.selectedTarget = value
302+
},
303+
'targetTab.selectedTarget' () {
282304
this.updateSettings()
283305
},
284306
},

frontend/src/composables/useTerminalConfig.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export function createTerminalConfigComposable () {
6666
shootNodes: [],
6767
privilegedMode: false,
6868
runtime: 'shoot',
69+
canScheduleOnSeed: false,
6970
})
7071

7172
function isAutoSelectNode (hostname) {

frontend/src/composables/useTerminalSplitpanes.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function createTerminalSplitpanesComposable () {
8787
})
8888

8989
const canScheduleOnSeed = computed(() => {
90-
return get(shootItem.value, ['info', 'canLinkToSeed'])
90+
return get(shootItem.value, ['info', 'canLinkToSeed'], false)
9191
})
9292

9393
const slotItemUUIds = computed(() => {
@@ -96,11 +96,13 @@ export function createTerminalSplitpanesComposable () {
9696
})
9797

9898
const defaultTarget = computed(() => {
99-
return terminalCoordinates.value.target ||
100-
(authzStore.hasControlPlaneTerminalAccess &&
101-
canScheduleOnSeed.value)
102-
? TargetEnum.CONTROL_PLANE
103-
: TargetEnum.SHOOT
99+
if (terminalCoordinates.value.target) {
100+
return terminalCoordinates.value.target
101+
}
102+
if (authzStore.hasControlPlaneTerminalAccess && canScheduleOnSeed.value) {
103+
return TargetEnum.CONTROL_PLANE
104+
}
105+
return TargetEnum.SHOOT
104106
})
105107

106108
function addSlotItem ({ data = {}, targetId, position } = {}) {

0 commit comments

Comments
 (0)