Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-disable no-console */

import { spawn } from 'child_process';
import { STSClient, AssumeRoleCommand } from '@aws-sdk/client-sts';
import { AtmosphereAllocation } from './atmosphere';
Expand Down Expand Up @@ -53,7 +53,20 @@ export const deployIntegTests = async (props: {
console.error(e);
hasFailure = true;
} finally {
await allocation.release(outcome);
try {
await allocation.release(outcome);
} catch (e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we catch the token expired error only and not all the errors? Otherwise we're going to hide other problems

Copy link
Member Author

@Abogical Abogical Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It already leaves a warning annotation for any errors, including expired tokens.
  • Regardless of the error, I don't think that an error when it comes to releasing should be fatal and stop the entire test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regardless of the error, I don't think that an error when it comes to releasing should be fatal and stop the entire test.

I disagree! if we think so then we shouldn't need to release at all. If we think the release is important but we know that there's a specific case isn't important then only catch gracefully this case but not all

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I've made the error caught only if it is due to an expired security token.

if (e instanceof Error && e.message.includes('The security token included in the request is expired')) {
// In case of timeouts, the expired security token error can occur. We can skip the release as it will automatically be deleted.
// Atmosphere will automatically release the resource if a timeout occurs on the backend.
//
// Log uses Github warning syntax, see: https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-commands#setting-a-warning-message
console.warn(`::warning::Atmosphere allocation release failed: ${e}`);
console.warn('Skipping release request as we assume its caused by an integ test timing out.');
} else {
throw e;
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,26 @@ describe('Run Integration Tests with Atmosphere', () => {

validateSnapshotRun({ batchSize: 3 });
});

test('failed Atmosphere release requests after timeout creates a warning and proceeds with the next batch', async () => {
jest.spyOn(integRunner, 'deployIntegrationTest').mockImplementation(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of mocking this part?

Copy link
Member Author

@Abogical Abogical Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to simulate an integration test failure caused by a timeout. This is the same scenario where the original bug occured: https://github.com/aws/aws-cdk/actions/runs/20137124927/job/57793467916#step:12:475

return Promise.reject(new Error('Integration tests failed with exit code 1'));
});

jest.spyOn(mockAtmosphereAllocation, 'release').mockImplementation(() => {
return Promise.reject(new Error('The security token included in the request is expired'));
});

const consoleSpy = jest.spyOn(console, 'warn').mockImplementation();

await expect(integRunner.deployIntegTests({ atmosphereRoleArn, endpoint, pool })).rejects.toThrow(
'Deployment integration test did not pass',
);

expect(consoleSpy).toHaveBeenCalledWith(expect.stringContaining('::warning::Atmosphere allocation release failed: Error: The security token included in the request is expired'));

consoleSpy.mockRestore();

validateSnapshotRun({ batchSize: 3 });
});
});
Loading