Skip to content

Conversation

@lovisaberggren
Copy link
Collaborator

@lovisaberggren lovisaberggren commented Jan 23, 2025

Proposed changes

Did some fixes of the IPA release workflow, added some extra error handling and logging for easier troubleshooting, and some refactoring, including splitting release-IPA-metrics.yml into two jobs, one for checking if the release should run, and the second for doing the release (skipped depending on the first step).

Tested the run manually on this branch, and it's passing: https://github.com/mongodb/openapi/actions/runs/12934985049

Next steps

  • Include workflow in OAS release workflow
  • Pass secrets and vars from OAS release workflow to release-IPA-metrics.yml
  • Download foas and use in release-IPA-metrics.yml instead of local v2.json

Later on, when we confirmed that it works as expected with the OAS release workflow, we'll change to start using the prod S3 bucket.

Jira ticket: CLOUDP-290416

@lovisaberggren lovisaberggren marked this pull request as ready for review January 23, 2025 14:45
@lovisaberggren lovisaberggren requested a review from a team as a code owner January 23, 2025 14:45
@lovisaberggren lovisaberggren marked this pull request as draft January 23, 2025 14:49
@lovisaberggren lovisaberggren changed the title CLOUDP-290416: Fix metrict get last run script CLOUDP-290416: Fix and refactor IPA metrics release workflow Jan 23, 2025
@lovisaberggren lovisaberggren marked this pull request as ready for review January 23, 2025 17:57
name: openapi-foas-dev # TODO: Change to passed input env
github-token: ${{ secrets.api_bot_pat }}
run-id: ${{ github.run_id }}
# - name: Download openapi-foas
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: What is the reason for commenting them out?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I realized that when running the workflow independently, the foas isn't generated and uploaded first, so it can't be found here, so for now I'm using the v2 spec in the repo, but when moving the workflow into the release oas workflow, we can use this again as the foas is generated here in an earlier step

process.exit(1);
});

if (!response) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: This if check here might be redundant. I could not think of any case uploadMetricCollectionDataToS3 will return null or undefined.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added this check because if the table creation fails due to the json not being iterable, the function will just return undefined (I think it's something with the library, imo it should error but it doesn't), I had this issue before when passing the wrong file as the collection data, which just resulted in undefined being returned, but the script should fail in this instance, so it's an extra check to make sure we actually get some result in the end

Copy link
Collaborator

Choose a reason for hiding this comment

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

So, this code block does not return an error somehow, am I right?

const table = tableFromJSON(metricsCollectionData);
  if (table === undefined) {
    throw new Error('Unable to transform metrics collection data to table');
  }

Sure, just wanted to be sure if it is not redundant 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah at least not for this particular case, adding these extra checks just as a precaution in case something isn't working as expected 👍

owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: context.workflow,
workflow_id: 'release-IPA-metrics.yml',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: Why do we need to specify the workflow name?

Copy link
Collaborator

Choose a reason for hiding this comment

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

The reason I am asking: when it starts working as a part of Release job, do we need to change this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When fetching the previous runs from the api, you use the workflow name or ID to specify which workflow you want to get the previous runs for

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

So, it is not enough to get the workflow from context but we should give the name explicitly. Good find 👍

Copy link
Collaborator

@yelizhenden-mdb yelizhenden-mdb left a comment

Choose a reason for hiding this comment

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

LGTM!

@lovisaberggren lovisaberggren merged commit f321972 into main Jan 24, 2025
13 checks passed
@lovisaberggren lovisaberggren deleted the CLOUDP-290416 branch January 24, 2025 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants