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

✨ Improve CEL expression evaluation #253

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

janiskemper
Copy link
Member

What this PR does / why we need it:
Improve CEL expression evaluation by adding further conditions and events. Make the error handling more elaborate to differentiate errors from expected results

Which issue(s) this PR fixes:
Fixes #210

TODOs:

  • squash commits
  • include documentation
  • add unit tests

Improve CEL expression evaluation by adding further conditions and
events. Make the error handling more elaborate to differentiate errors
from expected results

Signed-off-by: janiskemper <[email protected]>
csov1alpha1.CompileCELExpressionFailedReason,
"failed to compile CEL expression: %s, %s", waitCondition.Conditions, iss.Err(),
)

Copy link
Contributor

Choose a reason for hiding this comment

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

@janiskemper I would add a comment here, why you don't return an error.

Comment on lines +1199 to +1202
"object(%s/%s) from dynamic client for CEL expression is not found: %s", object.Namespace, object.Name, err.Error(),
)

return false, false, fmt.Errorf("failed to get object(%s/%s) from dynamic client for CEL expression: %w", object.Namespace, object.Name, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

@janiskemper is there a reason why both strings are different?

Suggestion:

err2 := fmt.fmt.Errorf("failed to get object(%s/%s) from dynamic client for CEL expression: %w", object.Namespace, object.Name, err)

conditions.MarkFalse(..., err2.Error())

return false, false, err2

Just a comment, not merge blocking.

"failed to evaluate the Ast and environment against the input vars for CEL expression: %s", err.Error(),
)

return false, false, fmt.Errorf("failed to evaluate the Ast and environment against the input vars for CEL expression: %w", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

@janiskemper the same err2-pattern could be used here.

Copy link
Contributor

@guettli guettli left a comment

Choose a reason for hiding this comment

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

do you see a way to test these changes?

@janiskemper
Copy link
Member Author

yes, by manipulating the clusteraddon.yaml

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.

Multi-stage cluster addons: Better evaluation of CEL expressions with conditions
2 participants