-
Notifications
You must be signed in to change notification settings - Fork 699
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
controller: Refactor controller_pod #548
Conversation
/assign @ScorpioCPH @jlewi |
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.
Thanks, I like this function getPodSlices()
:)
pkg/controller.v2/controller_pod.go
Outdated
} | ||
|
||
func getPodSlices(pods []*v1.Pod, replicas int, logger *log.Entry) [][]*v1.Pod { | ||
podSlices := make([][]*v1.Pod, 0) | ||
logger.Infof("%v", pods) |
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 log maybe too verbose.
@@ -212,9 +198,9 @@ func getPodSlices(pods []*v1.Pod, replicas int, logger *log.Entry) [][]*v1.Pod { | |||
} |
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.
Should we break here?
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.
Sorry, I rebased the master and can not see it anymore, could you have another review and point it out?
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.
It has already been addressed.
pkg/controller.v2/controller_pod.go
Outdated
} | ||
|
||
func getPodSlices(pods []*v1.Pod, replicas int, logger *log.Entry) [][]*v1.Pod { | ||
podSlices := make([][]*v1.Pod, 0) | ||
logger.Infof("%v", pods) | ||
podSlices := make([][]*v1.Pod, replicas) |
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.
How about use a map for podSlices, like this:
podSlices := make(map[int64][]*v1.Pod, replicas)
pkg/controller.v2/controller_pod.go
Outdated
} | ||
|
||
func getPodSlices(pods []*v1.Pod, replicas int, logger *log.Entry) [][]*v1.Pod { | ||
podSlices := make([][]*v1.Pod, 0) | ||
logger.Infof("%v", pods) | ||
podSlices := make([][]*v1.Pod, replicas) | ||
for _, pod := range pods { | ||
if _, ok := pod.Labels[tfReplicaIndexLabel]; !ok { | ||
logger.Warning("The pod do not have the index label.") |
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.
continue here?
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.
Added
pkg/controller.v2/controller_pod.go
Outdated
// TODO(CPH): Need to delete pods. | ||
loggerForTFJob(tfjob).Infof("need to delete pod but it is not implemented yet") | ||
// We already have one, and check if it is succeede or something else. | ||
// pod := podSlice[0] |
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.
What this line used for?
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Addressed. |
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
nit; it would be great if you could add a more descriptive PR description. If its not making substantive changes I'm happy to leave it to you @ScorpioCPH |
Review status: 0 of 3 files reviewed at latest revision, 5 unresolved discussions. pkg/controller.v2/controller_pod.go, line 189 at r2 (raw file): Previously, ScorpioCPH (Penghao Cen) wrote…
IME we should log sufficient information to debug what the job did so we can troubleshoot. If we use the json log entry with appropriate keys; hopefully we can filter logs pretty easily. pkg/controller.v2/controller_pod.go, line 46 at r6 (raw file):
Should you compute succeeded and running pods in the loop below because you want to take into account the fact that a replica could have more than 1 pod. Why not use the for loop below to compute a map replicaIndex -> status pkg/controller.v2/controller_pod.go, line 53 at r6 (raw file):
More than 1 pod might not be an error. If there is 1 running pod and the rest are not running that might be fine. Might be worth noting that in the TODO as part of fixing this later. pkg/controller.v2/controller_pod.go, line 57 at r6 (raw file):
Would be good to log this message with keys corresponding to replica type and index. This way we can easily filter log messages to see what we did/didn't do for a particular replica. pkg/controller.v2/controller_pod.go, line 138 at r6 (raw file):
Please add a comment for getPodSlices; even thought its a private function it well help future readers of the code. Comments from Reviewable |
pkg/controller.v2/controller_pod.go, line 138 at r6 (raw file): Previously, jlewi (Jeremy Lewi) wrote…
OK, SGTM Comments from Reviewable |
pkg/controller.v2/controller_pod.go, line 189 at r2 (raw file): Previously, jlewi (Jeremy Lewi) wrote…
I added such statement for debug and removed now. I think the log in this function is enough to help us locate the errors. WDYT Comments from Reviewable |
pkg/controller.v2/controller_pod.go, line 190 at r2 (raw file): Previously, ScorpioCPH (Penghao Cen) wrote…
I considered it once but I think the index is in a range then I think slice is easier to understand. Comments from Reviewable |
Comments from Reviewable |
pkg/controller.v2/controller_pod.go, line 53 at r6 (raw file): Previously, jlewi (Jeremy Lewi) wrote…
I think it is an error since we expect that only one pod for one replica index is created. Comments from Reviewable |
pkg/controller.v2/controller_pod.go, line 46 at r6 (raw file): Previously, jlewi (Jeremy Lewi) wrote…
Good idea, I will update it. Comments from Reviewable |
pkg/controller.v2/controller_pod.go, line 57 at r6 (raw file): Previously, jlewi (Jeremy Lewi) wrote…
OK, will do it. Comments from Reviewable |
pkg/controller.v2/controller_pod.go, line 101 at r2 (raw file): Previously, ScorpioCPH (Penghao Cen) wrote…
Removed. Comments from Reviewable |
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.
LGTM with some minor nits.
@@ -0,0 +1,66 @@ | |||
package controller |
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.
Please add copyright here :)
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.
Sorry for that. I will add it soon.
} | ||
} | ||
|
||
// All workers are running, set StartTime |
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.
nit: add .
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
Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao <gaoce@caicloud.io>
PTAL @ScorpioCPH |
@gaocegege If the state of pod continues to change, it will always be restarted, and the state of |
thanks,I understand! |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ScorpioCPH 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 |
* controller_pod: refactor Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Add test case Signed-off-by: Ce Gao <gaoce@caicloud.io> * WIP Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller_pod: Separate creation and status update Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Add continue Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Remove old code Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Remove log Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Update Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller_status: Add copyright header Signed-off-by: Ce Gao <gaoce@caicloud.io>
* controller_pod: refactor Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Add test case Signed-off-by: Ce Gao <gaoce@caicloud.io> * WIP Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller_pod: Separate creation and status update Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Add continue Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Remove old code Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Remove log Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller: Update Signed-off-by: Ce Gao <gaoce@caicloud.io> * controller_status: Add copyright header Signed-off-by: Ce Gao <gaoce@caicloud.io>
Signed-off-by: Ce Gao gaoce@caicloud.io
This change is