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

LL: support schedule workers on multi-nodes #287

Merged
merged 2 commits into from
May 24, 2022

Conversation

JimmyYang20
Copy link

worker's spec supports nodeName and nodeSelector

Signed-off-by: JimmyYang20 yangjin39@huawei.com

Signed-off-by: JimmyYang20 <yangjin39@huawei.com>
@kubeedge-bot kubeedge-bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 20, 2022
}

doJobStageEvent := func(nodeName string) {
if currentType == sednav1.LLJobStageCondWaiting {
Copy link
Member

Choose a reason for hiding this comment

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

Can we use swich to replace multiple if...else, like:

switch currentType {
    case sednav1.LLJobStageCondWaiting:
    ...
    case sednav1.LLJobStageCondRunning:
    ...
    case sednav1.LLJobStageCondCompleted, sednav1.LLJobStageCondFailed
    ...
}

Copy link
Author

Choose a reason for hiding this comment

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

ok, fix it

"fmt"
"k8s.io/apimachinery/pkg/types"
Copy link
Member

Choose a reason for hiding this comment

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

Follow the import order of go packages:

  1. built-in packages
  2. third-party packages
  3. self-packages

Copy link
Author

Choose a reason for hiding this comment

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

fix it

continue
}

if err != nil {
klog.Errorf("job(name=%s) complete the %s task failed, error: %v",
jobConfig.UniqueIdentifier, jobConfig.Phase, err)
klog.Errorf("job(%s) failed to complete the %s task: %v", name, jobStage, err)
}

<-tick.C
Copy link
Member

Choose a reason for hiding this comment

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

Suggested usage of ticker:

for {
	select {
		case <-job.JobConfig.Done:
			return
		case <-tick.C:
			...
		default:
			...
	}
}

Copy link
Author

Choose a reason for hiding this comment

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

fix it

func (lm *Manager) initJob(job *Job) error {
func (lm *Manager) initJob(job *Job, name string) error {
var err error
job.JobConfig = new(JobConfig)
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 not a good way to write code, it is recommended to:

jobConfig := new(JobConfig)
jobConfig.xxx = xxx
...
job.JobConfig = jobConfig

Copy link
Author

Choose a reason for hiding this comment

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

ok, fix it

@Poorunga
Copy link
Member

/lgtm

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label May 24, 2022
worker's spec supports nodeName and nodeSelector

Signed-off-by: JimmyYang20 <yangjin39@huawei.com>
@kubeedge-bot kubeedge-bot removed the lgtm Indicates that a PR is ready to be merged. label May 24, 2022
@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label May 24, 2022
@kubeedge-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jaypume

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

@kubeedge-bot kubeedge-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 24, 2022
@kubeedge-bot kubeedge-bot merged commit c7fa931 into kubeedge:main May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants