Skip to content

Commit

Permalink
📖 Fix typos and improve grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
gkleiman committed Jun 1, 2019
1 parent 3f2c357 commit 78d62b9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions docs/book/src/cronjob-tutorial/controller-implementation.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ The basic logic of our CronJob controller is this:

3. Clean up old jobs according to the history limits

4. Check if we're supsended (and don't do anything else if we are)
4. Check if we're suspended (and don't do anything else if we are)

5. Get the next scheduled run
5. Get the next scheduled run

6. Run a new job if it's on schedule, not past the deadline, and not
blocked by our concurrency policy
Expand Down
10 changes: 5 additions & 5 deletions docs/book/src/cronjob-tutorial/testdata/emptycontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type CronJobReconciler struct {

/*
Most controllers eventually end up running on the cluster, so they need RBAC permissions.
These are the bare minimum permissions need to run. As we add more functionality, we'll
These are the bare minimum permissions needed to run. As we add more functionality, we'll
need to revisit these.
*/

Expand All @@ -65,11 +65,11 @@ Most controllers need a logging handle and a context, so we set them up here.
The [context](../TODO.md) is used to allow cancelation of requests, and potentially
things like tracing. It's the first argument to all client methods. The `Background`
context is just an basic context without any extra data or timing restrictions.
context is just a basic context without any extra data or timing restrictions.
The logging handles lets us log. controller-runtime uses structured logging through a
The logging handle lets us log. controller-runtime uses structured logging through a
library called [logr](https://github.com/go-logr/logr). As we'll see shortly,
logger works by attaching key-value pairs to a static message. We can pre-assign
logging works by attaching key-value pairs to a static message. We can pre-assign
some pairs at the top of our reconcile method to have those attached to all log
lines in this reconciler.
*/
Expand All @@ -83,7 +83,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
}

/*
Finally, we add this Reconciler to the manager, so that it gets started
Finally, we add this reconciler to the manager, so that it gets started
when the manager is started.
For now, we just note that this reconciler operates on `CronJob`s. Later,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ We'll also want a few extras, which will make our users' lives easier:
- A deadline for starting jobs (if we miss this deadline, we'll just wait till
the next scheduled time)
- What do to if multiple jobs would run at once (do wewait? stop the old one? run both?)
- What do to if multiple jobs would run at once (do we wait? stop the old one? run both?)
- A way to pause the running of a CronJob, in case something's wrong with it
- Limits on old job history
Expand All @@ -50,7 +50,7 @@ keep track of whether a job has run. We can use at least one old job to do
this.
We'll use several markers (`// +comment`) to specify additional metadata. These
will be used by [controller-tools](../TODO.md) when generating the our CRD manifest.
will be used by [controller-tools](../TODO.md) when generating our CRD manifest.
As we'll see in a bit, controller-tools will also use GoDoc to form descriptions for
the fields.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (

/*
Then, we have the commonly useful variables that help us set up our Scheme.
Since need to use all the types in this package in our controller, it's helpful
(and the convention) to have a convinient method to add all the types to some
other `Scheme`. SchemeBuilder makes this easy for us
Since we need to use all the types in this package in our controller, it's
helpful (and the convention) to have a convenient method to add all the types to
some other `Scheme`. SchemeBuilder makes this easy for us.
*/
var (
// GroupVersion is group version used to register these objects
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ limitations under the License.

/*
We'll start out with some imports. You'll see below that we'll need a few more imports
than those scaffolded for us. We'll take about each one when we use it.
than those scaffolded for us. We'll talk about each one when we use it.
*/
package controllers

Expand Down Expand Up @@ -56,8 +56,8 @@ type CronJobReconciler struct {
}

/*
We'll mock out the clock to make it easier to jump around in time while testing
The "real" clock just calls time.Now.
We'll mock out the clock to make it easier to jump around in time while testing,
the "real" clock just calls `time.Now`.
*/
type realClock struct{}

Expand All @@ -72,9 +72,9 @@ type Clock interface {
// +kubebuilder:docs-gen:collapse=Clock

/*
We generally want to ignore (not requeue) on NotFound errors,
since we'll get a reconcile request once the object becomes found,
and requeuing in the mean time won't help.
We generally want to ignore (not requeue) NotFound errors, since we'll get a
reconciliation request once the object exists, and requeuing in the meantime
won't help.
*/
func ignoreNotFound(err error) error {
if apierrs.IsNotFound(err) {
Expand Down Expand Up @@ -107,7 +107,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
log := r.Log.WithValues("cronjob", req.NamespacedName)

/*
### 1: Load the named CronJob
### 1: Load the CronJob by name
We'll fetch the CronJob using our client. All client methods take a context
(to allow for cancellation) as their first argument, and the object in question
Expand Down Expand Up @@ -146,7 +146,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
root object. Instead, you should reconstruct it every run. That's what we'll
do here.
We can check if a job is "finished" and whether is succeeded or failed using status
We can check if a job is "finished" and whether it succeeded or failed using status
conditions. We'll put that logic in a helper to make our code cleaner.
*/

Expand Down Expand Up @@ -243,7 +243,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
/*
Using the date we've gathered, we'll update the status of our CRD.
Just like before, we use our client. To specifically update the status
subresource, we'll use the the `Status` part of the client, with the `Update`
subresource, we'll use the `Status` part of the client, with the `Update`
method.
The status subresource ignores changes to spec, so it's less likely to conflict
Expand Down Expand Up @@ -302,7 +302,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {

/* ### 4: Check if we're suspended
If this object is supsended, we don't want to run any jobs, so we'll stop now.
If this object is suspended, we don't want to run any jobs, so we'll stop now.
This is useful if something's broken with the job we're running and we want to
pause runs to investigate or putz with the cluster, without deleting the object.
*/
Expand All @@ -315,7 +315,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
/*
### 5: Get the next scheduled run
If we're not pause, we'll need to calculate the next scheduled run, and whether
If we're not paused, we'll need to calculate the next scheduled run, and whether
or not we've got a run that we haven't processed yet.
*/

Expand All @@ -328,7 +328,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
bail so that we don't cause issues on controller restarts or wedges.
Otherwise, we'll just return the missed runs (of which we'll just use the latest),
and the next run, so that we can know the latest time to reconcile again.
and the next run, so that we can know when it's time to reconcile again.
*/
getNextSchedule := func(cronJob *batch.CronJob, now time.Time) (lastMissed *time.Time, next time.Time, err error) {
sched, err := cron.ParseStandard(cronJob.Spec.Schedule)
Expand All @@ -337,7 +337,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
}

// for optimization purposes, cheat a bit and start from our last observed run time
// we could reconsitute this here, but there's not much point, since we've
// we could reconstitute this here, but there's not much point, since we've
// just updated it.
var earliestTime time.Time
if cronJob.Status.LastScheduleTime != nil {
Expand All @@ -361,8 +361,8 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
for t := sched.Next(earliestTime); !t.After(now); t = sched.Next(t) {
lastMissed = &t
// An object might miss several starts. For example, if
// controller gets wedged on friday at 5:01pm when everyone has
// gone home, and someone comes in on tuesday AM and discovers
// controller gets wedged on Friday at 5:01pm when everyone has
// gone home, and someone comes in on Tuesday AM and discovers
// the problem and restarts the controller, then all the hourly
// jobs, more than 80 of them for one hourly scheduledJob, should
// all start running with no further intervention (if the scheduledJob
Expand All @@ -377,7 +377,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
starts++
if starts > 100 {
// We can't get the most recent times so just return an empty slice
return nil, time.Time{}, fmt.Errorf("Too many missed start time (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew.")
return nil, time.Time{}, fmt.Errorf("Too many missed start times (> 100). Set or decrease .spec.startingDeadlineSeconds or check clock skew.")
}
}
return lastMissed, sched.Next(now), nil
Expand Down Expand Up @@ -522,7 +522,7 @@ func (r *CronJobReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {
Finally, we'll update our setup. In order to allow our reconciler to quickly
look up Jobs by their owner, we'll need an index. We declare an index key that
we can later use with the client as a pseudo-field name, and then descibe how to
we can later use with the client as a pseudo-field name, and then describe how to
extract the indexed value from the Job object. The indexer will automatically take
care of namespaces for us, so we just have to extract the owner name if the Job has
a CronJob owner.
Expand Down

0 comments on commit 78d62b9

Please sign in to comment.