Skip to content

Commit 4c667e2

Browse files
authored
Merge pull request #2049 from devtron-labs/fix/force-delete-helm
fix: force delete when cluster unreachable
2 parents f704d03 + b7a9660 commit 4c667e2

File tree

9 files changed

+58
-21
lines changed

9 files changed

+58
-21
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "0.3.19",
7+
"@devtron-labs/devtron-fe-common-lib": "0.3.19-beta-2",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/components/cdPipeline/CDPipeline.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -663,9 +663,11 @@ export default function CDPipeline({
663663
deploymentAppName: formData.deploymentAppName,
664664
releaseMode: formData.releaseMode,
665665
deploymentAppCreated: formData.deploymentAppCreated,
666-
...(getUserApprovalConfigPayload ? {
667-
userApprovalConfig: getUserApprovalConfigPayload(formData.userApprovalConfig)
668-
}: {}),
666+
...(getUserApprovalConfigPayload
667+
? {
668+
userApprovalConfig: getUserApprovalConfigPayload(formData.userApprovalConfig),
669+
}
670+
: {}),
669671
triggerType: formData.triggerType,
670672
environmentName: formData.environmentName,
671673
preStageConfigMapSecretNames: _preStageConfigMapSecretNames,
@@ -1031,8 +1033,10 @@ export default function CDPipeline({
10311033
})
10321034
.catch((error: ServerErrors) => {
10331035
// 412 is for linked pipeline and 403 is for RBAC
1034-
// 422 is for deployment window
1035-
if (!force && error.code != 403 && error.code != 412 && error.code != 422) {
1036+
//For now we are removing check for error code 422 which is of deployment window,
1037+
// so in that case force delete modal would be shown.
1038+
// This should be done at BE and when done we will revert our changes
1039+
if (!force && error.code != 403 && error.code != 412) {
10361040
setForceDeleteDialogData(error)
10371041
setDeleteDialog(DeleteDialogType.showForceDeleteDialog)
10381042
} else {

src/components/charts/charts.service.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,24 @@
1414
* limitations under the License.
1515
*/
1616

17-
import { get, post, put, trash, sortCallback, ResponseType } from '@devtron-labs/devtron-fe-common-lib'
17+
import {
18+
get,
19+
post,
20+
put,
21+
trash,
22+
sortCallback,
23+
ResponseType,
24+
getUrlWithSearchParams,
25+
} from '@devtron-labs/devtron-fe-common-lib'
1826
import { DELETE_ACTION, Routes } from '../../config'
1927
import { getAPIOptionsWithTriggerTimeout, handleUTCTime } from '../common'
20-
import { ChartValuesType, ChartGroup, HelmTemplateChartRequest, HelmProjectUpdatePayload } from './charts.types'
28+
import {
29+
ChartValuesType,
30+
ChartGroup,
31+
HelmTemplateChartRequest,
32+
HelmProjectUpdatePayload,
33+
DeleteInstalledChartParamsType,
34+
} from './charts.types'
2135
import { SavedValueListResponse } from './SavedValues/types'
2236

2337
interface RootObject {
@@ -57,13 +71,20 @@ export function deleteInstalledChart(
5771
isGitops?: boolean,
5872
deleteAction?: DELETE_ACTION,
5973
) {
60-
let URL: string = `app-store/deployment/application/delete/${installedAppId}?partialDelete=${isGitops ? 'true' : 'false'}`
74+
const baseUrl: string = `app-store/deployment/application/delete/${installedAppId}`
75+
let params: DeleteInstalledChartParamsType = {}
6176
if (deleteAction === DELETE_ACTION.FORCE_DELETE) {
62-
URL += `&force=true`
63-
} else if (deleteAction === DELETE_ACTION.NONCASCADE_DELETE) {
64-
URL += `&cascade=false`
77+
params = {
78+
forceDelete: true,
79+
}
80+
} else if (isGitops) {
81+
params['partialDelete'] = true
82+
if (deleteAction === DELETE_ACTION.NONCASCADE_DELETE) {
83+
params['cascade'] = false
84+
}
6585
}
66-
return trash(URL)
86+
const url = getUrlWithSearchParams(baseUrl, params)
87+
return trash(url)
6788
}
6889

6990
export function getChartValuesTemplateList(chartId: number | string): Promise<SavedValueListResponse> {

src/components/charts/charts.types.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,9 @@ export interface ChartHeaderFilterProps {
401401
isGrid: boolean
402402
setIsGrid: (isGrid: boolean) => void
403403
}
404+
405+
export interface DeleteInstalledChartParamsType {
406+
forceDelete?: true
407+
partialDelete?: true
408+
cascade?: false
409+
}

src/components/charts/discoverChartDetail/ChartDeploymentList.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ export const DeploymentRow = ({
176176
fetchDeployments()
177177
} else if (
178178
deleteAction !== DELETE_ACTION.NONCASCADE_DELETE &&
179-
!response.result.deleteResponse?.clusterReachable
179+
!response.result.deleteResponse?.clusterReachable &&
180+
deploymentAppType === DeploymentAppTypes.GITOPS
180181
) {
181182
setClusterName(response.result.deleteResponse?.clusterName)
182183
toggleConfirmation(false)
@@ -208,6 +209,7 @@ export const DeploymentRow = ({
208209
const handleForceDelete = () => {
209210
handleDelete(DELETE_ACTION.FORCE_DELETE)
210211
}
212+
211213
const handleCascadeDelete = () => {
212214
handleDelete(DELETE_ACTION.DELETE)
213215
}

src/components/v2/appDetails/sourceInfo/EnvironmentSelector.component.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ const EnvironmentSelectorComponent = ({
182182
}
183183
} else if (
184184
deleteAction !== DELETE_ACTION.NONCASCADE_DELETE &&
185-
!response.result.deleteResponse?.clusterReachable
185+
!response.result.deleteResponse?.clusterReachable &&
186+
appDetails?.deploymentAppType === DeploymentAppTypes.GITOPS
186187
) {
187188
setClusterName(response.result.deleteResponse?.clusterName)
188189
setShowDeleteConfirmation(false)

src/components/v2/values/chartValuesDiff/ChartValuesView.reducer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const initState = (
2323
chartValuesFromParent: ChartValuesType,
2424
installedConfigFromParent: any,
2525
chartVersionsDataFromParent: ChartVersionType[],
26+
deploymentAppType: DeploymentAppTypes,
2627
): ChartValuesViewState => {
2728
return {
2829
isLoading: true,
@@ -79,7 +80,7 @@ export const initState = (
7980
invalidProject: false,
8081
formValidationError: {},
8182
showNoGitOpsWarning: false,
82-
deploymentAppType: DeploymentAppTypes.HELM,
83+
deploymentAppType: deploymentAppType ?? DeploymentAppTypes.HELM,
8384
gitRepoURL: '',
8485
authMode: null,
8586
initialChartVersionValues: {

src/components/v2/values/chartValuesDiff/ChartValuesView.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ const ChartValuesView = ({
198198
: chartValuesFromParent,
199199
installedConfigFromParent,
200200
chartVersionsDataFromParent,
201+
appDetails?.deploymentAppType,
201202
),
202203
)
203204

@@ -706,7 +707,8 @@ const ChartValuesView = ({
706707
// helm app delete failed due to cluster not reachable (ArgoCD installed)
707708
if (
708709
deleteAction !== DELETE_ACTION.NONCASCADE_DELETE &&
709-
!response.result.deleteResponse?.clusterReachable
710+
!response.result.deleteResponse?.clusterReachable &&
711+
commonState.deploymentAppType === DeploymentAppTypes.GITOPS
710712
) {
711713
dispatch({
712714
type: ChartValuesViewActionTypes.multipleOptions,

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,10 +1346,10 @@
13461346
dependencies:
13471347
"@jridgewell/trace-mapping" "0.3.9"
13481348

1349-
"@devtron-labs/[email protected]":
1350-
version "0.3.19"
1351-
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-0.3.19.tgz#a1b22552e1e9d998c1d2d6690bf23afcef9253cc"
1352-
integrity sha512-sEUyag/2Ee7KG7JWRuv/IbJzZNQ9AbjqvDTty+VebuXTrCrOAhTUNXz+uGouUQ/x7J/bqDNY/M3d7Zwluw13yQ==
1349+
"@devtron-labs/[email protected]-beta-2":
1350+
version "0.3.19-beta-2"
1351+
resolved "https://registry.yarnpkg.com/@devtron-labs/devtron-fe-common-lib/-/devtron-fe-common-lib-0.3.19-beta-2.tgz#fb2d5a758c5567ebf95335ad79a7647b81ad9d19"
1352+
integrity sha512-rWUP1Cpiobw1pz8RHRQlSRUxfX+fwZpQKWx3SZomeq75nHvUYGCoT/NRvo1aBqzylIjQ005HDbXI3uHJdeobkw==
13531353
dependencies:
13541354
"@types/react-dates" "^21.8.6"
13551355
ansi_up "^5.2.1"

0 commit comments

Comments
 (0)