Skip to content

Commit a76ae87

Browse files
authored
Merge pull request kubernetes#2985 from losipiuk/losipiuk-patch-1
Document hack/update-vendor.sh
2 parents 3268c01 + 85a458e commit a76ae87

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

cluster-autoscaler/FAQ.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -912,4 +912,43 @@ We are aware that this process is tedious and we will work to improve it.
912912

913913
### How can I update CA dependencies (particularly k8s.io/kubernetes)?
914914

915-
TODO - update needed after k8s migrated to go modules
915+
Cluster Autoscaler imports a huge chunk of internal k8s code as it calls out to scheduler implementation.
916+
Therefore we want to keep set of libraries used in CA as close to one used by k8s, to avoid
917+
unexpected problems coming from version incompatibilities.
918+
919+
Cluster Autoscaler depends on `go modules` mechanism for dependency management, but do not use it directly
920+
during build process. `go.mod` file is just used to generate the `vendor` directory and further compilation
921+
is run against set of libraries stored in `vendor`. `vendor` directory can be regenerated using [`update-vendor.sh`](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/hack/update-vendor.sh) script.
922+
The `update-vendor.sh` script is responsible for autogenerating `go.mod` file used by Cluster Autoscaler. The base
923+
of the file is `go.mod` file coming from [kubernetes/kubernetes](https://github.com/kubernetes/kubernetes) repository.
924+
On top of that script adds modifications as defined
925+
locally in [`go.mod-extra`](https://github.com/kubernetes/autoscaler/blob/master/cluster-autoscaler/go.mod-extra) file.
926+
927+
Note: It is important that one should **never manually edit** `go.mod` file as it is regenerated
928+
on each `update-vendor.sh` call. Any extra libraries or version overrides should be put in `go.mod-extra` file (syntax of the file
929+
is same as syntax of `go.mod` file).
930+
931+
Finally `vendor` directry is materialized and validation tests are run.
932+
933+
If everything completes correctly a commit with updated `vendor` directory is created automatically. The pull-request with changed vendor
934+
must be sent out manually. The PR should include the auto-generated commit as well as commits containing any manual changes/fixes that need to
935+
go together.
936+
937+
Execution of `update-vendor.sh` can be parametrized using command line argumets:
938+
- `-f` - kubernetes/kubernetes fork to use. On `master` it defaults to `[email protected]:kubernetes/kubernetes.git`
939+
- `-r` - revision in kubernetes/kubernetes which should be used to get base `go.mod` file
940+
- `-d` - specifies script workdir; useful to speed up execution if script needs to be run multiple times, because updating vendor resulted in some compilation errors on Cluster-Autoscaler side which need to be fixed
941+
942+
Example execution looks like this:
943+
```
944+
./hack/update-vendor.sh -d/tmp/ca-update-vendor.ou1l [email protected]:kubernetes/kubernetes.git -rmaster
945+
```
946+
947+
Caveats:
948+
- `update-vendor.sh` is called directly in shell (no docker is used) therefore its operation may differ from environment to environment.
949+
- It is important that go version, which isn in use in the shell in which `update-vendor.sh` is called, matches the `go <version>` directive specified in `go.mod` file
950+
in `kubernetes/kubernetes` revision against which revendoring is done.
951+
- `update-vendor.sh` automatically runs unit tests as part of verification process. If one needs to suppress that, it can be done by overriding `VERIFY_COMMAND` variable (`VERIFY_COMMAND=true ./hack/update-vendor.sh ...`)
952+
- If one wants to only add new libraries to `go.mod-extra`, but not change the base `go.mod`, `-r` should be used with kubernetes/kubernets revision, which was used last time `update-vendor.sh` was called. One can determine that revision by looking at `git log` in Cluster Autoscaler repository. Following command will do the trick `git log | grep "Updating vendor against"`.
953+
954+

0 commit comments

Comments
 (0)