-
Notifications
You must be signed in to change notification settings - Fork 167
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
Conversation
Signed-off-by: JimmyYang20 <yangjin39@huawei.com>
} | ||
|
||
doJobStageEvent := func(nodeName string) { | ||
if currentType == sednav1.LLJobStageCondWaiting { |
There was a problem hiding this comment.
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
...
}
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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:
- built-in packages
- third-party packages
- self-packages
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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:
...
}
}
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, fix it
/lgtm |
worker's spec supports nodeName and nodeSelector Signed-off-by: JimmyYang20 <yangjin39@huawei.com>
a4b89b6
to
104943d
Compare
[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 |
worker's spec supports nodeName and nodeSelector
Signed-off-by: JimmyYang20 yangjin39@huawei.com