Skip to content
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

Replace "run now" CustomAction with standard action PerformSingleExecution #7165

Open
wants to merge 7 commits into
base: staging
Choose a base branch
from

Conversation

mgoworko
Copy link
Contributor

@mgoworko mgoworko commented Nov 18, 2024

Describe your changes

The main purpose of this PR, is to refactor "run now" action for periodic DeploymentManagers:

  • before: it was a CustomAction
  • now: it is a standard actions, similar to CANCEL, DEPLOY, etc.

Planned changes related to the PeriodicDeploymentManager:

  1. This change modifies basic handling and UX of "run now" action
  2. Second phase (already in progress while writing this comment) will involve:
  • moving the periodic deployment manager closer to Nu core
    • database, that was separate, moved the main Nu db
    • deployment manager decoupled from Flink
    • interface moved to the deployment manager API module, but mostly as-is, without huge changes
  • improving and optimizing queries about periodic scenarios and their status
  1. Third phase may involve further integrating the periodics into the general deployment manager interface - phase 2 is preparation for that.

Most important changes:

  1. The "run now" actions is now implemented as standard action:
  • it has its own dedicated button on actions panel, no longer uses generic CustomAction mechanism and button
  • this new button is now fully controlled by Nu backend response, both
    • its visibility (only for periodic processes)
    • active/inactive (greyed out), it is active only when newest version of scenario is scheduled
  1. The ProcessStateDefinitionManager improvements:
  • it is now aware, which version of the scenario is newest, and which is deployed
  • it allows to manage allowed actions, depending on deployed and latest version (it was needed for "run now" action)
  • ProcessStateDefinitionManager now allows to define, which action buttons are visible on FE (def applicableActions) (right now only applied to "run now" for periodic processes)
  • ProcessStateDefinitionManager now allows to specify custom tooltips for action buttons (again, it was needed by "run now" action")
  1. The PeriodicProcessStateDefinitionManager changes:
  • "run now" is now a standard action, handled in the graph of state transitions
  • "run now" is available only when newest version of scenario is scheduled
  • in other states, custom tooltips are returned, describing why it is now possible to invoke "run now"

Checklist before merge

  • Related issue ID is placed at the beginning of PR title in [brackets] (can be GH issue or Nu Jira issue)
  • Code is cleaned from temporary changes and commented out lines
  • Parts of the code that are not easy to understand are documented in the code
  • Changes are covered by automated tests
  • Showcase in dev-application.conf added to demonstrate the feature
  • Documentation added or updated
  • Added entry in Changelog.md describing the change from the perspective of a public distribution user
  • Added MigrationGuide.md entry in the appropriate subcategory if introducing a breaking change
  • Verify that PR will be squashed during merge

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced the PerformSingleExecution action, enhancing scenario execution capabilities.
    • Added support for a new command type, DMPerformSingleExecutionCommand, in the DeploymentManager.
    • New methods for handling applicable actions and tooltips in the ProcessStateDefinitionManager.
    • Enhanced the ProcessState class with new fields for applicable actions and action tooltips.
    • Implemented the PerformSingleExecutionButton in the toolbar for immediate execution.
    • Added a new PerformSingleExecutionRequest and PerformSingleExecutionResponse for API interactions.
    • Expanded event tracking to include the PerformSingleExecution action.
    • Improved the ActivitiesPanelRow component to recognize additional running states.
  • Bug Fixes

    • Improved error handling and logging in various health check endpoints.
  • Documentation

    • Updated changelog and migration guide to reflect new features and changes in command handling and process state management.
  • Chores

    • Cleaned up unused imports and improved code formatting across multiple files.

This comment was marked as outdated.

@github-actions github-actions bot added client client main fe ui labels Nov 18, 2024
@mgoworko

This comment was marked as outdated.

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@github-actions github-actions bot added the docs label Nov 19, 2024
@mgoworko mgoworko changed the title Improve "run now" state handling and treat it as a standard action, not custom action Replace "run now" CustomAction with standard action PerformSingleExecution, improve state handling and notifications Nov 19, 2024
@mgoworko mgoworko changed the title Replace "run now" CustomAction with standard action PerformSingleExecution, improve state handling and notifications Replace "run now" CustomAction with standard action PerformSingleExecution Nov 19, 2024
@mgoworko mgoworko marked this pull request as ready for review November 19, 2024 10:00
coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

@mgoworko mgoworko force-pushed the improve-run-now-state-handling branch from 879fd84 to d3c0e7d Compare November 20, 2024 15:23
coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

Copy link
Member

@arkadius arkadius left a comment

Choose a reason for hiding this comment

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

Minor comments added

const action = (p, c) => HttpService.performSingleExecution(p, c).finally(() => dispatch(loadProcessState(processName)));
const message = t("panels.actions.perform-single-execution.dialog", "Perform single execution", { name: processName });

const tooltip = ProcessStateUtils.getActionCustomTooltip(scenarioState, PredefinedActionName.PerformSingleExecution) ?? "run now";
Copy link
Member

Choose a reason for hiding this comment

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

Please use i18n mechanism

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 think I've done it now. Backend returns type of tooltip ("NOT_ALLOWED_IN_CURRENT_STATE" /"NOT_ALLOWED_FOR_DEPLOYED_VERSION") and frontend handles actual message rendering with i18s.

Copy link
Member

Choose a reason for hiding this comment

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

It's not exactly what I head in mind. I mean i18n for "run now" text :). I would not apply i18n for backend messages this way. If we decide to do this, it should be done full on BE side and done more holistic. Let's revert this

@@ -86,3 +80,9 @@ case class DMCancelScenarioCommand(scenarioName: ProcessName, user: User) extend

case class DMStopScenarioCommand(scenarioName: ProcessName, savepointDir: Option[String], user: User)
extends DMScenarioCommand[SavepointResult]

case class DMPerformSingleExecutionCommand(
Copy link
Member

Choose a reason for hiding this comment

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

  1. What about custom actions? Can you write in the description the plan of changes that will be made in further PRs?
  2. Let's write a TODO describing further plan that won't be a part of currently planned changes. Do you agree that eventually we should extract some kind of a scheduler interface and in the deployment manager keep only logic related with the deployment? Or maybe you see it differently?

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 added in this PR description the general plan for periodics, especially the change that is already in progress.

I'm not sure ATM about the future of CustomAction's. We aren't using them internally anymore - "run now" was our only usage. They are left in the codebased and APIs right now, so Nu users can still use them.

I guess we need to decide, whether to leave CustomAction's as they are, or remove them.

Copy link
Member

Choose a reason for hiding this comment

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

We should remove custom actions. It was done only for this one thing. It complicates deployments mechanism and slow down development. Let's add a removal step to the plan

disabled={name === "run now" ? disabledValue : false}
type={type}
/>
<CustomActionButton action={action} processName={processName} disabled={false} processStatus={status} type={type} />
Copy link
Contributor

Choose a reason for hiding this comment

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

As I see, there is no option to disable a custom action based on FE types. Do we need this disabled flag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is part of common ToolbarButtonProps, used for all buttons. AFAIK this value must be provided. I guess at the moment it is the only button, that is never disabled on FE side, so constant false provided here

After Arek's comments I added internationalization of tooltip messages, I think it needs FE review too.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
client client main fe docs ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants