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

Federated deployment controller - part 1 #34109

Merged

Conversation

mwielgus
Copy link
Contributor

@mwielgus mwielgus commented Oct 5, 2016

Based on federated replicaset controller (copy + find/replace).

Remaining stuff:

  • refacing out common elements to libs
  • using owerref in pod analysis
  • e2e tests
  • renaming concurrency flag for rs and reusing it in deployment
  • updating only one cluster at a time if rollingupdate strategy is used.

cc: @quinton-hoole @kubernetes/sig-cluster-federation

Release note:

Alpha version of federated deployment controller

This change is Reviewable

@mwielgus mwielgus added retest-not-required release-note-none Denotes a PR that doesn't merit a release note. labels Oct 5, 2016
@mwielgus mwielgus added this to the v1.5 milestone Oct 5, 2016
@mwielgus mwielgus assigned ghost Oct 5, 2016
@k8s-github-robot k8s-github-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 5, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins unit/integration failed for commit e826dc7a7e2e3c8d75d98657c955f2fbf863ae44. Full PR test history.

The magic incantation to run this job again is @k8s-bot unit test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@ghost
Copy link

ghost commented Oct 5, 2016

Thanks @mwielgus. Let me know when it's ready for review.

@ghost ghost added the priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. label Oct 5, 2016
@ghost
Copy link

ghost commented Oct 5, 2016

PS: We will need a release note for this one, so I've switched the label.

@ghost ghost added release-note-label-needed and removed release-note-none Denotes a PR that doesn't merit a release note. labels Oct 5, 2016
@mwielgus mwielgus force-pushed the fed-deployment-controller branch from e826dc7 to 48307b0 Compare October 6, 2016 14:30
@mwielgus
Copy link
Contributor Author

mwielgus commented Oct 6, 2016

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 :).

@mwielgus mwielgus added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Oct 6, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GKE smoke e2e failed for commit 48307b0. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

Copy link

@ghost ghost left a 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)
Copy link

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.

Copy link
Contributor Author

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) {
Copy link

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.

Copy link
Contributor Author

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
Copy link

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.

Copy link
Contributor Author

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() {
Copy link

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.

Copy link
Contributor Author

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):
Copy link

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.

Copy link
Contributor Author

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,
Copy link

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.

Copy link
Contributor Author

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
Copy link

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)
Copy link

Choose a reason for hiding this comment

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

Preference, not Reference?

Copy link
Contributor Author

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)
Copy link

Choose a reason for hiding this comment

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

planner

Copy link
Contributor Author

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
Copy link

Choose a reason for hiding this comment

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

Please clarify/reword comment.

@ghost ghost added the team/control-plane label Oct 6, 2016
@mwielgus mwielgus force-pushed the fed-deployment-controller branch from 48307b0 to c9e771a Compare October 10, 2016 14:25
@ghost
Copy link

ghost commented Oct 10, 2016

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.

@ghost ghost added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 10, 2016
@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit e72f26a into kubernetes:master Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants