-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow the configuration of executors memory during deploy (#646)
- Add an app update command - Allow memory config during app registration / update
- Loading branch information
Showing
5 changed files
with
105 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import axios, { AxiosError } from "axios"; | ||
import { handleAPIErrors, getCloudCredentials, getLogger, isCloudAPIErrorResponse, retrieveApplicationName, DBOSCloudCredentials } from "../cloudutils.js"; | ||
|
||
export async function updateApp(host: string, appName?: string, executorsMemoryMib?: number, userCredentials?: DBOSCloudCredentials): Promise<number> { | ||
const logger = getLogger(); | ||
if (!userCredentials) { | ||
userCredentials = await getCloudCredentials(host, logger); | ||
} | ||
const bearerToken = "Bearer " + userCredentials.token; | ||
|
||
appName = appName || retrieveApplicationName(logger); | ||
if (!appName) { | ||
return 1; | ||
} | ||
|
||
try { | ||
logger.info(`Updating application: ${appName}`); | ||
await axios.patch( | ||
`https://${host}/v1alpha1/${userCredentials.organization}/applications/${appName}`, | ||
{ | ||
executors_memory_mib: executorsMemoryMib, | ||
}, | ||
{ | ||
headers: { | ||
"Content-Type": "application/json", | ||
Authorization: bearerToken, | ||
}, | ||
} | ||
); | ||
logger.info(`Successfully updated ${appName}!`); | ||
return 0; | ||
} catch (e) { | ||
const errorLabel = `Failed to update application ${appName}`; | ||
const axiosError = e as AxiosError; | ||
if (isCloudAPIErrorResponse(axiosError.response?.data)) { | ||
handleAPIErrors(errorLabel, axiosError); | ||
} else { | ||
logger.error(`${errorLabel}: ${(e as Error).message}`); | ||
} | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters