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

📖 Add project overview to docs, clean up docs, structure #295

Merged

Conversation

DirectXMan12
Copy link
Contributor

@DirectXMan12 DirectXMan12 commented Jan 16, 2019

This adds an overview of the project organization to the root godocs, and cleans up the docs here and there, fixing whitespace issues, cleaning up wording, clarifying, and adding docs where they're lacking.

This also moves things out of pkg/runtime, so that pkg/runtime is (mostly) deprecated paths to other things.

This lays out package docs for the client package, clarifies that
client.New creates a new direct-to-API client, and adds an example
for indexers.
This adds an overview of the library to the root package.
@k8s-ci-robot k8s-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 16, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: DirectXMan12

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 16, 2019
Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

Looks pretty good, some minor nits.

doc.go Outdated
//
// Controllers
//
// Controllers (pkg/controller) handle using events (pkg/events) to eventually
Copy link
Contributor

Choose a reason for hiding this comment

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

s/handle using/handle

doc.go Outdated
// Logging and Metrics
//
// Logging (pkg/log) in controller-runtime is done via structured logs, using a
// log interface set called logr (https://godoc.org/github.com/go-logr/logr).
Copy link
Contributor

Choose a reason for hiding this comment

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

s/interface set/interface ?

doc.go Outdated
//
// Metrics (pkg/metrics) provided by controller-runtime are registered into a
// controller-runtime-specific Prometheus metrics registery. The manager will
// serve these by default at an HTTP endpoint, and additional metrics may be
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we serve the metrics by default. We wanted to, but couldn't so because scaffolded tests won't be able to run in parallel because of port-conflict.

// stand up a copy of etcd and kube-apiserver, and provide the correct options
// to connect to the API server. It's designed to work well with the Ginkgo
// testing framework, but should work with any testing setup.
package controllerruntime
Copy link
Contributor

Choose a reason for hiding this comment

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

Nicely written overview.

@@ -196,3 +198,24 @@ func ExampleClient_delete() {
})
_ = c.Delete(context.Background(), u)
}

// This example shows how to set up and consume a field select over a pod's volumes' secretName field.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/field select/field selector

