Skip to content

Commit

Permalink
Add retry with relogin to change target port
Browse files Browse the repository at this point in the history
  • Loading branch information
ravicious committed Jan 13, 2025
1 parent 1dd43af commit 41b1f2e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
8 changes: 6 additions & 2 deletions lib/teleterm/daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,12 @@ func (s *Service) SetGatewayTargetSubresourceName(ctx context.Context, gatewayUR
return nil, trace.Wrap(err)
}

app, err := clusters.GetApp(ctx, clusterClient.CurrentCluster(), targetURI.GetAppName())
if err != nil {
var app types.Application
if err := clusters.AddMetadataToRetryableError(ctx, func() error {
var err error
app, err = clusters.GetApp(ctx, clusterClient.CurrentCluster(), targetURI.GetAppName())
return trace.Wrap(err)
}); err != nil {
return nil, trace.Wrap(err)
}

Expand Down
30 changes: 19 additions & 11 deletions web/packages/teleterm/src/ui/DocumentGateway/useGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,18 +100,26 @@ export function useGateway(doc: DocumentGateway) {
const [changeTargetSubresourceNameAttempt, changeTargetSubresourceName] =
useAsync(
useCallback(
async (name: string) => {
const updatedGateway =
await clustersService.setGatewayTargetSubresourceName(
doc.gatewayUri,
name
);
(name: string) =>
retryWithRelogin(ctx, doc.targetUri, async () => {
const updatedGateway =
await clustersService.setGatewayTargetSubresourceName(
doc.gatewayUri,
name
);

documentsService.update(doc.uri, {
targetSubresourceName: updatedGateway.targetSubresourceName,
});
},
[clustersService, documentsService, doc.uri, doc.gatewayUri]
documentsService.update(doc.uri, {
targetSubresourceName: updatedGateway.targetSubresourceName,
});
}),
[
clustersService,
documentsService,
doc.uri,
doc.gatewayUri,
ctx,
doc.targetUri,
]
)
);

Expand Down

0 comments on commit 41b1f2e

Please sign in to comment.