🐛 fix: omit PlacementDecision score field when zero-valued#435
Conversation
WalkthroughModified the JSON serialization tag for the Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Discussed with original enhancement author @bhperry and he agreed this is the right approach. /assign @qiujian16 |
|
/lgtm |
|
I misunderstood the problem. Does this actually fix argoproj/argo-cd#27264 ? It seems like argo actually needs to handle non-strings or it will still break once the PR to set thr scores merges. Score should always be set once the feature is complete. |
|
@mikeshng would it be enough to just set omitempty to make argocd not break while they fix the underlying problem? I think having it be a pointer is confusing for the api, when the intention is that it will always be set to a number. |
|
This doesn't directly fix the argo-cd issue. The argo-cd fix is still required. This current API change PR gives us enough time to address it properly. |
|
can we set omitzero instead? will it be good enough for serielization? |
7783a29 to
89a9873
Compare
89a9873 to
b64d322
Compare
Add omitzero json tag to ClusterDecision.Score so that the default zero value is not serialized to JSON. The field remains int64 (non-pointer) and is only included when explicitly set to a non-zero value. Signed-off-by: Mike Ng <ming@redhat.com>
b64d322 to
3fc03e3
Compare
|
@bhperry @qiujian16 thank you for the quick reviews. I've done the changes as you both suggested. Thanks! |
|
think about it more. I wonder if "not set" is meaningful when the feature is enabled. I guess not, when feature is enabled and score is zero, it does not mean the scheduler does not set the value, but just indicate the score is zero. |
|
@bhperry , could you please see @qiujian16 's comment? I think both me and him prefer if we use a pointer here. Thanks. |
|
Once the feature in OCM is merged (I will rebase the PR tomorrow) score will never be "not set". When cluster decision is first created it has its initial score. That is why I don't think a pointer makes sense -- it will always be set to an integer, so it's an extra pointer dereference + nil check for no reason. In my opinion the best way forward would be:
|
|
ok makes sense to me. /approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mikeshng, qiujian16 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm |
a40dfdc
into
open-cluster-management-io:main
Summary
Add omitzero json tag to ClusterDecision.Score so that the default zero value is not serialized to JSON. The field remains int64 (non-pointer) and is only included when explicitly set to a non-zero value.
Related issue(s)
Fixes #
Summary by CodeRabbit