@@ -84,7 +84,8 @@ type Manager interface {
// Options are the arguments for creating a new Manager
type Options struct {
// Scheme is the scheme used to resolve runtime.Objects to GroupVersionKinds / Resources
// Defaults to the kubernetes/client-go scheme.Scheme
// Defaults to the kubernetes/client-go scheme.Scheme, but it's almost always a good
// idea to pass your own scheme in.
Copy link
Contributor

Choose a reason for hiding this comment

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

I have seen users struggling with this. I think we can provide some guidance here: For ex. user is writing controllers with built-in types, then default scheme is enough, but if using your own types/external-types, augment the default scheme with the scheme for specific types.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added more documentation on schemes to pkg/runtime/scheme, which probably should be promoted to pkg/scheme.

@DirectXMan12 DirectXMan12 changed the title [WIP] 📖 Add project overview to docs, clean up docs [WIP] 📖 Add project overview to docs, clean up docs, structure Jan 17, 2019
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 31, 2019
@DirectXMan12 DirectXMan12 changed the title [WIP] 📖 Add project overview to docs, clean up docs, structure 📖 Add project overview to docs, clean up docs, structure Jan 31, 2019
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 31, 2019
This cleans up the existing docs, clarifying working, improving spacing,
and making sure all packages have docs.
Manager previously conformed to a slightly different interface than
recorder.Provider.  This fixes that.
pkg/runtime is a bit of a odd collection right now.  This starts to move
stuff out of it, leaving aliases in place instead.  Since signals are
used to control managers, this functionality now lives in a subpackage
of manager.
Continue moving stuff out of pkg/runtime.  the schemebuilder now lives
in pkg/scheme.
FAQ.md Outdated

- When you can, take advantage of optimistic locking: use deterministic
names for objects you create, so that the Kubernetes API server will
warn you if the object already exists. May controllers in Kubernetes
Copy link
Contributor

Choose a reason for hiding this comment

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

s/May/Many/

FAQ.md Outdated

**A**: The fake client
[exists](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/client/fake),
but we generally reccomend using
Copy link

Choose a reason for hiding this comment

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

s/reccomend/recommend/

FAQ.md Outdated
[envtest.Environment](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/envtest#Environment)
to spin up a real API server instead of trying to mock one out.

- Structure your tests to check the that the state of the world is as you
Copy link

Choose a reason for hiding this comment

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

s/check the that/check that/

Copy link
Contributor

@droot droot left a comment

Choose a reason for hiding this comment

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

looks good to me (there are minor nits pointed out by another reviewer).

from the API groups that it needs (be they Kubernetes types or your own).
See the [scheme builder
docs](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/scheme) for
more information.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is excellent. We should add these to kubebuilder book.

@@ -25,7 +25,7 @@ import (
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/runtime/scheme"
"sigs.k8s.io/controller-runtime/pkg/scheme"
Copy link
Contributor

Choose a reason for hiding this comment

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

I am guessing this might impact scaffolded code.

Note to self: Audit scaffolded code (and figure out if migration guide needs to be written for cr-0.2.0) and update it to use cr-0.2.0.

func (bld *Builder) Build() (*runtime.Scheme, error) {
s := runtime.NewScheme()
return s, bld.AddToScheme(s)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice.

general, your application should have its own Scheme containing the types
from the API groups that it needs (be they Kubernetes types or your own).
See the [scheme builder
docs](https://godoc.org/sigs.k8s.io/controller-runtime/pkg/scheme) for
Copy link

Choose a reason for hiding this comment

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

s|controller-runtime/pkg/scheme|controller-runtime/pkg/runtime/scheme|

Copy link
Contributor Author

Choose a reason for hiding this comment

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

see above changes

This adds a series of FAQs.  A decent amount of this should be migrated
to the KB book.
I have a habit of spelling it with 2 'c's and one 'm'.
@mengqiy
Copy link
Member

mengqiy commented Feb 13, 2019

/lgtm
/hold
Moving packages is actually breaking changes. Maybe we should change the commit messages to use ⚠️ instead of ✨

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Feb 13, 2019
@mengqiy
Copy link
Member

mengqiy commented Feb 13, 2019

IIRC we are not going to release again in release-0.1 branch, so using ⚠️ or ✨ doesn't matter much ATM :)
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Feb 13, 2019
@k8s-ci-robot k8s-ci-robot merged commit 45d6520 into kubernetes-sigs:master Feb 13, 2019
@DirectXMan12 DirectXMan12 deleted the docs/overview-and-fixup branch February 14, 2019 22:13
@DirectXMan12
Copy link
Contributor Author

The package moves left aliases in place, so they shouldn't actually be breaking yet.

@droot droot mentioned this pull request Feb 19, 2019
// GetRecorder returns a new EventRecorder for the provided name
GetRecorder(name string) record.EventRecorder
// GetEventRecorderFor returns a new EventRecorder for the provided name
GetEventRecorderFor(name string) record.EventRecorder
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a breaking change. Was that intentional? If not, can we add the GetRecorder method back and deprecate it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was marked as breaking (on the commit). Did it make it into a stable branch? We should do a patch to the stable branch to restore it if so

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't look like it made it into a stable branch (it's not on release-0.1). Master is intended to have breaking changes, and yes, this was intended to be breaking (it brings manager in line with other things that provide a recorder).

Copy link
Contributor

Choose a reason for hiding this comment

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

Oops, I missed the breaking mark (I wasn't aware of the meaning of ⚠️), so please ignore my comment. Thanks for explaining @DirectXMan12!

DirectXMan12 pushed a commit that referenced this pull request Jan 31, 2020
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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.

None yet

7 participants