Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Commit

Permalink
Handle inconsistent API response from Confluent if a Service Account …
Browse files Browse the repository at this point in the history
…already exists (#52)
  • Loading branch information
SEQUOIIA authored Jul 27, 2022
1 parent 7ff4db4 commit 22d08e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion server/src/server/wrapper/connected/CcloudServiceAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export class CcloudServiceAccount implements ServiceAccounts {
throw (error);
}

if (error.consoleLines.some((l: string): boolean => l.includes("is already in use"))) {
// "Error: service name "NAME-HERE" is already in use" is usually returned if the service account exists
// "Error: Service Account Not Found: 404 Not Found" can also be returned if the service account exists.. for some reason. Confluent is looking into why but are currently unable to reproduce in a different environment.
if (error.consoleLines.some((l: string): boolean => l.includes("is already in use")) || error.consoleLines.some((l: string): boolean => l.includes("404 Not Found"))) {
let existingServicesAccounts = await this.getServiceAccounts();

let existingServicesAccount = existingServicesAccounts.find(s => s.Name === accountName);
Expand Down
6 changes: 5 additions & 1 deletion server/src/server/wrapper/connected/executeCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ export function executeCli(args: string[]): Promise<string[]> {
return reject(new CcloudSessionExpiredException());
}

reject(new CliException(exitCode, errLines));
let combinedLines : any = [];
combinedLines = combinedLines.concat(lines);
combinedLines = combinedLines.concat(errLines);

reject(new CliException(exitCode, combinedLines));
});
});
}

0 comments on commit 22d08e8

Please sign in to comment.