Skip to content

Commit cdde9b2

Browse files
authored
Merge pull request #757 from gkleiman/book-improvements
📖 Fix typos and improve grammar
2 parents 3f2c357 + 78d62b9 commit cdde9b2

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

docs/book/src/cronjob-tutorial/controller-implementation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ The basic logic of our CronJob controller is this:
88

99
3. Clean up old jobs according to the history limits
1010

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

13-
5. Get the next scheduled run
13+
5. Get the next scheduled run
1414

1515
6. Run a new job if it's on schedule, not past the deadline, and not
1616
blocked by our concurrency policy

docs/book/src/cronjob-tutorial/testdata/emptycontroller.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type CronJobReconciler struct {
4545

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

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

8585
/*
86-
Finally, we add this Reconciler to the manager, so that it gets started
86+
Finally, we add this reconciler to the manager, so that it gets started
8787
when the manager is started.
8888
8989
For now, we just note that this reconciler operates on `CronJob`s. Later,

docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ We'll also want a few extras, which will make our users' lives easier:
4141
4242
- A deadline for starting jobs (if we miss this deadline, we'll just wait till
4343
the next scheduled time)
44-
- What do to if multiple jobs would run at once (do wewait? stop the old one? run both?)
44+
- What do to if multiple jobs would run at once (do we wait? stop the old one? run both?)
4545
- A way to pause the running of a CronJob, in case something's wrong with it
4646
- Limits on old job history
4747
@@ -50,7 +50,7 @@ keep track of whether a job has run. We can use at least one old job to do
5050
this.
5151
5252
We'll use several markers (`// +comment`) to specify additional metadata. These
53-
will be used by [controller-tools](../TODO.md) when generating the our CRD manifest.
53+
will be used by [controller-tools](../TODO.md) when generating our CRD manifest.
5454
As we'll see in a bit, controller-tools will also use GoDoc to form descriptions for
5555
the fields.
5656
*/

docs/book/src/cronjob-tutorial/testdata/project/api/v1/groupversion_info.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ import (
3434

3535
/*
3636
Then, we have the commonly useful variables that help us set up our Scheme.
37-
Since need to use all the types in this package in our controller, it's helpful
38-
(and the convention) to have a convinient method to add all the types to some
39-
other `Scheme`. SchemeBuilder makes this easy for us
37+
Since we need to use all the types in this package in our controller, it's
38+
helpful (and the convention) to have a convenient method to add all the types to
39+
some other `Scheme`. SchemeBuilder makes this easy for us.
4040
*/
4141
var (
4242
// GroupVersion is group version used to register these objects

docs/book/src/cronjob-tutorial/testdata/project/controllers/cronjob_controller.go

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

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

@@ -56,8 +56,8 @@ type CronJobReconciler struct {
5656
}
5757

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)