Skip to content

Commit 5c9eba3

Browse files
authored
Merge pull request #2070 from devtron-labs/fix/restart-error-handling
fix: [PROD] open the restart workload on app group , from second tab we have set the ima ge approver , now from first tab do restart , we are showing initiated and it actually restarts , however it should not #5472
2 parents 2321758 + 55db4a8 commit 5c9eba3

File tree

8 files changed

+86
-20
lines changed

8 files changed

+86
-20
lines changed

src/components/ApplicationGroup/Details/EnvironmentOverview/RestartStatusListDrawer.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ export const RestartStatusListDrawer = ({
4242
}: RestartStatusListDrawerProps) => {
4343
const [expandedAppIds, setExpandedAppIds] = useState<number[]>([])
4444
const [isExpandableButtonClicked, setExpandableButtonClicked] = useState(false)
45-
4645
const hasPartialDeploymentWindowAccess = (appId) =>
4746
hibernateInfoMap[appId] &&
4847
hibernateInfoMap[appId].userActionState &&

src/components/ApplicationGroup/Details/EnvironmentOverview/RestartWorkloadModal.tsx

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const RestartWorkloadModal = ({
7676
const abortControllerRef = useRef<AbortController>(new AbortController())
7777
const [showResistanceBox, setShowResistanceBox] = useState(false)
7878
const [isExpandableButtonClicked, setExpandableButtonClicked] = useState(false)
79+
7980
const { searchParams } = useSearchString()
8081
const history = useHistory()
8182
const [showStatusModal, setShowStatusModal] = useState(false)
@@ -506,12 +507,35 @@ export const RestartWorkloadModal = ({
506507
}
507508

508509
const postRestartPodBatchFunction = (payload) => () =>
509-
postRestartWorkloadRotatePods(payload).then((response) => {
510-
if (response.result) {
511-
// showing the status modal in case batch promise resolved
512-
updateBulkRotatePodsMapWithStatusCounts(response, payload.appId)
513-
}
514-
})
510+
postRestartWorkloadRotatePods(payload)
511+
.then((response) => {
512+
if (response.result) {
513+
// showing the status modal in case batch promise resolved
514+
updateBulkRotatePodsMapWithStatusCounts(response, payload.appId)
515+
}
516+
})
517+
.catch((serverError) => {
518+
if (serverError.code === 409) {
519+
serverError.errors.map(({ userMessage }) => {
520+
const _bulkRotatePodsMap = { ...bulkRotatePodsMap }
521+
const _resources: ResourcesMetaDataMap = _bulkRotatePodsMap[payload.appId].resources
522+
523+
// Iterate through the Map and update errorResponse
524+
Object.keys(_resources).forEach((kindName) => {
525+
_resources[kindName].containsError = true
526+
_resources[kindName].errorResponse = userMessage
527+
})
528+
529+
_bulkRotatePodsMap[payload.appId].failedCount = Object.keys(_resources).length
530+
_bulkRotatePodsMap[payload.appId].errorResponse = userMessage
531+
_bulkRotatePodsMap[payload.appId].resources = _resources
532+
// Updating the state with the modified map
533+
setBulkRotatePodsMap(_bulkRotatePodsMap)
534+
535+
return null
536+
})
537+
}
538+
})
515539

516540
const createFunctionCallsFromRestartPodMap = () => {
517541
// default case for restart workload for all apps

src/components/app/details/triggerView/CiWebhookDebuggingModal.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import React, { useState } from 'react'
1818
import { useHistory, useLocation } from 'react-router-dom'
19-
import { showError, Progressing, sortCallback, stopPropagation } from '@devtron-labs/devtron-fe-common-lib'
19+
import { showError, Progressing, sortCallback, stopPropagation, getUrlWithSearchParams } from '@devtron-labs/devtron-fe-common-lib'
2020
import moment from 'moment'
2121
import { getCIWebhookPayload } from './ciWebhook.service'
2222
import { getCIPipelineURL } from '../../../common'
@@ -60,7 +60,7 @@ export default function CiWebhookModal({
6060
'noreferrer',
6161
)
6262
} else {
63-
history.push(`edit/workflow/${workflowId}/ci-pipeline/${ciPipelineId}`)
63+
history.push(`/app/${appId}/edit/workflow/${workflowId}/ci-pipeline/${ciPipelineId}`)
6464
}
6565
}
6666

@@ -267,7 +267,7 @@ export default function CiWebhookModal({
267267

268268
const renderTimeStampDetailedDescription = () => {
269269
return (
270-
<div style={{ height: 'calc(100vh - 75px' }} className="bcn-0 pl-16 mt-20">
270+
<div style={{ height: 'calc(100vh - 75px' }} className="bcn-0 px-16 mt-20">
271271
<div style={{ background: '#f2f4f7' }}>
272272
<div className="cn-9 fs-12 fw-6 pt-12 pl-12">Incoming Payload</div>
273273
<div
@@ -286,11 +286,11 @@ export default function CiWebhookModal({
286286
>
287287
{expandIncomingPayload ? 'Collapse' : 'Expand'}
288288
</button>
289-
<div className="cn-9 fw-6 fs-14 flex left">
289+
<div className="cn-9 fw-6 fs-14 flex left dc__content-space">
290290
Filter matching results
291291
<button
292292
type="button"
293-
className="mr-20 dc__transparent dc__align-right"
293+
className="dc__transparent"
294294
onClick={() => onEditShowEditableCiModal(ciPipelineId, workflowId)}
295295
>
296296
{/* Here the CI model requires the CiPipelineId not the CiPipelineMaterialId */}
@@ -358,7 +358,7 @@ export default function CiWebhookModal({
358358
const renderTimeStampDetailedIncomingModal = () => {
359359
return (
360360
<div
361-
className={`bcn-0 w-800 bcn-0 dc__position-fixed dc__top-0 dc__right-0 timestamp-detail-container ${
361+
className={`bcn-0 w-1024 bcn-0 dc__position-fixed dc__top-0 dc__right-0 timestamp-detail-container ${
362362
fromBulkCITrigger ? 'env-modal-width' : ''
363363
}`}
364364
style={{ zIndex: 100 }}

src/components/v2/chartDeploymentHistory/ChartDeploymentHistory.component.tsx

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import {
2929
TabGroup,
3030
ToastManager,
3131
ToastVariantType,
32+
ShowMoreText,
33+
DEPLOYMENT_STATUS,
34+
EMPTY_STATE_STATUS,
3235
} from '@devtron-labs/devtron-fe-common-lib'
3336
import moment from 'moment'
3437
import Tippy from '@tippyjs/react'
@@ -37,7 +40,7 @@ import docker from '../../../assets/icons/misc/docker.svg'
3740
import { ReactComponent as DeployButton } from '../../../assets/icons/ic-deploy.svg'
3841
import DataNotFound from '../../../assets/img/app-not-deployed.png'
3942
import { InstalledAppInfo } from '../../external-apps/ExternalAppService'
40-
import { DEPLOYMENT_STATUS, Moment12HourFormat, SERVER_ERROR_CODES, URLS } from '../../../config'
43+
import { Moment12HourFormat, SERVER_ERROR_CODES, URLS } from '../../../config'
4144
import '../../app/details/cIDetails/ciDetails.scss'
4245
import './chartDeploymentHistory.scss'
4346
import MessageUI from '../common/message.ui'
@@ -52,14 +55,16 @@ import {
5255
RollbackReleaseRequest,
5356
} from './chartDeploymentHistory.service'
5457
import IndexStore from '../appDetails/index.store'
55-
import { DEPLOYMENT_HISTORY_TAB, ERROR_EMPTY_SCREEN, EMPTY_STATE_STATUS } from '../../../config/constantMessaging'
58+
import { DEPLOYMENT_HISTORY_TAB, ERROR_EMPTY_SCREEN } from '../../../config/constantMessaging'
5659
import { importComponentFromFELibrary } from '../../common'
5760
import DockerImageDetails from './DockerImageDetails'
5861
import RollbackConfirmationDialog from './RollbackConfirmationDialog'
5962
import {
6063
processVirtualEnvironmentDeploymentData,
6164
renderDeploymentApprovalInfo,
6265
} from '../../app/details/cdDetails/utils'
66+
import { ReactComponent as Rocket} from '@Icons/ic-nav-rocket.svg'
67+
import {ReactComponent as ICLines } from '@Icons/ic-lines.svg'
6368

6469
const VirtualHistoryArtifact = importComponentFromFELibrary('VirtualHistoryArtifact')
6570

@@ -594,12 +599,34 @@ const ChartDeploymentHistory = ({
594599
}
595600

596601
function renderSelectedDeploymentDetailHeader() {
597-
const deployment = deploymentHistoryArr[selectedDeploymentHistoryIndex]
602+
const deployment: ChartDeploymentDetail = deploymentHistoryArr[selectedDeploymentHistoryIndex]
603+
604+
const getViewMessage = () => {
605+
const { message } = deployment
606+
if (deployment.status.toLowerCase() === DEPLOYMENT_STATUS.FAILED && message) {
607+
return (
608+
<div className="trigger-details__grid-helm py-4 dc__grid">
609+
<div className="flex top dc__content-center">
610+
<ICLines className="icon-dim-20 dc__no-shrink scn-7" />
611+
</div>
612+
613+
<div className="flex column left">
614+
<div className=" cn-9 fs-13 fw-4 lh-20">
615+
<span>Message</span>
616+
</div>
617+
618+
{/* Need key since using ref inside of this component as useEffect dependency, so there were issues while switching builds */}
619+
{message && <ShowMoreText text={message} key={message} textClass="cn-7" />}
620+
</div>
621+
</div>
622+
)
623+
}}
598624

599625
return (
600-
<div className="trigger-details ml-20 mr-20 pb-20">
626+
<div className="trigger-details pb-20">
601627
<div className="flex dc__content-space trigger-details__summary">
602-
<div className="flex column left pt-10">
628+
<div className="flex left py-10 px-20 dc__gap-8">
629+
<Rocket className="scn-6 icon-dim-20" />
603630
<div className="cn-9 fs-14 fw-6" data-testid="deployed-at-heading">
604631
Deployed at
605632
</div>
@@ -621,7 +648,9 @@ const ChartDeploymentHistory = ({
621648
<DockerImageDetails deployment={deployment} setShowDockerInfo={setShowDockerInfo} />
622649
)}
623650
</div>
651+
624652
</div>
653+
625654
{!(selectedDeploymentHistoryIndex === 0 || isVirtualEnvironment) && (
626655
<Tippy className="default-tt" arrow={false} content="Re-deploy this version">
627656
<button
@@ -638,6 +667,8 @@ const ChartDeploymentHistory = ({
638667
<DockerListModal dockerList={deployment.dockerImages} closeTab={closeDockerInfoTab} />
639668
)}
640669
</div>
670+
{getViewMessage()}
671+
641672
</div>
642673
)
643674
}
@@ -711,7 +742,7 @@ const ChartDeploymentHistory = ({
711742
{renderDeploymentCards()}
712743
</div>
713744
</div>
714-
<div className="ci-details__body">{renderSelectedDeploymentDetail()}</div>
745+
<div className="ci-details__body dc__overflow-scroll">{renderSelectedDeploymentDetail()}</div>
715746
{showRollbackConfirmation && (
716747
<RollbackConfirmationDialog
717748
deploying={deploying}

src/components/v2/chartDeploymentHistory/DockerImageDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const DockerImageDetails = ({ deployment, setShowDockerInfo }: DockerImageDetail
2525
return (
2626
<>
2727
{deployment.dockerImages.slice(0, 3).map((dockerImage) => (
28-
<div key={dockerImage} className="dc__app-commit__hash ml-10">
28+
<div key={dockerImage} className="dc__app-commit__hash">
2929
<Tippy arrow className="default-tt" content={dockerImage}>
3030
<span className="flex">
3131
<DockerIcon className="commit-hash__icon grayscale" />

src/components/v2/chartDeploymentHistory/chartDeploymentHistory.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,10 @@
113113
max-height: 444px;
114114
}
115115
}
116+
117+
.trigger-details {
118+
.trigger-details__grid-helm {
119+
display: grid;
120+
grid-template-columns: 52px 1fr;
121+
}
122+
}

src/components/v2/chartDeploymentHistory/chartDeploymentHistory.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ export interface ChartDeploymentDetail {
4343
deployedAt: DeployedAt
4444
deployedBy: string
4545
status: string
46+
message?: string
4647
}
4748

4849
export interface RollbackReleaseRequest {

src/css/base.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4904,6 +4904,10 @@ textarea::placeholder {
49044904
grid-template-columns: 50% 50%;
49054905
}
49064906

4907+
.dc__grid {
4908+
display: grid;
4909+
}
4910+
49074911
.cd-material {
49084912
// Replace bulk ci/cd sidebar css with this one when moving a common component
49094913
&__container-with-sidebar {

0 commit comments

Comments
 (0)