Skip to content

Commit

Permalink
[v16] Web discover minor fixes (#49006)
Browse files Browse the repository at this point in the history
* Remove optional wording (no longer optional)

* Fix incorrect log app name

* Show already exists error messages instead of making it seem we are still searching

* Address CRs

* Fix story and button

* Update e
  • Loading branch information
kimlisa authored Nov 15, 2024
1 parent 332ca14 commit 6c86959
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 20 deletions.
2 changes: 1 addition & 1 deletion e
Submodule e updated from da9c34 to b33962
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function AutoDeploy({ toggleDeployMethod }: DeployServiceProp) {

<StyledBox mb={5}>
<header>
<H3>Step 3 (Optional)</H3>
<H3>Step 3</H3>
</header>
<SelectSecurityGroups
selectedSecurityGroups={selectedSecurityGroups}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export function AgentWaitingDialog({
- The Teleport Service could not join this Teleport cluster. Check
the logs for errors by running
<br />
<Mark>kubectl logs -l app=teleport-agent -n teleport-agent</Mark>
<Mark>
kubectl logs -l app=teleport-kube-agent -n teleport-agent
</Mark>
</Text>

<Text>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ WithAwsPermissionsError.parameters = {
};

export const WithEnrollmentError = () => <Component />;

WithEnrollmentError.parameters = {
msw: {
handlers: [
Expand Down Expand Up @@ -209,6 +208,46 @@ WithEnrollmentError.parameters = {
},
};

export const WithAlreadyExistsError = () => (
<Component devInfoText="select any region, select EKS1 to see already exist error" />
);
WithAlreadyExistsError.parameters = {
msw: {
handlers: [
tokenHandler,
rest.post(cfg.getListEKSClustersUrl(integrationName), (req, res, ctx) => {
{
return res(ctx.json({ clusters: eksClusters }));
}
}),
rest.get(
cfg.getKubernetesUrl(getUserContext().cluster.clusterId, {}),
(req, res, ctx) => {
return res(ctx.json({ items: kubeServers }));
}
),
rest.post(
cfg.getEnrollEksClusterUrl(integrationName),
async (req, res, ctx) => {
return res(
ctx.delay(1000),
ctx.status(200),
ctx.json({
results: [
{
clusterName: 'EKS1',
error:
'teleport-kube-agent is already installed on the cluster',
},
],
})
);
}
),
],
},
};

export const WithOtherError = () => <Component />;

WithOtherError.parameters = {
Expand All @@ -222,7 +261,7 @@ WithOtherError.parameters = {
},
};

const Component = () => {
const Component = ({ devInfoText = '' }) => {
const ctx = createTeleportContext();
const discoverCtx: DiscoverContextState = {
agentMeta: {
Expand Down Expand Up @@ -278,7 +317,9 @@ const Component = () => {
resourceKind={ResourceKind.Kubernetes}
>
<DiscoverProvider mockCtx={discoverCtx}>
<Info>Devs: Select any region to see story state</Info>
<Info>
{devInfoText || 'Devs: Select any region to see story state'}
</Info>
<EnrollEksCluster
nextStep={discoverCtx.nextStep}
updateAgentMeta={discoverCtx.updateAgentMeta}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ export type CheckedEksCluster = AwsEksCluster & {
};

type EKSClusterEnrollmentState = {
status: 'notStarted' | 'enrolling' | 'awaitingAgent' | 'success' | 'error';
status:
| 'notStarted'
| 'enrolling'
| 'awaitingAgent'
| 'success'
| 'error'
| 'alreadyExists';
error?: string;
};

Expand Down Expand Up @@ -294,16 +300,19 @@ export function EnrollEksCluster(props: AgentStepProps) {
emitErrorEvent(
'unknown error: no results came back from enrolling the EKS cluster.'
);
} else if (
result.error &&
!result.error.includes(
'teleport-kube-agent is already installed on the cluster'
)
) {
setEnrollmentState({
} else if (result.error) {
const errorState: EKSClusterEnrollmentState = {
status: 'error',
error: `Cluster enrollment error: ${result.error}`,
});
};
if (
result.error.includes(
'teleport-kube-agent is already installed on the cluster'
)
) {
errorState.status = 'alreadyExists';
}
setEnrollmentState(errorState);
emitErrorEvent(`failed to enroll EKS cluster: ${result.error}`);
} else {
setEnrollmentState({ status: 'awaitingAgent' });
Expand Down Expand Up @@ -505,7 +514,8 @@ export function EnrollEksCluster(props: AgentStepProps) {
</Box>
)}
{(enrollmentState.status === 'enrolling' ||
enrollmentState.status === 'error') && (
enrollmentState.status === 'error' ||
enrollmentState.status === 'alreadyExists') && (
<EnrollmentDialog
clusterName={selectedCluster.name}
close={closeEnrollmentDialog}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,20 @@ export function EnrollmentDialog({
);

case 'error':
case 'alreadyExists':
return (
<>
<Flex mb={5} alignItems="center">
<Icons.Warning size="large" ml={1} mr={2} color="error.main" />
<Text>{error}</Text>
</Flex>
<Flex gap={4}>
<ButtonPrimary width="50%" onClick={retry}>
Retry
</ButtonPrimary>
<ButtonSecondary width="50%" onClick={close}>
{status === 'error' && (
<ButtonPrimary width="50%" onClick={retry}>
Retry
</ButtonPrimary>
)}
<ButtonSecondary width="86px" onClick={close}>
Close
</ButtonSecondary>
</Flex>
Expand Down

0 comments on commit 6c86959

Please sign in to comment.