Introduction
IBM Fusion Backup and Restore recipes have a decision-making field called "condition" within the check hooks. The result obtained from evaluating this field determines the outcome of the hook. Therefore, it is important to write the "condition" string carefully, ensuring that it is valid and recognized by the recipe on the cluster.
Over time, these check hooks have been enhanced to support logical expression evaluation, enabling more complex conditions to be defined in a structured and intuitive manner.
In this article, will explore how to write the "condition" field effectively, with clarity and fair understanding.
What is the format for Check Hook “condition” string?
At minimum, it includes two JSONPath expressions enclosed in curly braces
and separated by an operator
.
Condition string = {expression1} <operator> {expression2}

Expression1 and Expression2
Should be valid JSONPath expressions, representing either a namespace-scoped or cluster-scope Kubernetes resource.
Operator
It can be one of the below comparison operators:
Note: In Fusion 2.9, check with logical expressions was introduced. Allowing users to have multiple logical expressions in check hooks using AND ( && ) and OR ( || ) operators. It is also possible to create complex groupings using parentheses. Few valid examples are:
{$.spec.replicas} == {$.status.readyReplicas}
{$.spec.replicas} == {$.status.readyReplicas} || {$.metadata.generation} == {$.status.observedGeneration} && {$.spec.progressDeadlineSeconds} == {"500"}
({$.spec.replicas} == {$.status.readyReplicas}) || (({$.metadata.generation} == {$.status.observedGeneration}) && {$.spec.progressDeadlineSeconds} == {"500"}

Order of evaluation
Firstly, JSONPath expressions are evaluated, followed by inner groups present in the parentheses and then any outer groups. If logical groups are at same level, then they will be evaluated from left to right.
Write a condition string
Let’s quickly write condition string for Db2uCluster resource status. Snippet below shows its status details.
"status": {
"conditions": [
{
"lastTransitionTime": "2025-03-26T10:31:21Z",
"status": "OK",
"type": "FormationStatus"
}
],
"maintenanceState": "InMaintenance",
"state": "Ready",
"version": "s11.5.9.0"
}
Say – We want to validate for its “Ready” state?
For this, check hook condition can be written as –
chks:
- condition: '{$.status.state} == {"Ready"}'
What if also want to validate the Formation status “OK”?
In this situation, logical AND can be utilized. Thus, final condition string will be –
chks:
- condition: '({$.status.state} == {"Ready"}) && ({$.status.conditions[?(@.type=="FormationStatus")].status} == {"OK"})'
We can add another parenthesis to add more clarity
chks:
- condition: '(({$.status.state} == {"Ready"}) && ({$.status.conditions[?(@.type=="FormationStatus")].status} == {"OK"}))'
Final recipe check hook:
hooks:
- name: db2uclusters-check
labelSelector: for-backup=true
namespace: ${GROUP.db2u-volumes.namespace}
selectResource: db2u.databases.ibm.com/v1/db2uclusters
timeout: 300
type: check
chks:
- condition: '(({$.status.state} == {"Ready"}) && ({$.status.conditions[?(@.type=="FormationStatus")].status} == {"OK"}))'
name: stateReady
onError: fail
timeout: 300
onError: fail
Note:
- Result of both above conditions will be same. Parenthesis, just add more clarity to it.
- From this exercise, we see how important logical comparison and grouping are.
- Similarly, we can add any additional condition check to existing string.
Benefits:
- Conditions help in validating resource state.
- Logical grouping enables the use of nested conditions, which helps in determining the current state of a resource precisely.
- Placing conditions appropriately streamlines backup and recovery workflows.
Conclusion
IBM Fusion recipe condition string uses JSONPath expressions to filter values from Kubernetes resources. These expressions can optionally be combined with logical operators and grouped using parentheses, enabling the creation of complex, multi-condition expressions for a specific resource. This ultimately enhances the check hook capability, supporting more reliable backup and recovery scenarios.
Hope you found this article informative and helpful in creating condition strings for your Fusion Recipes. Stay tuned for upcoming enhancements and new features in the Fusion Recipe. Happy reading!
References
https://www.ibm.com/docs/en/fusion-software/2.10.0?topic=workflows-creating-recipe
https://github.com/IBM/storage-fusion/tree/master/backup-restore/recipes