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

[vrotsc,vrotsc-annotations] (#324) Add Workflow canvas Error Handling #371

Merged
merged 13 commits into from
Aug 2, 2024

Conversation

Michaelpalacce
Copy link
Collaborator

@Michaelpalacce Michaelpalacce commented Aug 1, 2024

Description

TBD

Checklist

  • I have added relevant error handling and logging messages to help troubleshooting
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation, relevant usage information (if applicable)
  • I have updated the PR title with affected component, related issue number and a short summary of the changes introduced
  • I have added labels for implementation kind (kind/) and version type (version/)
  • I have tested against live environment, if applicable
  • I have synced any structure and/or content vRA-NG improvements with vra-ng and ts-vra-ng archetypes (if applicable)
  • I have my changes rebased and squashed to the minimal number of relevant commits. Notice: don't squash all commits
  • I have added a descriptive commit message with a short title, including a Fixed #XXX - or Closed #XXX - prefix to auto-close the issue

Testing

e2e test added

Related issue:
#324

They point to the item to call in case of exception
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
1 << 2 is the same as 2 << 1... first is better as we want powers of 2
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Otherwise we won't be able to use the actual `Error` object as they will
overlap and overwrite :)
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
@Michaelpalacce Michaelpalacce added area/vro-types Relates to changes to the type definitions lang/typescript Related to typescript code area/vrotsc Relates to `vrotsc` module version/minor Introduces a non-breaking feature or change kind/feature New Feature to the project labels Aug 1, 2024
@Michaelpalacce Michaelpalacce self-assigned this Aug 1, 2024
@Michaelpalacce Michaelpalacce requested a review from a team as a code owner August 1, 2024 07:28
akantchev and others added 4 commits August 1, 2024 10:43
Signed-off-by: Alexander Kantchev <akantchev@vmware.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
…re-aria into feature/324-canvas-item-error-handling

