forked from aws/aws-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cli): large context causes E2BIG error during synthesis on Linux (a…
…ws#21373) Linux systems don't support environment variables larger than 128KiB. This change splits the context into two if it's larger than that and stores the overflow into a temporary file. The application then re-constructs the original context from these two sources. A special case is when this new version of the CLI is used to synthesize an application that depends on an old version of the framework. The application will still consume part of the context, but the CLI warns the user that some of it has been lost. Since the tree manipulation logic is basically the same as the one used for displaying notices, it was extracted into its own file. Re-roll aws#21230 Fixes aws#19261 ---- ### All Submissions: * [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Unconventional Dependencies: * [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* Instead of passing the context in an environment variable, the CLI now writes the context to a temporary file and sets an environment variable only with the location. The app then uses that location to read from the file. Also tested manually on a Linux machine. Re-roll aws#21230 Fixes aws#19261
- Loading branch information
1 parent
61b2ab7
commit 7040168
Showing
11 changed files
with
344 additions
and
67 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
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,58 @@ | ||
import * as path from 'path'; | ||
import { CloudAssembly } from '@aws-cdk/cx-api'; | ||
import * as fs from 'fs-extra'; | ||
import { trace } from './logging'; | ||
|
||
/** | ||
* Source information on a construct (class fqn and version) | ||
*/ | ||
export interface ConstructInfo { | ||
readonly fqn: string; | ||
readonly version: string; | ||
} | ||
|
||
/** | ||
* A node in the construct tree. | ||
*/ | ||
export interface ConstructTreeNode { | ||
readonly id: string; | ||
readonly path: string; | ||
readonly children?: { [key: string]: ConstructTreeNode }; | ||
readonly attributes?: { [key: string]: any }; | ||
|
||
/** | ||
* Information on the construct class that led to this node, if available | ||
*/ | ||
readonly constructInfo?: ConstructInfo; | ||
} | ||
|
||
/** | ||
* Whether the provided predicate is true for at least one element in the construct (sub-)tree. | ||
*/ | ||
export function some(node: ConstructTreeNode, predicate: (n: ConstructTreeNode) => boolean): boolean { | ||
return node != null && (predicate(node) || findInChildren()); | ||
|
||
function findInChildren(): boolean { | ||
return Object.values(node.children ?? {}).some(child => some(child, predicate)); | ||
} | ||
} | ||
|
||
export function loadTree(assembly: CloudAssembly) { | ||
try { | ||
const outdir = assembly.directory; | ||
const fileName = assembly.tree()?.file; | ||
return fileName ? fs.readJSONSync(path.join(outdir, fileName)).tree : {}; | ||
} catch (e) { | ||
trace(`Failed to get tree.json file: ${e}. Proceeding with empty tree.`); | ||
return {}; | ||
} | ||
} | ||
|
||
export function loadTreeFromDir(outdir: string) { | ||
try { | ||
return fs.readJSONSync(path.join(outdir, 'tree.json')).tree; | ||
} catch (e) { | ||
trace(`Failed to get tree.json file: ${e}. Proceeding with empty tree.`); | ||
return {}; | ||
} | ||
} |
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
Oops, something went wrong.