Skip to content

Commit

Permalink
Web discover minor fixes (#48862)
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
  • Loading branch information
kimlisa authored Nov 14, 2024
1 parent b439b03 commit e58e489
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,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 @@ -165,7 +165,6 @@ WithAwsPermissionsError.parameters = {
};

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

WithEnrollmentError.parameters = {
msw: {
handlers: [
Expand Down Expand Up @@ -194,6 +193,39 @@ WithEnrollmentError.parameters = {
},
};

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

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

WithOtherError.parameters = {
Expand All @@ -212,7 +244,7 @@ WithOtherError.parameters = {
},
};

const Component = () => {
const Component = ({ devInfoText = '' }) => {
const ctx = createTeleportContext();
const discoverCtx: DiscoverContextState = {
agentMeta: {
Expand Down Expand Up @@ -268,7 +300,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 @@ -95,7 +95,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 @@ -302,16 +308,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 @@ -515,7 +524,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,16 +63,19 @@ 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>
{status === 'error' && (
<ButtonPrimary width="50%" onClick={retry}>
Retry
</ButtonPrimary>
)}
<ButtonSecondary width="50%" onClick={close}>
Close
</ButtonSecondary>
Expand Down

0 comments on commit e58e489

Please sign in to comment.