Skip to content

Commit edaf631

Browse files
committed
fix: change SCC mismatch from blocking error to warning
Based on code review feedback: - Move SCC mismatch message to a constant (SCC_MISMATCH_WARNING_MESSAGE) - Allow workspace start when containerScc is undefined - Update message to emphasize SCC difference instead of nested capabilities - Change from blocking error to warning - dashboard should not prevent workspace from starting The hasSccMismatch() function now returns false when containerScc is undefined, allowing workspaces created before SCC attribute was added to start normally. Status indicators now show warning icon instead of failed status, and start actions log a warning instead of throwing an error. Signed-off-by: Oleksii Orel <oorel@redhat.com>
1 parent 8e32a58 commit edaf631

File tree

11 files changed

+512
-116
lines changed

11 files changed

+512
-116
lines changed

packages/dashboard-frontend/src/components/Workspace/Status/Indicator/__tests__/Indicator.spec.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,26 +102,40 @@ describe('Workspace indicator component', () => {
102102
});
103103

104104
describe('SCC Mismatch', () => {
105-
it('should render FAILED status with SCC mismatch tooltip when containerScc does not match currentScc', () => {
105+
it('should render warning triangle icon for STOPPED workspace when containerScc does not match currentScc', () => {
106106
const element = (
107107
<WorkspaceStatusIndicator status={DevWorkspaceStatus.STOPPED} containerScc="restricted" />
108108
);
109109
expect(getComponentSnapshot(element, 'anyuid')).toMatchSnapshot();
110110
});
111111

112-
it('should render normal status when containerScc matches currentScc', () => {
112+
it('should render warning for STOPPED workspace when containerScc is undefined but currentScc is defined', () => {
113113
const element = (
114-
<WorkspaceStatusIndicator status={DevWorkspaceStatus.RUNNING} containerScc="anyuid" />
114+
<WorkspaceStatusIndicator status={DevWorkspaceStatus.STOPPED} containerScc={undefined} />
115115
);
116116
expect(getComponentSnapshot(element, 'anyuid')).toMatchSnapshot();
117117
});
118118

119-
it('should render normal status when containerScc is undefined', () => {
119+
it('should render normal status for RUNNING workspace even with SCC mismatch', () => {
120120
const element = (
121-
<WorkspaceStatusIndicator status={DevWorkspaceStatus.RUNNING} containerScc={undefined} />
121+
<WorkspaceStatusIndicator status={DevWorkspaceStatus.RUNNING} containerScc="restricted" />
122+
);
123+
expect(getComponentSnapshot(element, 'anyuid')).toMatchSnapshot();
124+
});
125+
126+
it('should render normal status when containerScc matches currentScc', () => {
127+
const element = (
128+
<WorkspaceStatusIndicator status={DevWorkspaceStatus.STOPPED} containerScc="anyuid" />
122129
);
123130
expect(getComponentSnapshot(element, 'anyuid')).toMatchSnapshot();
124131
});
132+
133+
it('should render normal status when currentScc is undefined (server has no SCC requirement)', () => {
134+
const element = (
135+
<WorkspaceStatusIndicator status={DevWorkspaceStatus.STOPPED} containerScc={undefined} />
136+
);
137+
expect(getComponentSnapshot(element, undefined)).toMatchSnapshot();
138+
});
125139
});
126140
});
127141

packages/dashboard-frontend/src/components/Workspace/Status/Indicator/__tests__/__snapshots__/Indicator.spec.tsx.snap

Lines changed: 150 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ exports[`Workspace indicator component DevWorkspaces should render STOPPED statu
545545
</div>
546546
`;
547547

548-
exports[`Workspace indicator component SCC Mismatch should render FAILED status with SCC mismatch tooltip when containerScc does not match currentScc 1`] = `
548+
exports[`Workspace indicator component SCC Mismatch should render normal status for RUNNING workspace even with SCC mismatch 1`] = `
549549
<div
550550
data-testid="patternfly-tooltip"
551551
>
@@ -557,38 +557,21 @@ exports[`Workspace indicator component SCC Mismatch should render FAILED status
557557
<div
558558
data-testid="tooltip-content"
559559
>
560-
<span>
561-
Cannot start: Administrator enabled nested container capabilities. This workspace was created before this change and cannot be started.
562-
563-
<a
564-
href="https://eclipse.dev/che/docs/stable/administration-guide/enabling-container-run-capabilities/"
565-
onClick={[Function]}
566-
rel="noopener noreferrer"
567-
style={
568-
{
569-
"color": "#73bcf7",
570-
"textDecoration": "underline",
571-
}
572-
}
573-
target="_blank"
574-
>
575-
Learn more
576-
</a>
577-
</span>
560+
RUNNING
578561
</div>
579562
<div
580563
data-testid="tooltip-placed-to"
581564
>
582565
<span
583-
aria-label="Workspace status is Failed"
566+
aria-label="Workspace status is Running"
584567
className="statusIndicator"
585568
data-testid="workspace-status-indicator"
586569
>
587570
<span
588571
className="pf-c-icon pf-m-inline"
589572
>
590573
<span
591-
className="pf-c-icon__content pf-m-warning"
574+
className="pf-c-icon__content pf-m-success"
592575
>
593576
<svg
594577
aria-hidden={true}
@@ -601,11 +584,70 @@ exports[`Workspace indicator component SCC Mismatch should render FAILED status
601584
"verticalAlign": "-0.125em",
602585
}
603586
}
604-
viewBox="0 0 576 512"
587+
viewBox="0 0 1024 1024"
605588
width="1em"
606589
>
607590
<path
608-
d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"
591+
d="M512.1,0 C229.7,0 0,229.8 0,512 C0,794.3 229.8,1024 512.1,1024 C794.4,1024 1024,794.3 1024,512 C1024,229.7 794.4,0 512.1,0 Z M512,896 C300.2,896 128,723.9 128,512 C128,300.3 300.2,128 512,128 C723.7,128 896,300.2 896,512 C896,723.8 723.7,896 512,896 Z M512,224 C671.1,224 800,352.9 800,512 C800,671.1 671.1,800 512,800 C352.9,800 224,671.1 224,512 C224,352.9 352.9,224 512,224"
592+
/>
593+
</svg>
594+
</span>
595+
</span>
596+
</span>
597+
</div>
598+
</div>
599+
`;
600+
601+
exports[`Workspace indicator component SCC Mismatch should render normal status when containerScc matches currentScc 1`] = `
602+
<div
603+
data-testid="patternfly-tooltip"
604+
>
605+
<span
606+
data-testid="tooltip-props"
607+
>
608+
{"isContentLeftAligned":true,"className":"tooltip"}
609+
</span>
610+
<div
611+
data-testid="tooltip-content"
612+
>
613+
STOPPED
614+
</div>
615+
<div
616+
data-testid="tooltip-placed-to"
617+
>
618+
<span
619+
aria-label="Workspace status is Stopped"
620+
className="statusIndicator"
621+
data-testid="workspace-status-indicator"
622+
>
623+
<span
624+
className="pf-c-icon pf-m-inline"
625+
>
626+
<span
627+
className="pf-c-icon__content pf-m-default"
628+
>
629+
<svg
630+
aria-hidden="true"
631+
fill="var(--pf-global--palette--black-500)"
632+
height="1em"
633+
role="img"
634+
style={
635+
{
636+
"verticalAlign": "-0.125em",
637+
}
638+
}
639+
viewBox="0 0 16 16"
640+
width="1em"
641+
>
642+
<path
643+
d="M8.001,0 C3.589,0 0,3.590 0,8 C0,12.410 3.590,16 8.001,16 C12.412,16 16,12.410
644+
16,8 C16,3.589 12.4125,0 8.001,0 Z M8,14 C4.690,14 2,11.310 2,8 C2,4.692 4.690,2
645+
8,2 C11.307,2 14,4.690 14,8 C14,11.309 11.307,14 8,14 Z"
646+
/>
647+
<path
648+
d="M8.001,3.5 C5.519,3.5 3.5,5.520 3.5,8 C3.5,10.481 5.520,12.5 8.000,12.5 C10.482,12.5 12.5,10.481
649+
12.5,8 C12.5,5.519 10.482,3.5 8.000,3.5 Z M8,10.75 C6.483,10.75 5.25,9.517 5.25,8 C5.25,6.484
650+
6.483,5.25 8,5.25 C9.516,5.25 10.75,6.483 10.75,8 C10.75,9.516 9.516,10.75 8,10.75 Z"
609651
/>
610652
</svg>
611653
</span>
@@ -615,7 +657,66 @@ exports[`Workspace indicator component SCC Mismatch should render FAILED status
615657
</div>
616658
`;
617659

618-
exports[`Workspace indicator component SCC Mismatch should render normal status when containerScc is undefined 1`] = `
660+
exports[`Workspace indicator component SCC Mismatch should render normal status when currentScc is undefined (server has no SCC requirement) 1`] = `
661+
<div
662+
data-testid="patternfly-tooltip"
663+
>
664+
<span
665+
data-testid="tooltip-props"
666+
>
667+
{"isContentLeftAligned":true,"className":"tooltip"}
668+
</span>
669+
<div
670+
data-testid="tooltip-content"
671+
>
672+
STOPPED
673+
</div>
674+
<div
675+
data-testid="tooltip-placed-to"
676+
>
677+
<span
678+
aria-label="Workspace status is Stopped"
679+
className="statusIndicator"
680+
data-testid="workspace-status-indicator"
681+
>
682+
<span
683+
className="pf-c-icon pf-m-inline"
684+
>
685+
<span
686+
className="pf-c-icon__content pf-m-default"
687+
>
688+
<svg
689+
aria-hidden="true"
690+
fill="var(--pf-global--palette--black-500)"
691+
height="1em"
692+
role="img"
693+
style={
694+
{
695+
"verticalAlign": "-0.125em",
696+
}
697+
}
698+
viewBox="0 0 16 16"
699+
width="1em"
700+
>
701+
<path
702+
d="M8.001,0 C3.589,0 0,3.590 0,8 C0,12.410 3.590,16 8.001,16 C12.412,16 16,12.410
703+
16,8 C16,3.589 12.4125,0 8.001,0 Z M8,14 C4.690,14 2,11.310 2,8 C2,4.692 4.690,2
704+
8,2 C11.307,2 14,4.690 14,8 C14,11.309 11.307,14 8,14 Z"
705+
/>
706+
<path
707+
d="M8.001,3.5 C5.519,3.5 3.5,5.520 3.5,8 C3.5,10.481 5.520,12.5 8.000,12.5 C10.482,12.5 12.5,10.481
708+
12.5,8 C12.5,5.519 10.482,3.5 8.000,3.5 Z M8,10.75 C6.483,10.75 5.25,9.517 5.25,8 C5.25,6.484
709+
6.483,5.25 8,5.25 C9.516,5.25 10.75,6.483 10.75,8 C10.75,9.516 9.516,10.75 8,10.75 Z"
710+
/>
711+
</svg>
712+
</span>
713+
</span>
714+
</span>
715+
</div>
716+
</div>
717+
`;
718+
719+
exports[`Workspace indicator component SCC Mismatch should render warning for STOPPED workspace when containerScc is undefined but currentScc is defined 1`] = `
619720
<div
620721
data-testid="patternfly-tooltip"
621722
>
@@ -628,7 +729,7 @@ exports[`Workspace indicator component SCC Mismatch should render normal status
628729
data-testid="tooltip-content"
629730
>
630731
<span>
631-
Cannot start: Administrator enabled nested container capabilities. This workspace was created before this change and cannot be started.
732+
The workspace was created with a different container SCC (Security Context Constraint) than what is currently configured. The workspace may fail to start.
632733
633734
<a
634735
href="https://eclipse.dev/che/docs/stable/administration-guide/enabling-container-run-capabilities/"
@@ -650,7 +751,7 @@ exports[`Workspace indicator component SCC Mismatch should render normal status
650751
data-testid="tooltip-placed-to"
651752
>
652753
<span
653-
aria-label="Workspace status is Failed"
754+
aria-label="Workspace status has SCC mismatch warning"
654755
className="statusIndicator"
655756
data-testid="workspace-status-indicator"
656757
>
@@ -685,7 +786,7 @@ exports[`Workspace indicator component SCC Mismatch should render normal status
685786
</div>
686787
`;
687788

688-
exports[`Workspace indicator component SCC Mismatch should render normal status when containerScc matches currentScc 1`] = `
789+
exports[`Workspace indicator component SCC Mismatch should render warning triangle icon for STOPPED workspace when containerScc does not match currentScc 1`] = `
689790
<div
690791
data-testid="patternfly-tooltip"
691792
>
@@ -697,21 +798,38 @@ exports[`Workspace indicator component SCC Mismatch should render normal status
697798
<div
698799
data-testid="tooltip-content"
699800
>
700-
RUNNING
801+
<span>
802+
The workspace was created with a different container SCC (Security Context Constraint) than what is currently configured. The workspace may fail to start.
803+
804+
<a
805+
href="https://eclipse.dev/che/docs/stable/administration-guide/enabling-container-run-capabilities/"
806+
onClick={[Function]}
807+
rel="noopener noreferrer"
808+
style={
809+
{
810+
"color": "#73bcf7",
811+
"textDecoration": "underline",
812+
}
813+
}
814+
target="_blank"
815+
>
816+
Learn more
817+
</a>
818+
</span>
701819
</div>
702820
<div
703821
data-testid="tooltip-placed-to"
704822
>
705823
<span
706-
aria-label="Workspace status is Running"
824+
aria-label="Workspace status has SCC mismatch warning"
707825
className="statusIndicator"
708826
data-testid="workspace-status-indicator"
709827
>
710828
<span
711829
className="pf-c-icon pf-m-inline"
712830
>
713831
<span
714-
className="pf-c-icon__content pf-m-success"
832+
className="pf-c-icon__content pf-m-warning"
715833
>
716834
<svg
717835
aria-hidden={true}
@@ -724,11 +842,11 @@ exports[`Workspace indicator component SCC Mismatch should render normal status
724842
"verticalAlign": "-0.125em",
725843
}
726844
}
727-
viewBox="0 0 1024 1024"
845+
viewBox="0 0 576 512"
728846
width="1em"
729847
>
730848
<path
731-
d="M512.1,0 C229.7,0 0,229.8 0,512 C0,794.3 229.8,1024 512.1,1024 C794.4,1024 1024,794.3 1024,512 C1024,229.7 794.4,0 512.1,0 Z M512,896 C300.2,896 128,723.9 128,512 C128,300.3 300.2,128 512,128 C723.7,128 896,300.2 896,512 C896,723.8 723.7,896 512,896 Z M512,224 C671.1,224 800,352.9 800,512 C800,671.1 671.1,800 512,800 C352.9,800 224,671.1 224,512 C224,352.9 352.9,224 512,224"
849+
d="M569.517 440.013C587.975 472.007 564.806 512 527.94 512H48.054c-36.937 0-59.999-40.055-41.577-71.987L246.423 23.985c18.467-32.009 64.72-31.951 83.154 0l239.94 416.028zM288 354c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"
732850
/>
733851
</svg>
734852
</span>

packages/dashboard-frontend/src/components/Workspace/Status/Indicator/index.tsx

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { connect, ConnectedProps } from 'react-redux';
1616
import { CheTooltip } from '@/components/CheTooltip';
1717
import { getStatusIcon } from '@/components/Workspace/Status/getStatusIcon';
1818
import styles from '@/components/Workspace/Status/index.module.css';
19+
import { SCC_MISMATCH_WARNING_MESSAGE } from '@/services/helpers/sccMismatch';
1920
import {
2021
DeprecatedWorkspaceStatus,
2122
DevWorkspaceStatus,
@@ -30,20 +31,34 @@ export type Props = MappedProps & {
3031
containerScc: string | undefined;
3132
};
3233

34+
/**
35+
* Check if there's an SCC mismatch between the workspace and server configuration.
36+
* Returns true if server has SCC configured but workspace has different or missing SCC.
37+
*/
38+
function hasSccMismatch(containerScc: string | undefined, currentScc: string | undefined): boolean {
39+
// If server has no SCC requirement, no mismatch
40+
if (currentScc === undefined) {
41+
return false;
42+
}
43+
// Server has SCC requirement - check if workspace matches
44+
return containerScc !== currentScc;
45+
}
46+
3347
class WorkspaceStatusIndicatorComponent extends React.PureComponent<Props> {
3448
public render(): React.ReactElement {
3549
const { status, containerScc, branding, currentScc } = this.props;
3650

37-
const hasSccMismatch = currentScc ? containerScc !== currentScc : false;
51+
// Only check SCC mismatch for stopped workspaces
52+
const isStopped = status === DevWorkspaceStatus.STOPPED;
53+
const sccMismatch = isStopped && hasSccMismatch(containerScc, currentScc);
3854

39-
// If SCC mismatch, show Failed status with special tooltip
40-
if (hasSccMismatch) {
55+
// If SCC mismatch, show warning triangle icon with tooltip
56+
if (sccMismatch) {
4157
const icon = getStatusIcon(DevWorkspaceStatus.FAILED);
4258
const documentationUrl = branding.docs.containerRunCapabilities;
4359
const tooltip = (
4460
<span>
45-
Cannot start: Administrator enabled nested container capabilities. This workspace was
46-
created before this change and cannot be started.
61+
{SCC_MISMATCH_WARNING_MESSAGE}
4762
{documentationUrl && (
4863
<>
4964
{' '}
@@ -66,7 +81,7 @@ class WorkspaceStatusIndicatorComponent extends React.PureComponent<Props> {
6681
<span
6782
className={styles.statusIndicator}
6883
data-testid="workspace-status-indicator"
69-
aria-label="Workspace status is Failed"
84+
aria-label="Workspace status has SCC mismatch warning"
7085
>
7186
{icon}
7287
</span>

0 commit comments

Comments
 (0)