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

Add Q2 switch to exit on failed deploy #553

Open
ar opened this issue Jul 19, 2023 · 7 comments
Open

Add Q2 switch to exit on failed deploy #553

ar opened this issue Jul 19, 2023 · 7 comments

Comments

@ar
Copy link
Member

ar commented Jul 19, 2023

A valid suggestion came from a jPOS user to enable Q2 to terminate upon encountering an error during deployment.

There are scenarios where it could be beneficial for Q2 to halt if a QBean fails to initialize. Nevertheless, we may want to distinguish between terminating during the startup process and ceasing operation if, for some reason, the system is running and a QBean becomes misconfigured.

I suggest to add a new startup option:

--exit-on-failed-deploy=startup|always
@alcarraz
Copy link
Contributor

alcarraz commented Jul 19, 2023

Maybe not all the qbeans are critical, another option (not saying better) could be that the qbeans could be flagged as critical, and maybe that could be a qbean attribute, e.g.:

<qbean name="xxx" exit-on-failed-deploy="[startup|always]">

@alcarraz
Copy link
Contributor

By the command line, we could set the default value. And when not set, it could be no.

@aVolpe
Copy link
Contributor

aVolpe commented Jul 19, 2023

I was working in a feature similar to this (fintechworks@8aa75f7), I can continue that feature if we can define
some behaviors:

  • The server should stop if we deploy an invalid descriptor when it is running?
  • The server should stop if the qbean throws on init or start?
  • How to handle async qbeans?

There is a related concept in kubernetes are readiness and liveness, see https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/.

For example, some qbeans should be required for the server to be 'alive' and others to be 'ready', for
example, a server is ready if the txnmgr and the qserver beans are running, but it's alive only if the
db connection is active.

We can use those concepts to model when to stop the Q2 after startup.

@alcarraz
Copy link
Contributor

Maybe not all the qbeans are critical, another option (not saying better) could be that the qbeans could be flagged as critical, and maybe that could be a qbean attribute, e.g.:

<qbean name="xxx" exit-on-failed-deploy="[startup|always]">

Oups, my bad, just noticed that if the deploy fails because of bad XML this wouldn't work, we could handle cases where the failure is because of another thing, it probably isn't worth it.

@ar
Copy link
Member Author

ar commented Jul 19, 2023

I understand your --ff option is very similar to what we are suggesting here, and I like it. There's still a difference between failing at startup versus always. I also liked @alcarraz suggestion and was disappointed, the same as you Andres when we realized that we could fail at the XML level.

I believe that the main concern that the user that raised this issue had is a situation where you start the system and the TM fails, so you have servers up, and no TM running.

I think the liveness/readyness status has to be addressed at another level, and may need cooperation from the QBeans, with clear indications to the system about their status. Probably something to start with a JEP discussion before implementing it.

@aVolpe
Copy link
Contributor

aVolpe commented Jul 19, 2023

The transaction manager loads all participants in the init method and extends QBeanSupport so no exception is thrown. But the init method doesn't mark the deployment as failed, it only logs a warning, so we need to mark this bean as failed or use the status -1 that the QBeanSupport uses to mark the bean as 'invalid'.

We can add these checks in the Q2 to determine if we need to fail:

  • In the catch as is in the ff pr to catch invalid xmls, any exception is marked as a fail.
  • If after the deploy, but before the start, the qbean is in an invalid state, fail.
  • After the start, check if the bean is a qbean, and the status is not STARTED, fail.

@ar
Copy link
Member Author

ar commented Jul 19, 2023

I think what we are addressing here are situations where the TM would drop the QBean descriptor altogether renaming it as .BAD or .DUP or situations where the QBean raises a ConfigurationException.

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

No branches or pull requests

3 participants