Skip to content

Commit

Permalink
Merge branch 'main' into rix0rrr-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Dec 2, 2022
2 parents 7ab3e49 + f5fe69a commit fae8376
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/close-stale-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
name: Stale issue job
steps:
- uses: aws-actions/stale-issue-cleanup@v6
- uses: aws-actions/stale-issue-cleanup@v5
with:
# Setting messages to an empty string will cause the automation to skip
# that category
Expand Down
8 changes: 8 additions & 0 deletions packages/aws-cdk/lib/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Command, Configuration, Settings } from '../lib/settings';
import * as version from '../lib/version';
import { DeploymentMethod } from './api';
import { enableTracing } from './util/tracing';
import { checkForPlatformWarnings } from './platform-warnings';

// https://github.com/yargs/yargs/issues/1929
// https://github.com/evanw/esbuild/issues/1492
Expand Down Expand Up @@ -294,6 +295,13 @@ async function initCommandLine() {
if (argv.ci) {
setCI(true);
}

try {
await checkForPlatformWarnings();
} catch (e) {
debug(`Error while checking for platform warnings: ${e}`);
}

debug('CDK toolkit version:', version.DISPLAY_VERSION);
debug('Command line arguments:', argv);

Expand Down
41 changes: 41 additions & 0 deletions packages/aws-cdk/lib/platform-warnings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import * as os from 'os';
import * as logging from './logging';
import * as fs from 'fs-extra';

export async function checkForPlatformWarnings() {
if (await hasDockerCopyBug()) {
logging.warning('`cdk synth` may hang in Docker on Linux 5.6-5.10. See https://github.com/aws/aws-cdk/issues/21379 for workarounds.');
}
}

async function hasDockerCopyBug() {
return await runningInDocker() && os.platform() === 'linux' && isVersionBetween(os.release(), '5.6', '5.10');
}

async function runningInDocker() {
return fs.pathExists('/.dockerenv');
}

export function isVersionBetween(version: string, lower: string, upper: string) {
const ver = splitVersion(version);
const lo = splitVersion(lower);
const up = splitVersion(upper);

while (lo.length < ver.length) { lo.push(0); }
while (up.length < ver.length) { up.push(9999999); }

let n = ver.length;
for (let i = 0; i < n; i++) {
if (lo[i] < ver[i] && ver[i] < up[i]) { return true; }
if (lo[i] > ver[i] || ver[i] > up[i]) { return false; }
}

return false;

}

function splitVersion(version: string): number[] {
return `${version}`.split('.')
.map(x => parseInt(x, 10))
.map(x => isNaN(x) ? 0 : x);
}
15 changes: 15 additions & 0 deletions packages/aws-cdk/test/platform-warnings.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { isVersionBetween } from '../lib/platform-warnings';


test.each([
['2.1', false],
['2.2', true],
['2', false],
['3', true],
['4', false],
['4.3', true],
['4.3', true],
['4.2.294-220.533.amzn2.x86_64', true],
])('%p is in range: %p', (version, expected) => {
expect(isVersionBetween(version, '2.1.0.6', '4.9.2')).toEqual(expected);
});

0 comments on commit fae8376

Please sign in to comment.