-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
Federated deployment controller - part 1 #34109
Federated deployment controller - part 1 #34109
Conversation
Jenkins unit/integration failed for commit e826dc7a7e2e3c8d75d98657c955f2fbf863ae44. Full PR test history. The magic incantation to run this job again is |
Thanks @mwielgus. Let me know when it's ready for review. |
PS: We will need a release note for this one, so I've switched the label. |
e826dc7
to
48307b0
Compare
The PR is ready for the review. The mentioned items will be don in follow-up prs. I'm not a big fan of sending >1k LOC PRs :). |
Jenkins GCI GKE smoke e2e failed for commit 48307b0. Full PR test history. The magic incantation to run this job again is |
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.
Partially complete review. More to come.
rs := newDeploymentWithReplicas("rs", 9) | ||
rs, _ = fedclientset.Extensions().Deployments(apiv1.NamespaceDefault).Create(rs) | ||
fedrswatch.Add(rs) | ||
time.Sleep(1 * time.Second) |
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.
Rather poll until success below. 1 second is arbitrary, slows down the test, and might lead to flakes in a highly contended environment.
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.
Fixed. The same needs to be applied to the original replicaset controller tests.
} | ||
} | ||
|
||
func TestDeploymentController(t *testing.T) { |
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 log messages, or at least comments to explain what you're testing at each step, and why.
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.
fedUpdater fedutil.FederatedUpdater | ||
|
||
deploymentBackoff *flowcontrol.Backoff | ||
// For events |
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 comment is not useful.
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.
done
fdc.reconcileDeploymentsOnClusterChange() | ||
}) | ||
|
||
for !fdc.isSynced() { |
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 could end up being a relatively tight endless loop. You'll need logging and exponential backoff.
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 logging. Exponential backoff is not needed here. If the controller cannot sync then it is useless.
|
||
go func() { | ||
select { | ||
case <-time.After(time.Minute): |
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.
There are a lot of seemingly arbitrary delay times in this code. Please lift them into variables or constants at the top of the file, and explain in comments what each time period is for, and how it's value was arrived at.
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 comment. No need to make it a constant.
} | ||
} | ||
|
||
func (fdc *DeploymentController) schedule(fd *extensionsv1.Deployment, clusters []*fedv1.Cluster, |
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 a method comment describing the arguments.
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.
current map[string]int64, estimatedCapacity map[string]int64) map[string]int64 { | ||
// TODO: integrate real scheduler | ||
|
||
planer := fdc.defaultPlanner |
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: planner with two n's
// TODO: integrate real scheduler | ||
|
||
planer := fdc.defaultPlanner | ||
fdPref, err := parseFederationDeploymentReference(fd) |
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.
Preference, not Reference?
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.
Done.
glog.Info("Invalid Deployment specific preference, use default. deployment: %v, err: %v", fd.Name, err) | ||
} | ||
if fdPref != nil { // create a new planner if user specified a preference | ||
planer = planner.NewPlanner(fdPref) |
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.
planner
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.
Done.
} | ||
scheduleResult, overflow := planer.Plan(replicas, clusterNames, current, estimatedCapacity, | ||
fd.Namespace+"/"+fd.Name) | ||
// make sure the return contains clusters need to zero the 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.
Please clarify/reword comment.
48307b0
to
c9e771a
Compare
LGTM as an initial revision. I will give the followup PR's a more thorough review, as quite a bit of this code is likely to change soon in those. |
Automatic merge from submit-queue |
Based on federated replicaset controller (copy + find/replace).
Remaining stuff:
cc: @quinton-hoole @kubernetes/sig-cluster-federation
Release note:
This change is