Skip to content

[DT-1361]SnapshotCreateFlight: Create new steps to replace AuthorizeBillingProfileUseStep #1958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

rjohanek
Copy link
Contributor

@rjohanek rjohanek commented Apr 8, 2025

Jira ticket: https://broadworkbench.atlassian.net/browse/DT-1361

Addresses

As a part of our billing migration to rawls, we want to have a period of transition where some billing profiles live in TDR while others have been migrated to rawls. So, we need to handle either case. If it is the rawls case, we need to add new logic to check if the user has access. - Same as Shelby's PR: #1952 which does this work for the DatasetCreateFlight, while this affects the SnapshotCreateFlight

Summary of changes

Update Snapshot Service to check if there is a TDR billing profile and pass it into the flight. In the flight, only run AuthorizeBillingProfileUseStep if there is a TDR billing profile, otherwise only run AuthorizeRawlsBillingProjectsUseStep.

Testing Strategy

Unit tests and manual testing as described in: #1952

To do

Manual Test for Terra billing profile showed there is an issue because the profile model saved in the map during AuthorizeBillingProfileUseStep is used later on in the flight. This is an issue because it is not populated in the Rawls only step, AuthorizeRawlsBillingProjectsUseStep, this causes a null pointer later on.

Error: response status is 500Response bodyDownload{ "message": "Cannot invoke \"bio.terra.model.BillingProfileModel.getBillingAccountId()\" because \"profileModel\" is null", "errorDetail": [ "Cannot invoke \"bio.terra.model.BillingProfileModel.getBillingAccountId()\" because \"profileModel\" is null" ] }

@rjohanek rjohanek requested a review from a team as a code owner April 8, 2025 19:41
@rjohanek rjohanek requested review from rushtong, s-rubenstein, snf2ye and pshapiro4broad and removed request for a team, rushtong and s-rubenstein April 8, 2025 19:41
@rjohanek rjohanek requested a review from fboulnois April 10, 2025 12:08
Copy link
Member

@pshapiro4broad pshapiro4broad left a comment

Choose a reason for hiding this comment

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

Looks OK, just a few comments

boolean isTdrBillingProfile;
try {
getProfileByIdNoCheck(defaultProfileId);
isTdrBillingProfile = true;
Copy link
Member

@pshapiro4broad pshapiro4broad Apr 10, 2025

Choose a reason for hiding this comment

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

Up to you, but now that this is a function you can use return here and in the catch and remove isTdrBillingProfile from the function.

// Make sure this user is authorized to use the billing profile in SAM
addStep(
new AuthorizeBillingProfileUseStep(profileService, snapshotReq.getProfileId(), userReq));
if (isTdrBillingProfile) {
Copy link
Member

Choose a reason for hiding this comment

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

This now duplicates the code in DatasetCreateFlight. If we wanted to avoid this duplication, one approach would be to put both cases inside AuthorizeBillingProfileUseStep and have it also accept rawlsService and isTdrBillingProfile.

Another benefit (or shortcoming, depending on how you look at it) of this refactoring is that changing AuthorizeBillingProfileUseStep means that we'd have to look at all cases where this step is used and fix them as part of this work.

if (tdrBillingProfileFallback) {
assertThat(
FlightTestUtils.getStepNames(flight),
containsInRelativeOrder("AuthorizeBillingProfileUseStep"));
Copy link
Member

Choose a reason for hiding this comment

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

To test a single element in a collection, use hasItem()

Suggested change
containsInRelativeOrder("AuthorizeBillingProfileUseStep"));
hasItem("AuthorizeBillingProfileUseStep"));

@rjohanek rjohanek marked this pull request as draft April 14, 2025 16:25
@snf2ye snf2ye removed their request for review April 17, 2025 16:08
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.

3 participants