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

Fix #560 - Check if the .spec.flow has changed before building #564

Merged
merged 2 commits into from
Nov 14, 2024

Conversation

ricardozanini
Copy link
Member

@ricardozanini ricardozanini commented Oct 31, 2024

Description of the change:
Fix #560

Motivation for the change:

Checklist

  • Add or Modify a unit test for your change
  • Have you verified that tall the tests are passing?
How to backport a pull request to a different branch?

In order to automatically create a backporting pull request please add one or more labels having the following format backport-<branch-name>, where <branch-name> is the name of the branch where the pull request must be backported to (e.g., backport-7.67.x to backport the original PR to the 7.67.x branch).

NOTE: backporting is an action aiming to move a change (usually a commit) from a branch (usually the main one) to another one, which is generally referring to a still maintained release branch. Keeping it simple: it is about to move a specific change or a set of them from one branch to another.

Once the original pull request is successfully merged, the automated action will create one backporting pull request per each label (with the previous format) that has been added.

If something goes wrong, the author will be notified and at this point a manual backporting is needed.

NOTE: this automated backporting is triggered whenever a pull request on main branch is labeled or closed, but both conditions must be satisfied to get the new PR created.

@wmedvede wmedvede self-requested a review November 6, 2024 19:46
Copy link
Contributor

@wmedvede wmedvede left a comment

Choose a reason for hiding this comment

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

I have created a WF, I can see the build as usual.
I have changed the WF definition, and executed kubectl apply -f xxxx again.
I can't see a new build.

@ricardozanini looks like not working.

@ricardozanini
Copy link
Member Author

@wmedvede That's because we received the .spec.flow already updated in the k8s database. It would only be possible to determine if a workflow would change. I am not sure why the first version worked on my minikube.

Now, I've added a CRC field in the status, so we know if the flow has changed since we control the status update, not the user.

Copy link
Contributor

@wmedvede wmedvede left a comment

Choose a reason for hiding this comment

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

I have executed the following sequence:

  1. I deployed a workflow, the build_1 is produced, the workflow pod is started, etc.
  2. I did a breaking change in the workflow, and kubectl apply -f bla bla (I can see the new CRC generated)
  3. A new build_2 is stated as expected
  4. the new build_2 fails as expeced (see 2)
  5. I fixed the workflow, and did kubectl apply -f bla bla
  6. I can see the new CRC was generated, however no new build was started
  7. I do more changes in the workflow, kubectl apply bla bla bla again
  8. I can see the new CRC is generated

However, since the build_2, no new build is produced.
Not good.

@ricardozanini
Copy link
Member Author

ricardozanini commented Nov 7, 2024

@wmedvede, can you share the SonataFlow YAML for each change you made?

I'm just wondering if this behavior happened before this PR, so the bug might be somewhere else in the states_preview algorithm.

@wmedvede
Copy link
Contributor

wmedvede commented Nov 7, 2024

@wmedvede, can you share the SonataFlow YAML for each change you made?

I'm just wondering if this behavior happened before this PR, so the bug might be somewhere else in the states_preview algorithm.

I believe the issue us reproducible for whatever workflow, but you can use this use case:

https://github.com/flows-examples/techpreview2/blob/7103145b9c7917c31991e03607c52a0615348ec6/platforms/openshift-dataindex_and_jobservice_as_platform_service_and_global_persistence_postgresql/Readme.txt

Install the platform as pointed out, and then deploy the callback state timeouts.

https://github.com/flows-examples/techpreview2/blob/7103145b9c7917c31991e03607c52a0615348ec6/platforms/openshift-dataindex_and_jobservice_as_platform_service_and_global_persistence_postgresql/04-sonataflow_callbackstatetimeouts.sw.yaml

  1. The first deploy will work
  2. To force the second build, basically change:
  flow:
    start: PrintStartMessage

to the value

  flow:
    start: PrintStartMessage2

The second build will start, but will fail. Since the sate definition wasn't changed.

  1. For the third build, keep:
  flow:
    start: PrintStartMessage2

and go to the workflows states, and change the name of the state also there:

    states:
      - name: PrintStartMessage2
        type: operation
        actions:

This time, a potential new build should be good.
However, it's never produced.

p.s. the workflow DB is initialized automatically, no need to do a manual initialization

@ricardozanini
Copy link
Member Author

@wmedvede rebased!

@wmedvede wmedvede merged commit c429953 into apache:main Nov 14, 2024
4 checks passed
wmedvede pushed a commit to wmedvede/kogito-serverless-operator that referenced this pull request Nov 14, 2024
…pache#564)

* Fix apache#560 - Check if the .spec.flow has changed before building

Signed-off-by: Ricardo Zanini <[email protected]>

* Use CRC32 instead of comparing flows directly

Signed-off-by: Ricardo Zanini <[email protected]>

---------

Signed-off-by: Ricardo Zanini <[email protected]>
(cherry picked from commit c429953)
rgdoliveira pushed a commit to kiegroup/kogito-serverless-operator that referenced this pull request Nov 14, 2024
…pache#564) (#96)

* Fix apache#560 - Check if the .spec.flow has changed before building

Signed-off-by: Ricardo Zanini <[email protected]>

* Use CRC32 instead of comparing flows directly

Signed-off-by: Ricardo Zanini <[email protected]>

---------

Signed-off-by: Ricardo Zanini <[email protected]>
(cherry picked from commit c429953)

Co-authored-by: Ricardo Zanini <[email protected]>
@ricardozanini ricardozanini deleted the issue-560 branch November 14, 2024 15:37
rgdoliveira pushed a commit to rgdoliveira/kogito-serverless-operator that referenced this pull request Nov 18, 2024
…pache#564)

* Fix apache#560 - Check if the .spec.flow has changed before building

Signed-off-by: Ricardo Zanini <[email protected]>

* Use CRC32 instead of comparing flows directly

Signed-off-by: Ricardo Zanini <[email protected]>

---------

Signed-off-by: Ricardo Zanini <[email protected]>
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.

Add the ability to scale to 0 a workflow executing with the preview by not requiring a new build
2 participants