Signed-off-by: Stefan Genov <stefan.genov@broadcom.com>
@VenelinBakalov VenelinBakalov changed the title [vrotsc,vrotsc-annotations] (#324) Canvas item error handling [vrotsc,vrotsc-annotations] (#324) Add Workflow canvas Error Handling item Aug 1, 2024
@Michaelpalacce Michaelpalacce changed the title [vrotsc,vrotsc-annotations] (#324) Add Workflow canvas Error Handling item [vrotsc,vrotsc-annotations] (#324) Add Workflow canvas Error Handlin Aug 1, 2024
@akantchev akantchev changed the title [vrotsc,vrotsc-annotations] (#324) Add Workflow canvas Error Handlin [vrotsc,vrotsc-annotations] (#324) Add Workflow canvas Error Handling Aug 1, 2024
@akantchev
Copy link
Contributor

akantchev commented Aug 1, 2024

Hi @Michaelpalacce,

I did some tests with a real environment, however when I try to build a package an push it to an environment the following error occurs:

[ERROR] /home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/node_modules/sax/lib/sax.js:651
[ERROR]     er = new Error(er)
[ERROR]          ^
[ERROR]
[ERROR] Error: No whitespace between attributes
[ERROR] Line: 14
[ERROR] Column: 555
[ERROR] Char: b
[ERROR]     at error (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/node_modules/sax/lib/sax.js:651:10)
[ERROR]     at strictFail (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/node_modules/sax/lib/sax.js:677:7)
[ERROR]     at SAXParser.write (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/node_modules/sax/lib/sax.js:1395:13)
[ERROR]     at new XmlDocument (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/node_modules/xmldoc/lib/xmldoc.js:301:19)
[ERROR]     at exports.xml (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/util.js:14:25)
[ERROR]     at Object.getWorkflowItems (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/util.js:279:62)
[ERROR]     at parseInputForms (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/tree.js:88:28)
[ERROR]     at parseTreeElement (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/tree.js:64:24)
[ERROR]     at /home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/tree.js:112:26
[ERROR]     at Array.map (<anonymous>)
[ERROR]     at Object.<anonymous> (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/tree.js:112:14)
[ERROR]     at Generator.next (<anonymous>)
[ERROR]     at /home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/tree.js:8:71
[ERROR]     at new Promise (<anonymous>)
[ERROR]     at __awaiter (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/tree.js:4:12)
[ERROR]     at Object.parseTree (/home/alex/gitlab/Projects/vro.ts.workflows/node_modules/@vmware-pscoe/vropkg/dist/parse/tree.js:109:12)
[ERROR]
[ERROR] Node.js v22.4.1
[INFO] Running vropkg... finished
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

It appears that somewhere when you generate the XML there is a missing white-space, hence the XML is incorrect, could you please check.

I used the a typescript project with single workflow using the following code:

/*-
 * #%L
 * vro.ts.workflows
 * %%
 * Copyright (C) 2024 TODO: Enter Organization name
 * %%
 * TODO: Define header text
 * #L%
 */
import { Workflow, Out, In, Err, Item, RootItem, DecisionItem, WaitingTimerItem, WorkflowEndItem, DefaultErrorHandler } from "vrotsc-annotations";

@Workflow({
    name: "Complex Workflow",
    path: "VMware/PSCoE",
    attributes: {
        waitingTimer: {
            type: "Date"
        },
        counter: {
            type: "number"
        }
    }
})
export class Complex {

    @DecisionItem({
        target: "waitForEvent",
        else: "end"
    })
    public decisionElement(waitingTimer: Date) {
        return waitingTimer !== null;
    }

    @Item({
        target: "decisionElement",
        exception: ""
    })
    public execute(
        @Out @In waitingTimer: Date,
        @Out @In counter: number
    ): void {
        if (!counter) {
            counter = 0;
        }
        counter++;
        if (counter < 2) {
            const tt = Date.now() + 5 * 1000;
            waitingTimer = new Date(tt);
        } else {
            waitingTimer = null;
        }

        System.log("Counter: " + counter);
        System.log("Waiting Timer: " + waitingTimer);
    }

    @Item({
        target: "execute",
        exception: ""
    })
    @RootItem()
    public start() {
        System.log("Starting workflow");
    }

    @WaitingTimerItem({
        target: "execute"
    })
    public waitForEvent(@In waitingTimer: Date) {
        // NOOP
    }

    @DefaultErrorHandler({
        target: "workflowEnd"
    })
    public defaultErrorHandler(@Out errorMessage: string) {
        // NOOP
    }

    @WorkflowEndItem({
        endMode: 1,
        businessStatus: "Bad"
    })
    public workflowEnd(@Err errorMessage: string) {
        // NOOP
    }
}

Co-authored-by: Venelin Bakalov <bakalovv@vmware.com>
Signed-off-by: Stefan Genov <sgenov@vmware.com>
@vmwclabot
Copy link
Member

@Michaelpalacce, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.

1 similar comment
@vmwclabot
Copy link
Member

@Michaelpalacce, you must sign every commit in this pull request acknowledging our Developer Certificate of Origin before your changes are merged. This can be done by adding Signed-off-by: John Doe <john.doe@email.org> to the last line of each Git commit message. The e-mail address used to sign must match the e-mail address of the Git author. Click here to view the Developer Certificate of Origin agreement.

@Michaelpalacce
Copy link
Collaborator Author

@akantchev I think you need to define: errorMessage as an attribute too:

attributes: {
waitingTimer: {
type: "Date"
},
counter: {
type: "number"
}
}

@VenelinBakalov
Copy link
Collaborator

@akantchev I think you need to define: errorMessage as an attribute too:

attributes: { waitingTimer: { type: "Date" }, counter: { type: "number" } }

@akantchev please check whenever you can and if everything is ok, let's resolve the previous comment

Copy link
Collaborator

@VenelinBakalov VenelinBakalov left a comment

Choose a reason for hiding this comment

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

Just merge conflict resolution left

@VenelinBakalov VenelinBakalov merged commit 8e4dc69 into main Aug 2, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/vro-types Relates to changes to the type definitions area/vrotsc Relates to `vrotsc` module dco-required kind/feature New Feature to the project lang/typescript Related to typescript code version/minor Introduces a non-breaking feature or change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants