Skip to content

Commit 58228c9

Browse files
Merge branch 'main' into fix/trigger-timeout-string
2 parents 2371795 + 77f78b6 commit 58228c9

File tree

6 files changed

+77
-15
lines changed

6 files changed

+77
-15
lines changed

src/components/ResourceBrowser/ResourceList/ResourceList.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export default function ResourceList() {
310310
!isTerminal &&
311311
!isNodes
312312
) {
313-
getResourceListData()
313+
selectedResource.gvk.Kind !== SIDEBAR_KEYS.nodeGVK.Kind && getResourceListData()
314314
setSearchText('')
315315
setSearchApplied(false)
316316
} else if (isNodes) {
@@ -634,7 +634,6 @@ export default function ResourceList() {
634634
setResourceListLoader(true)
635635
setResourceList(null)
636636
setFilteredResourceList([])
637-
638637
const resourceListPayload: ResourceListPayloadType = {
639638
clusterId: Number(clusterId),
640639
k8sRequest: {

src/components/app/details/cicdHistory/TriggerDetails.tsx

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,33 +176,58 @@ const WorkerStatus = React.memo(
176176
const ProgressingStatus = React.memo(
177177
({ status, message, podStatus, stage, type, finishedOn, workerPodName }: ProgressingStatusType): JSX.Element => {
178178
const [aborting, setAborting] = useState(false)
179-
const [abortConfirmation, setAbortConfiguration] = useState(false)
179+
const [abortConfirmation, setAbortConfirmation] = useState(false)
180+
const [abortError, setAbortError] = useState<{
181+
status: boolean
182+
message: string
183+
}>({
184+
status: false,
185+
message: '',
186+
})
180187
const { buildId, triggerId, pipelineId } = useParams<{
181188
buildId: string
182189
triggerId: string
183190
pipelineId: string
184191
}>()
185192
let abort = null
186193
if (type === HistoryComponentType.CI) {
187-
abort = () => cancelCiTrigger({ pipelineId, workflowId: buildId })
194+
abort = (isForceAbort: boolean) => cancelCiTrigger({ pipelineId, workflowId: buildId }, isForceAbort)
188195
} else if (stage !== 'DEPLOY') {
189196
abort = () => cancelPrePostCdTrigger(pipelineId, triggerId)
190197
}
191198

192199
async function abortRunning() {
193200
setAborting(true)
194-
const [error] = await asyncWrap(abort())
195-
setAborting(false)
196-
if (error) {
197-
showError(error)
198-
} else {
201+
try {
202+
await abort(abortError.status)
199203
toast.success('Build Aborted')
200-
setAbortConfiguration(false)
204+
setAbortConfirmation(false)
205+
setAbortError({
206+
status: false,
207+
message: '',
208+
})
209+
} catch (error) {
210+
setAborting(false)
211+
setAbortConfirmation(false)
212+
if (error['code'] === 400) {
213+
// code 400 is for aborting a running build
214+
const errors = error['errors']
215+
setAbortError({
216+
status: true,
217+
message: errors[0].userMessage,
218+
})
219+
}
201220
}
202221
}
203222

204223
const toggleAbortConfiguration = (): void => {
205-
setAbortConfiguration(not)
224+
setAbortConfirmation(not)
225+
}
226+
const closeForceAbortModal = (): void => {
227+
setAbortError({
228+
status: false,
229+
message: '',
230+
})
206231
}
207232
return (
208233
<>
@@ -252,6 +277,29 @@ const ProgressingStatus = React.memo(
252277
</ConfirmationDialog.ButtonGroup>
253278
</ConfirmationDialog>
254279
)}
280+
{abortError.status && (
281+
<ConfirmationDialog>
282+
<ConfirmationDialog.Icon src={warn} />
283+
<ConfirmationDialog.Body title="Could not abort build!" />
284+
<div className="w-100 bc-n50 h-36 flexbox dc__align-items-center">
285+
<span className="pl-12">Error: {abortError.message}</span>
286+
</div>
287+
<div className="fs-13 fw-6 pt-12 cn-7 lh-1-54">
288+
<span>Please try to force abort</span>
289+
</div>
290+
<div className="pt-4 fw-4 cn-7 lh-1-54">
291+
<span>Some resource might get orphaned which will be cleaned up with Job-lifecycle</span>
292+
</div>
293+
<ConfirmationDialog.ButtonGroup>
294+
<button type="button" className="cta cancel" onClick={closeForceAbortModal}>
295+
Cancel
296+
</button>
297+
<button type="button" className="cta delete" onClick={abortRunning}>
298+
{aborting ? <Progressing /> : 'Force Abort'}
299+
</button>
300+
</ConfirmationDialog.ButtonGroup>
301+
</ConfirmationDialog>
302+
)}
255303
</>
256304
)
257305
},

src/components/app/service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ export function extractImage(image: string): string {
282282
return image ? image.split(':').pop() : ''
283283
}
284284

285-
export const cancelCiTrigger = (params) => {
286-
let URL = `${Routes.CI_CONFIG_GET}/${params.pipelineId}/workflow/${params.workflowId}`
285+
export const cancelCiTrigger = (params, isForceAbort) => {
286+
let URL = `${Routes.CI_CONFIG_GET}/${params.pipelineId}/workflow/${params.workflowId}?forceAbort=${isForceAbort}`
287287
return trash(URL)
288288
}
289289

src/components/cdPipeline/NewCDPipeline.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,13 @@ export default function NewCDPipeline({
816816
getWorkflows()
817817
}
818818
}
819+
else if(response.errors){
820+
setDeleteDialog(DeleteDialogType.showForceDeleteDialog)
821+
setForceDeleteData({
822+
forceDeleteDialogTitle: 'Something went wrong',
823+
forceDeleteDialogMessage: response.errors[0].userMessage,
824+
})
825+
}
819826
})
820827
.catch((error: ServerErrors) => {
821828
// 412 is for linked pipeline and 403 is for RBAC

src/components/v2/appDetails/k8Resource/nodeDetail/NodeDetailTabs/Manifest.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ function ManifestComponent({
224224
className: 'devtron-toast unauthorized',
225225
},
226226
)
227-
} else if (err.code === 500) {
227+
} else if (err.code === 400 || err.code === 409 || err.code === 422 ) {
228228
const error = err['errors'] && err['errors'][0]
229229
if (error && error.code && error.userMessage) {
230-
setErrorText(`ERROR ${error.code} > Message: “${error.userMessage}”`)
230+
setErrorText(`ERROR ${err.code} > Message: “${error.userMessage}”`)
231231
} else {
232232
showError(err)
233233
}

src/components/workflowEditor/workflowEditor.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,14 @@ class WorkflowEdit extends Component<WorkflowEditProps, WorkflowEditState> {
216216
deleteWorkflow = (appId?: string, workflowId?: number) => {
217217
deleteWorkflow(appId || this.props.match.params.appId, workflowId || this.state.workflowId)
218218
.then((response) => {
219+
220+
if(response.errors){
221+
const {errors} = response
222+
const {userMessage} = errors[0]
223+
toast.error(userMessage)
224+
return
225+
}
226+
219227
if (response.status.toLowerCase() === 'ok') {
220228
this.setState({ showDeleteDialog: false })
221229
toast.success('Workflow Deleted')

0 commit comments

Comments
 (0)