Skip to content

[RW-9614][risk=no] Refactor Cromwell configuration panel #7480

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

Merged
merged 1 commit into from
Mar 17, 2023

Conversation

Peter-Lavigne
Copy link
Contributor

@Peter-Lavigne Peter-Lavigne commented Mar 14, 2023

Description:

Refactors the Cromwell configuration panel to use shared logic for when a GKE app can be created.

Additionally, adds some tests.

Fixes a pre-existing bug where the user cannot create a Cromwell app if their previously-deleted app is in a DELETED state.

It's difficult to test or notice this locally since the app is quickly removed from the list of apps returned by the list apps endpoint.

Question for the reviewer: When are apps in a "DELETED" state, anyway? What happens if a user has a “deleted” app, then creates another? Would the user have two apps in that scenario, and does our code account for this?


PR checklist

  • This PR meets the Acceptance Criteria in the JIRA story
  • The JIRA story has been moved to Dev Review
  • This PR includes appropriate unit tests
  • I have added explanatory comments where the logic is not obvious
  • I have run and tested this change locally, and my testing process is described here
  • If this includes a new feature flag, I have created and linked new JIRA tickets to (a) turn on the feature flag and (b) remove it later
  • If this includes an API change, I have run the E2E tests on this change against my local server with yarn test-local because this PR won't be covered by the CircleCI tests
  • If this includes a UI change, I have taken screen recordings or screenshots of the new behavior and notified the PO and UX designer in Slack
  • If this change impacts deployment safety (e.g. removing/altering APIs which are in use) I have documented these in the description
  • If this includes an API change, I have updated the appropriate Swagger definitions and updated the appropriate API consumers

@Peter-Lavigne Peter-Lavigne requested review from a team and NehaBroad and removed request for a team March 14, 2023 15:13
@Peter-Lavigne
Copy link
Contributor Author

Peter-Lavigne commented Mar 14, 2023

I don't see any other issues with the Cromwell configuration panel other than the potential issue raised above with having multiple apps if one app is in a DELETED state.

If this is a possible state, what should we do? One idea is to update our existing findApp function to findActiveApp to filter out DELETED apps.

@@ -168,7 +173,7 @@ const PanelMain = fp.flow(
id='cromwell-cloud-environment-create-button'
aria-label='cromwell cloud environment create button'
onClick={onCreate}
disabled={loading || !!app?.status || creating}
disabled={loading || !canCreateApp(app) || creating}
Copy link
Collaborator

Choose a reason for hiding this comment

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

It will be better to move this in a method and add a comment describing the conditions of canCreateApp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did some light refactoring and renaming and ended up with this:

const createEnabled = !loadingApps && !creatingCromwellApp && canCreateApp(app);

Should I still add a comment?

...listAppsAppResponseSharedDefaults,
appName: 'all-of-us-2-cromwell-1234',
appType: AppType.CROMWELL,
creator: '[email protected]',
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we use a mock name?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, renamed 👍

Copy link
Collaborator

@jmthibault79 jmthibault79 left a comment

Choose a reason for hiding this comment

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

Looks like the API code filters out DELETED apps anyway... so I'm not sure when you'd be seeing one.

  private List<UserAppEnvironment> getUserAppEnvironments(
      String googleProjectId, AppsApi appsApi, String leonardoAppRole) {
    List<LeonardoListAppResponse> listAppResponses =
        leonardoRetryHandler.run(
            (context) ->
                appsApi.listAppByProject(
                    googleProjectId,
                    /* labels= */ null,
                    /* includeDeleted= */ false,
                    /* includeLabels= */ LeonardoLabelHelper.LEONARDO_APP_LABEL_KEYS,
                    leonardoAppRole));

    return listAppResponses.stream().map(leonardoMapper::toApiApp).collect(Collectors.toList());
  }

return a1.filter((e) => !a2.includes(e));
}

export const ALL_STATUSES = Object.keys(AppStatus)
Copy link
Collaborator

Choose a reason for hiding this comment

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

we have many kinds of status so I'd prefer ALL_APP_STATUSES or allUserAppStatuses or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to ALL_GKE_APP_STATUSES 👍

@@ -36,6 +36,7 @@ import { NotebooksApiStub } from 'testing/stubs/notebooks-api-stub';
import { RuntimeApiStub } from 'testing/stubs/runtime-api-stub';
import { RuntimesApiStub } from 'testing/stubs/runtimes-api-stub';
import { workspaceDataStub } from 'testing/stubs/workspaces';
import { ALL_STATUSES, minus } from 'testing/utils';
Copy link
Collaborator

Choose a reason for hiding this comment

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

good refactoring

@NehaBroad
Copy link
Collaborator

if its being done in API should we do it again in UI?

@Peter-Lavigne
Copy link
Contributor Author

Oh, I didn't know we filtered out those GKE apps.

I tried to distinguish between ActiveAppStatus and InactiveAppStatus at the API level, but our swagger version would need to be upgraded to do this well.

This PR no longer fixes a bug, and the multi-app state I described above won't happen.

I think these are still valid refactors and test improvements, though. Maybe I should add a comment somewhere so we don't get confused by this again?

@Peter-Lavigne Peter-Lavigne force-pushed the peterlavigne/rw-9614-fix-create-cromwell branch from f2f059b to 8e6dd80 Compare March 16, 2023 19:45
@Peter-Lavigne
Copy link
Contributor Author

GitHub claimed there was a conflict so I rebased. However, there didn't appear to be a conflict so it seems like a temporary GitHub bug.

Copy link
Collaborator

@jmthibault79 jmthibault79 left a comment

Choose a reason for hiding this comment

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

These changes are fine ... how about updating any incorrect github text with strikethroughs, then updating your squashed commit message to "did some refactoring yolo" or whatever

@Peter-Lavigne Peter-Lavigne changed the title [RW-9614][risk=no] Allow creating Cromwell when the app status is DELETED [RW-9614][risk=no] Refactor Cromwell configuration panel Mar 17, 2023
@Peter-Lavigne Peter-Lavigne force-pushed the peterlavigne/rw-9614-fix-create-cromwell branch from 8e6dd80 to 0e8a393 Compare March 17, 2023 13:29
@Peter-Lavigne
Copy link
Contributor Author

Good idea, done 👍

@Peter-Lavigne Peter-Lavigne merged commit ec53648 into main Mar 17, 2023
@Peter-Lavigne Peter-Lavigne deleted the peterlavigne/rw-9614-fix-create-cromwell branch March 17, 2023 14:44
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