Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

Commit

Permalink
Makefile: Remove 'clean' prerequisite from build targets
Browse files Browse the repository at this point in the history
'clean' has been a prerequisite for:

* conformance-%, since the target landed in 0520bdf (hack: add
  conformance tests for hack builds, 2016-05-26, #45).
* release, since the target landed in 04848d1 (Add release build
  process, 2016-05-27, #47).

clean-vm-% target has been a prerequisite for run-% since the target
landed in 9e2e89e (run make target, 2016-09-23, #141).

But there are two problems with including cleaners are prerequisites
of build steps:

* They are inefficient.  Make is good at rebuilding only things that
  need rebuilding, provided you inform it of your dependencies.
  Cleaning before every build will often lead to unnecessary rebuilds
  of up-to-date content.

* They are racy.  For example, a parallel make invocation may process
  several prerequisites at once.  The current 'clean' recipe will
  execute quickly, which is why it hasn't been much of a problem yet,
  but you can see the race by inserting a delay:

    clean:
      sleep 60
      rm -rf _output

  and running:

    $ make -j8 release
    sleep 60
    mkdir -p _output/bin/darwin/
    GOOS=darwin GOARCH=amd64   go build ...
    ...
    mkdir -p _output/release/
    tar czf _output/release/bootkube.tar.gz -C _output bin/linux/bootkube bin/darwin/bootkube bin/linux/checkpoint
    rm -rf _output

  with the other preqrequisites completing first, clean's rm ends up
  removing everything release generated.

In this commit, I've removed the clean prerequisites from the build
targets to resolve the above issues.  I've also updated our
recommended make invocations to add clean as an explicit earlier step.
This ensures folks following our directions get the same behavior as
they would have previously (since our recommendations are all
implicitly -j1 and rm is fast anyway).  I think the extra clean calls
may be overkill in at least some cases, but I'll remove them one by
one in follow-up commits.
  • Loading branch information
wking committed Mar 29, 2018
1 parent fbcb680 commit 9e18c38
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ go:
- 1.9.x
- 1.10.x
script:
- make clean release
- make clean
- make release
13 changes: 9 additions & 4 deletions Documentation/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ cd $GOPATH/src/github.com/kubernetes-incubator/bootkube
Then, to build (only Go verson 1.8 is supported now):

```
make clean all
make clean
make all
```

## Local Development Environments

To easily launch local vagrant development clusters:
To easily launch local, single-node vagrant development clusters:

```
# Launch a single-node cluster
make clean-vm-single
make run-single
```

You can also launch a multi-node cluster:

```
# Launch a multi-node cluster
make clean-vm-multi
make run-multi
```

Expand All @@ -39,10 +42,12 @@ Each of these commands will recompile bootkube, then render new assets and provi
Additionally, if you wish to run upstream Kubernetes conformance tests against these local clusters:

```
make clean
make conformance-single
```

```
make clean
make conformance-multi
```

Expand Down
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ cross: \
_output/bin/linux/s390x/checkpoint

release: \
clean \
check \
_output/release/bootkube.tar.gz \

Expand Down Expand Up @@ -56,7 +55,7 @@ _output/release/bootkube.tar.gz: _output/bin/linux/bootkube _output/bin/darwin/b
tar czf $@ -C _output bin/linux/bootkube bin/darwin/bootkube bin/linux/checkpoint

run-%: GOFLAGS = -i
run-%: clean-vm-% _output/bin/linux/bootkube _output/bin/$(LOCAL_OS)/bootkube
run-%: _output/bin/linux/bootkube _output/bin/$(LOCAL_OS)/bootkube
@cd hack/$*-node && ./bootkube-up
@echo "Bootkube ready"

Expand All @@ -68,7 +67,7 @@ clean-vm-%:
rm -rf cluster )

#TODO(aaron): Prompt because this is destructive
conformance-%: clean all
conformance-%: all
@cd hack/$*-node && vagrant destroy -f
@cd hack/$*-node && rm -rf cluster
@cd hack/$*-node && ./bootkube-up
Expand Down
3 changes: 3 additions & 0 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ Or, manually:

```
# Vagrant
make clean
make conformance-multi
```

Expand All @@ -96,6 +97,7 @@ Or, manually:

```
git checkout vX.Y.Z
make clean
make release
PUSH_IMAGE=true ./build/build-image.sh
```
Expand All @@ -112,6 +114,7 @@ Or, manually:

```
git checkout master # Checkpointer releases should only be built from commits reachable by master
make clean
make release
BUILD_IMAGE=checkpoint PUSH_IMAGE=true ./build/build-image.sh
```
Expand Down

0 comments on commit 9e18c38

Please sign in to comment.