Skip to content
This repository has been archived by the owner on Oct 18, 2024. It is now read-only.

create empty decision when no cluster selected #95

Conversation

haoqing0110
Copy link
Member

#85

Signed-off-by: haoqing0110 qhao@redhat.com

@openshift-ci openshift-ci bot requested review from elgnay and qiujian16 December 21, 2022 11:13
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haoqing0110

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

for index := 0; len(remainingDecisions) > 0; index++ {
// if clusterDecisions is empty, append empty slice to decisionSlices,
// and create an PlacementDecision with empty decisions in status.
for index := 0; len(remainingDecisions) > 0 || len(decisionSlices) == 0; index++ {
Copy link
Member

Choose a reason for hiding this comment

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

This is confusing, can we make it more explicit

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

// so that can create an PlacementDecision with empty decisions in status.
if len(decisionSlices) == 0 {
decisionSlice := []clusterapiv1beta1.ClusterDecision{}
decisionSlices = append(decisionSlices, decisionSlice)
Copy link
Member

Choose a reason for hiding this comment

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

nit: decisionSlices = append(decisionSlices, []clusterapiv1beta1.ClusterDecision{})

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

Signed-off-by: haoqing0110 <qhao@redhat.com>
// requeue placement if requeueAfter is defined in scheduleResult
if syncCtx != nil && scheduleResult.RequeueAfter() != nil {
if syncCtx != nil && !status.IsError() && scheduleResult.RequeueAfter() != nil {
Copy link
Member

Choose a reason for hiding this comment

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

I think we should requeue no matter there is error or not? and should we return error finally after update status?

@@ -260,7 +252,12 @@ func (c *schedulingController) syncPlacement(ctx context.Context, syncCtx factor
}

// update placement status if necessary to signal no bindings
return c.updateStatus(ctx, placement, int32(len(scheduleResult.Decisions())), misconfiguredCondition, satisfiedCondition)
err = c.updateStatus(ctx, placement, int32(len(scheduleResult.Decisions())), misconfiguredCondition, satisfiedCondition)
Copy link
Member

Choose a reason for hiding this comment

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

nit

if err := xx ; err !=nil {
    return err
}

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed.

@@ -81,6 +81,14 @@ func (s *Status) AsError() error {
return errors.New(s.Message())
}

// Error returns the err when Code is "Error" or "Misconfigured".
func (s *Status) Error() error {
if s.IsError() {
Copy link
Member

Choose a reason for hiding this comment

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

hrm, we might want to refactor here. why we have both isError and asError? couldn't we just check if returned error is nil?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's for the case when Status is nil I think. Remove this func. And modify the NewStatus(), to ensure AsError can always return s.err when code is Error or Misconfigured.

@haoqing0110 haoqing0110 force-pushed the br_empty-decision branch 4 times, most recently from 274706a to b33c54e Compare December 26, 2022 02:56
Signed-off-by: haoqing0110 <qhao@redhat.com>
@qiujian16
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jan 3, 2023
@openshift-merge-robot openshift-merge-robot merged commit 75b8f2e into open-cluster-management-io:main Jan 3, 2023
@haoqing0110 haoqing0110 deleted the br_empty-decision branch January 3, 2023 01:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants