Skip to content

Conversation

bhperry
Copy link
Contributor

@bhperry bhperry commented Mar 20, 2025

Summary

Adding the necessary type changes to ManifestWork to support the workload conditions and completion feature.

Related issue(s)

open-cluster-management-io/enhancements#138

UpdateStrategy *UpdateStrategy `json:"updateStrategy,omitempty"`

// ConditionRules defines how to set manifestwork conditions for a specific manifest.
// +optional
Copy link
Member

Choose a reason for hiding this comment

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

you might want to add a marker listMapKey: condition and set strategy to merge.


// CelExpressions defines the CEL expressions to be evaluated for the condition.
// Final result is the logical AND of all expressions.
// +optional
Copy link
Member

Choose a reason for hiding this comment

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

I am wondering whether with type WellKnownCompletions, we do not need to set any other field in this struct.
If so, we might have a nested struct and put all field not needed for WellKnownCompletions to it, e.g.

type ConditionRule struct {
    Condition string `json:"condition"`
    Type ConditionRuleType `json:"type"`
   // this could be a pointer, so when type is WellKnownCompletions, this is nil
    CEL *CELRule `json:"cel"`
}

type CELRule struct {
    Expressions []string `json:"expressions"`
    Message string `json:"message"`
    ....
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My original idea was that the standard message and condition for WellKnownCompletions could be overridden by the user, such that they could use the well known rules but set them to a custom condition/message.

But I do see the benefit to simplifying and using nesting for the CELRule. I am open to switching to this approach if that is what you prefer.

Copy link
Member

@qiujian16 qiujian16 May 7, 2025

Choose a reason for hiding this comment

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

I prefer a simplified way, and if there is use case later that we need message override for WellKnownCompletions, we could add another field solely for WellKnownCompletions type to set them.

Copy link
Member

Choose a reason for hiding this comment

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

And it might be more consistent if the type is WellKnownCondition? so for completed condition, user should set

condition: Completed
type: WellKownCondition

It would be easier for us to extend later for other condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And it might be more consistent if the type is WellKnownCondition? so for completed condition, user should set

condition: Completed
type: WellKownCondition

It would be easier for us to extend later for other condition.

This is interesting. My thinking with WellKnownCompletions was that since Completed is a specialized case, users would want to be able to set that separately from other future well known conditions.

Are you suggesting that a rule like this would select just a single rule that matches the given condition

- condition: Completed
  type: WellKnownCondition

and then a rule like this would select all well knowns?

- type: WellKnownCondition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Options:

  1. Reject in webhook validation
  2. The last occurrence of a condition overrides all previous
  3. The full rule for the condition becomes the logical AND of all expressions across the rules

Copy link
Member

Choose a reason for hiding this comment

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

might work if add

// +listType=map
// +listMapKey=type
// +listMapKey=condition

such that there is no duplicate setting. but need take a try,

Copy link
Member

Choose a reason for hiding this comment

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

@bhperry would you like to add // +listMapKey=type
and we are good to merge this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think type should be a map key. Condition is required now, so using just that as map key ensures each condition only has one rule. If we add type then OCM has to handle the case where a condition has a WellKnown and custom CEL rule.

Copy link
Member

Choose a reason for hiding this comment

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

got it, it is fine if condition is required.

@bhperry bhperry force-pushed the workload-conditions branch from 970c248 to 456e139 Compare May 15, 2025 16:49
Signed-off-by: Ben Perry <[email protected]>
@bhperry bhperry force-pushed the workload-conditions branch from d0c6c2d to fc00e48 Compare May 21, 2025 15:11
@qiujian16
Copy link
Member

/approve
only is to check if #362 (comment) works

Copy link
Contributor

openshift-ci bot commented May 22, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bhperry, qiujian16

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@qiujian16
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label May 30, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 5880b0c into open-cluster-management-io:main May 30, 2025
10 checks passed
@bhperry bhperry deleted the workload-conditions branch June 2, 2025 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants