Skip to content

[Feature]: Use a Modify workflow as a Reconcile workflow #1026

@Mark90

Description

@Mark90

What should we build?

As an Orchestrator User I want to be able to correct information in external systems with 1 click by running a Reconcile workflow.

A "Reconcile workflow" is nothing more than calling the Modify workflow that will reapply current configuration from the database. (e.g. running the Modify workflow with only empty input forms)

Implementation details

  • The reconcile workflow will only run steps that update external systems. It does not include the:
    • Input forms
    • Subscription updates in Core DB
  • The definition of those steps should be reused by both the modify and reconcile workflow
  • The reconcile workflow still requires the subscription to be in sync before it can be started
  • Only allow 1 Reconcile workflow per product
    • See how this is implemented for Create workflows with ProductTable.create_subscription_workflow_key

Intended usage in Orchestrator implementations

Below is an example for the modify workflow of one specific production.
These steps should be repeated for each product that need (and support) a reconcile workflow.

Example based on example-orchestrator modify_l2vpn:

  • Add migration to add a row in Workflows table with target=RECONCILE and name="reconcile_l2vpn"
  • Add LazyWorkflowInstance mapping the module modify_l2vpn to reconcile_l2vpn:
LazyWorkflowInstance("workflows.l2vpn.modify_l2vpn", "reconcile_l2vpn")

The modify_l2vpn.py should be modified as well.
It currently looks like this:

@modify_workflow("Modify l2vpn", initial_input_form=initial_input_form_generator)
def modify_l2vpn() -> StepList:
    return (
        begin
        >> set_status(SubscriptionLifecycle.PROVISIONING)
        >> update_subscription
        >> update_subscription_description
        >> set_status(SubscriptionLifecycle.ACTIVE)
        >> update_l2vpn_in_nrm
    )

The steps responsible for updating external systems should be pulled out to a reusable variable:

update_l2vpn_in_external_systems = (
        begin 
        >> update_l2vpn_in_nrm
)

@modify_workflow("Modify l2vpn", initial_input_form=initial_input_form_generator)
def modify_l2vpn() -> StepList:
    return (
        begin
        >> set_status(SubscriptionLifecycle.PROVISIONING)
        >> update_subscription
        >> update_subscription_description
        >> set_status(SubscriptionLifecycle.ACTIVE)
        >> update_l2vpn_in_external_systems
    )

The reconcile workflow then refers to the steps in that variable without going through the input forms.
It also does not update the subscription in the Core DB because there is nothing to update.

@reconcile_workflow("Reconcile l2vpn")
def reconcile_l2vpn() -> StepList:
    return (
        begin
        >> update_l2vpn_in_external_systems
    )

If some of the steps in update_l2vpn_in_external_systems require default values to be in the state, an extra step can be added to provide this.

Tasks

In orchestrator-core:

  • Add Target.RECONCILE
    • Ensure that reconcile workflows are returned by the endpoint /api/subscriptions/workflows/<id>
  • Implement @reconcile_workflow() decorator
    • Create wrap_reconcile_initial_input (based on wrap_modify_initial_input_form) to perform the validations in ModifySubscriptionPage and to provide the minimal state values
    • It should not accept an initial input form
    • Use the correct Target.RECONCILE
  • Implement and test in all example-orchestrator modify workflows, such as modify_l2vpn

Related UI ticket: workfloworchestrator/orchestrator-ui-library#2081

Metadata

Metadata

Assignees

Labels

featureRequest for new feature

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions