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

🌱 placement support decision groups #200

Conversation

haoqing0110
Copy link
Member

@haoqing0110 haoqing0110 commented Jun 28, 2023

Summary

Related issue(s)

#236

@codecov
Copy link

codecov bot commented Jun 28, 2023

Codecov Report

Patch coverage: 84.61% and project coverage change: +0.23 🎉

Comparison is base (c8ec750) 59.91% compared to head (37c85a6) 60.14%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #200      +/-   ##
==========================================
+ Coverage   59.91%   60.14%   +0.23%     
==========================================
  Files         128      128              
  Lines       13241    13376     +135     
==========================================
+ Hits         7933     8045     +112     
- Misses       4568     4585      +17     
- Partials      740      746       +6     
Flag Coverage Δ
unit 60.14% <84.61%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...nt/controllers/scheduling/scheduling_controller.go 65.84% <84.37%> (+6.51%) ⬆️
pkg/placement/controllers/scheduling/schedule.go 68.69% <100.00%> (-0.86%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@haoqing0110 haoqing0110 force-pushed the br_placement-strategy branch from 59e5c68 to d721dd5 Compare June 28, 2023 10:32
elgnay pushed a commit to elgnay/ocm that referenced this pull request Jun 29, 2023
@haoqing0110 haoqing0110 force-pushed the br_placement-strategy branch from d721dd5 to 05c277b Compare June 30, 2023 07:06
@haoqing0110 haoqing0110 force-pushed the br_placement-strategy branch from 05c277b to 21892ee Compare June 30, 2023 14:54
@haoqing0110 haoqing0110 changed the title [wip] placement support decision groups 🌱 [wip] placement support decision groups Jun 30, 2023
@haoqing0110 haoqing0110 changed the title 🌱 [wip] placement support decision groups [wip] 🌱 placement support decision groups Jun 30, 2023
@haoqing0110
Copy link
Member Author

/assign @qiujian16 @serngawy

@haoqing0110 haoqing0110 changed the title [wip] 🌱 placement support decision groups 🌱 placement support decision groups Jul 3, 2023
// ScheduleResult is the result for a certain schedule.
type scheduleResult struct {
feasibleClusters []*clusterapiv1.ManagedCluster
scheduledDecisions []clusterapiv1beta1.ClusterDecision
Copy link
Member

Choose a reason for hiding this comment

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

I actually think the scheduledDecisions here should be []*clusterapiv1.ManagedCluster,

And you should have a process like

  1. schedule
  2. generateDecision
  3. bind

Copy link
Member Author

Choose a reason for hiding this comment

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

Change to []*clusterapiv1.ManagedCluster and update the placement decision generate and update flow.

})

// generate placement decisions, group index starts from 0, decision name index starts from 1 for readability.
pds, groupStatus := c.generatePlacementDecisionsAndStatus(placement, decisionGroup, decisionGroupIndex, placementDecisionIndex+1)
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 weird. the two should at least start with the same index

Copy link
Member Author

Choose a reason for hiding this comment

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

change to start from 0.

assertNumberOfDecisions(placementName, namespace, 0, 1)
})

ginkgo.It("Should update the decision group once clusters belong to labelselector clusterset are added/deleted", func() {
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 also have a static group field? should we also test it?

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the case.

@haoqing0110 haoqing0110 force-pushed the br_placement-strategy branch 2 times, most recently from a754dca to d5af93d Compare July 5, 2023 03:25
@haoqing0110 haoqing0110 force-pushed the br_placement-strategy branch from d5af93d to dd41ad5 Compare July 5, 2023 07:22
@haoqing0110 haoqing0110 force-pushed the br_placement-strategy branch 2 times, most recently from 9b14b19 to 37c85a6 Compare July 6, 2023 08:52
// The group length depends on ClustersPerDecisionGroup.
if len(clusterNames) > 0 {
matched := []clusterapiv1beta1.ClusterDecision{}
for _, cluster := range clusters {
Copy link
Member

Choose a reason for hiding this comment

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

why we do not directly iterate the clusterNames, but still iterate cluster?
can we do something like

for len(clusterNames) > 0 {
  clusterList := clusterNames.List()
  resultNumber := len(clusterList)
  if length < resultNumber {
     resultNumber = length
  }
  matched := []clusterapiv1beta1.ClusterDecision{}
  for i:=0; i<resultNumber; i++ {
    matched = append(matched, clusterapiv1beta1.ClusterDecision{
				ClusterName: clusterList[i],
    })
   delete(clusterNames, clusterList[i])
  }
  decisionGroup := clusterDecisionGroup{
				decisionGroupName: "",
				clusterDecisions:  matched,
 }
groups = append(groups, decisionGroup)
}

Copy link
Member Author

@haoqing0110 haoqing0110 Jul 7, 2023

Choose a reason for hiding this comment

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

why we do not directly iterate the clusterNames, but still iterate cluster?

This is to ensure the dynamic group clusters are always in the same order. The above suggestion looks good.

One question is, when the group length is 0, do we expect it to be the same as 100%, or expect no group (all the clusters not selected by the decision group will not be shown in the placement decision)? or we expect the length to be at least 1?

Copy link
Member

Choose a reason for hiding this comment

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

should be 100% I think

Copy link
Member

Choose a reason for hiding this comment

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

actual I do not think it could be 0, we should validate on API.

Copy link
Member Author

Choose a reason for hiding this comment

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

Update code, and will update the api in another PR.

@haoqing0110 haoqing0110 force-pushed the br_placement-strategy branch from 37c85a6 to 24e0ec5 Compare July 10, 2023 06:19
@qiujian16
Copy link
Member

/approve

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 10, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: haoqing0110, 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

Signed-off-by: haoqing0110 <qhao@redhat.com>
Signed-off-by: haoqing0110 <qhao@redhat.com>
Signed-off-by: haoqing0110 <qhao@redhat.com>
Signed-off-by: haoqing0110 <qhao@redhat.com>
Signed-off-by: haoqing0110 <qhao@redhat.com>
Signed-off-by: haoqing0110 <qhao@redhat.com>
@haoqing0110 haoqing0110 force-pushed the br_placement-strategy branch from 24e0ec5 to 38a2716 Compare July 10, 2023 08:47
@qiujian16
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jul 10, 2023
@openshift-merge-robot openshift-merge-robot merged commit 6649834 into open-cluster-management-io:main Jul 10, 2023
@haoqing0110 haoqing0110 deleted the br_placement-strategy branch July 10, 2023 13:48
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.

4 participants