Commit Graph

166 Commits

Author SHA1 Message Date
Patrick Ohly
39bbcedbca dra api: add structured parameters
NodeResourceSlice will be used by kubelet to publish resource information on
behalf of DRA drivers on the node. NodeName and DriverName in
NodeResourceSlice must be immutable. This simplifies tracking the different
objects because what they are for cannot change after creation.

The new field in ResourceClass tells scheduler and autoscaler that they are
expected to handle allocation.

ResourceClaimParameters and ResourceClassParameters are new types for telling
in-tree components how to handle claims.
2024-03-07 16:15:31 +01:00
Tim Hockin
df7f5fca27
Don't embed plural exceptions in tools 2024-03-06 14:57:46 -08:00
Tim Hockin
00e09374b6
Make update-codegen avoid sub-workspaces 2024-02-29 22:10:39 -08:00
Tim Hockin
1a4450f6ff
Get rid of code-generator/cmd/openapi-gen
It's an exact duplicate of k8s.io/kube-openapi/cmd/openapi-gen.
2024-02-29 22:07:37 -08:00
Tim Hockin
8288c06b2b
Make hack scripts use go install and assume PATH
Now that they all call setup_env, we don't need find-binary (I think).
That was originally meant to hide the diff between docker and local
builds but all these tools do local builds anyway.
2024-02-29 22:07:32 -08:00
Tim Hockin
b68340e5b6
Get rid of gengo InputDirs flag 2024-02-29 22:07:23 -08:00
Tim Hockin
d0dd72b01e
Move OutputFileBase flag to each tool 2024-02-29 22:07:16 -08:00
Tim Hockin
26a1a13b80
Rename output-package -> output-pkg
To parallel "output-dir".
2024-02-29 22:07:15 -08:00
Tim Hockin
6a375b8f4c
Move the OutputBase flag to each tool
...and rename to --output-dir
2024-02-29 22:07:14 -08:00
Tim Hockin
0ff7dd1943
Rename gengo DefaultGen -> GolangGenerator 2024-02-29 22:07:12 -08:00
Tim Hockin
4320631265
codegen: Don't need to pass --logtostderr
All the tools already set it internally
2024-02-29 22:07:06 -08:00
Tim Hockin
19b37f046f
Rename update-generated-* dockerized
Now they don't start with "update" and confuse dumb scripts which try to
run all the updates.
2024-02-29 22:07:04 -08:00
Tim Hockin
94b709c0e2
codegen: Use single-dash for '-v' 2024-02-29 22:07:04 -08:00
Tim Hockin
3c2940f2ae
Kill off PRJ_SRC_PATH 2024-02-29 22:06:50 -08:00
Tim Hockin
530c4352fb
Rename new::setup_env back to setup_env 2024-02-29 22:06:44 -08:00
Tim Hockin
f772410082
Make code-gen subprojects work on gengo/v2 2024-02-29 22:06:38 -08:00
Tim Hockin
7506048d3f
Make update-codegen client work on gengo/v2 2024-02-29 22:06:36 -08:00
Tim Hockin
130a9f8426
Make update-codegen applyconfig work on gengo/v2 2024-02-29 22:06:34 -08:00
Tim Hockin
9c62235266
Make update-codegen informer work on gengo/v2 2024-02-29 22:06:32 -08:00
Tim Hockin
46665fa76a
Make update-codegen lister work on gengo/v2 2024-02-29 22:06:31 -08:00
Tim Hockin
1965f56f59
Make update-codegen openapi work on gengo/v2 2024-02-29 22:06:29 -08:00
Tim Hockin
5475797f43
Make update-codegen conversion work on gengo/v2 2024-02-29 22:06:28 -08:00
Tim Hockin
1e96f4e50a
Make update-codegen prerelease work on gengo/v2 2024-02-29 22:06:26 -08:00
Tim Hockin
b5b8c9d869
Make update-codegen swagger work on gengo/v2 2024-02-29 22:06:25 -08:00
Tim Hockin
8420278c7f
Make update-codegen defaulter work on gengo/v2 2024-02-29 22:06:24 -08:00
Tim Hockin
1fb4e824ba
Make update-codegen deepcopy work on gengo/v2 2024-02-29 22:06:23 -08:00
Tim Hockin
d5e8e9c29c
Change update-codegen.sh to use new setup_env
This breaks all the generators, which will be fixed subsequently.
2024-02-29 22:06:22 -08:00
Tim Hockin
8b579b2347
Change the build_binaries path to use modules
This makes "new" and "old" setup_env functions. In subsequent commits,
all callers of the "old" form will be fixed, and the "new" will be
renamed back.

The old and new functions diff:

```diff
--- /tmp/a	2023-12-14 09:02:57.804092696 -0800
+++ /tmp/b	2023-12-14 09:03:09.679999585 -0800
@@ -1,4 +1,4 @@
-kube::golang::old::setup_env() {
+kube::golang:🆕:setup_env() {
   kube::golang::verify_go_version

   # Set up GOPATH.  We have tools which depend on being in a GOPATH (see
@@ -7,9 +7,9 @@
   # Even in module mode, we need to set GOPATH for `go build` and `go install`
   # to work.  We build various tools (usually via `go install`) from a lot of
   # scripts.
-  #   * We can't set GOBIN because that does not work on cross-compiles.
-  #   * We could use `go build -o <something>`, but it's subtle when it comes
-  #     to cross-compiles and whether the <something> is a file or a directory,
+  #   * We can't just set GOBIN because that does not work on cross-compiles.
+  #   * We could always use `go build -o <something>`, but it's subtle wrt
+  #     cross-compiles and whether the <something> is a file or a directory,
   #     and EVERY caller has to get it *just* right.
   #   * We could leave GOPATH alone and let `go install` write binaries
   #     wherever the user's GOPATH says (or doesn't say).
@@ -20,16 +20,6 @@
   #
   # Eventually, when we no longer rely on run-in-gopath.sh we may be able to
   # simplify this some.
-  local go_pkg_dir="${KUBE_GOPATH}/src/${KUBE_GO_PACKAGE}"
-  local go_pkg_basedir
-  go_pkg_basedir=$(dirname "${go_pkg_dir}")
-
-  mkdir -p "${go_pkg_basedir}"
-
-  # TODO: This symlink should be relative.
-  if [[ ! -e "${go_pkg_dir}" || "$(readlink "${go_pkg_dir}")" != "${KUBE_ROOT}" ]]; then
-    ln -snf "${KUBE_ROOT}" "${go_pkg_dir}"
-  fi
   export GOPATH="${KUBE_GOPATH}"

   # If these are not set, set them now.  This ensures that any subsequent
@@ -40,24 +30,10 @@
   # Make sure our own Go binaries are in PATH.
   export PATH="${KUBE_GOPATH}/bin:${PATH}"

-  # Change directories so that we are within the GOPATH.  Some tools get really
-  # upset if this is not true.  We use a whole fake GOPATH here to collect the
-  # resultant binaries.
-  local subdir
-  subdir=$(kube::realpath . | sed "s|${KUBE_ROOT}||")
-  cd "${KUBE_GOPATH}/src/${KUBE_GO_PACKAGE}/${subdir}" || return 1
-
-  # Set GOROOT so binaries that parse code can work properly.
-  GOROOT=$(go env GOROOT)
-  export GOROOT
-
   # Unset GOBIN in case it already exists in the current session.
   # Cross-compiles will not work with it set.
   unset GOBIN

-  # This seems to matter to some tools
-  export GO15VENDOREXPERIMENT=1
-
-  # Disable workspaces
-  export GOWORK=off
+  # Explicitly turn on modules.
+  export GO111MODULE=on
 }
```

Result: `make` works for k/k:

```
$ make kubectl
+++ [1211 11:07:31] Building go targets for linux/amd64
    k8s.io/kubernetes/cmd/kubectl (static)

$ make WHAT=./cmd/kubectl/
+++ [1211 11:08:19] Building go targets for linux/amd64
    k8s.io/kubernetes/./cmd/kubectl/ (non-static)

$ make WHAT=k8s.io/kubernetes/cmd/kubectl
+++ [1211 11:08:52] Building go targets for linux/amd64
    k8s.io/kubernetes/cmd/kubectl (static)
```

Result: `make` works for staging by package:

```
$ make WHAT=k8s.io/api
+++ [1211 11:11:37] Building go targets for linux/amd64
    k8s.io/api (non-static)
```

Result: `make` fails for staging by path:

```
$ make WHAT=./staging/src/k8s.io/api
+++ [1211 11:12:44] Building go targets for linux/amd64
    k8s.io/kubernetes/./staging/src/k8s.io/api (non-static)
cannot find module providing package k8s.io/kubernetes/staging/src/k8s.io/api: import lookup disabled by -mod=vendor
	(Go version in go.work is at least 1.14 and vendor directory exists.)
!!! [1211 11:12:44] Call tree:
!!! [1211 11:12:44]  1: /home/thockin/src/kubernetes/hack/lib/golang.sh:850 kube::golang::build_some_binaries(...)
!!! [1211 11:12:44]  2: /home/thockin/src/kubernetes/hack/lib/golang.sh:1012 kube::golang::build_binaries_for_platform(...)
!!! [1211 11:12:44]  3: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [1211 11:12:44] Call tree:
!!! [1211 11:12:44]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
!!! [1211 11:12:44] Call tree:
!!! [1211 11:12:44]  1: hack/make-rules/build.sh:27 kube::golang::build_binaries(...)
make: *** [Makefile:96: all] Error 1
```

Result: `make test` fails:

```
$ make test WHAT=./cmd/kubectl
+++ [1211 11:13:38] Set GOMAXPROCS automatically to 6
+++ [1211 11:13:38] Running tests without code coverage and with -race
cmd/kubectl/kubectl.go:25:2: cannot find package "k8s.io/client-go/plugin/pkg/client/auth" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/client-go/plugin/pkg/client/auth (vendor tree)
	/home/thockin/sdk/gotip/src/k8s.io/client-go/plugin/pkg/client/auth (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/client-go/plugin/pkg/client/auth (from $GOPATH)
cmd/kubectl/kubectl.go:20:2: cannot find package "k8s.io/component-base/cli" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/component-base/cli (vendor tree)
	/home/thockin/sdk/gotip/src/k8s.io/component-base/cli (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/component-base/cli (from $GOPATH)
cmd/kubectl/kubectl.go:21:2: cannot find package "k8s.io/kubectl/pkg/cmd" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd (vendor tree)
	/home/thockin/sdk/gotip/src/k8s.io/kubectl/pkg/cmd (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubectl/pkg/cmd (from $GOPATH)
cmd/kubectl/kubectl.go:22:2: cannot find package "k8s.io/kubectl/pkg/cmd/util" in any of:
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubernetes/vendor/k8s.io/kubectl/pkg/cmd/util (vendor tree)
	/home/thockin/sdk/gotip/src/k8s.io/kubectl/pkg/cmd/util (from $GOROOT)
	/home/thockin/src/kubernetes/_output/local/go/src/k8s.io/kubectl/pkg/cmd/util (from $GOPATH)
make: *** [Makefile:191: test] Error 1
```
2024-02-29 00:22:07 -08:00
Tim Hockin
0d366dd99a
codegen: Use long flag names for clarity 2024-01-14 16:12:09 -08:00
Kubernetes Prow Robot
dcee8834b5
Merge pull request #122775 from thockin/codegen_s_base_file_g
update-codegen: rename "base"->"file" for clarity
2024-01-15 01:08:39 +01:00
Tim Hockin
0f849d3b55
update-codegen: rename "base"->"file" for clarity 2024-01-14 10:41:59 -08:00
Tim Hockin
f2b550180c
codegen: don't use xargs w/ maybe-empty input
GNU xargs has a `-r, --no-run-if-empty` option but I don't think we want
to depend on GNU (thanks, MacOS).

Why?  Sometimes, when you are messing with codegens, you end up with an
empty input and then it just hangs.
2024-01-14 10:38:34 -08:00
Tim Hockin
6607834207
Use the same report files as before 2023-05-09 19:33:21 -07:00
Tim Hockin
ef796dca9b
Simpler openapi gen - subprojects do themselves
This involves moving the report files, but it allows me to delete the
indirect variable and indirect array code in update-codgen.  As proud as
I was of figuring that out, I am also ashamed of myself for doing it.

This is my atonement.
2023-05-09 16:24:18 -07:00
Tim Hockin
93b2845bec
Codegen: subprojects openapi
Use the "subprojects" aspect of update-codegen to generat openapi for
the subprojects.  Next we can simplify and remove the generic support.

apiextensions-apiserver seems like it was ALWAYS broken:
k8s.io/apiextensions/ doesn't exist, but k8s.io/apiextensions-apiserver
does.

Fixing that causes different openapi results, obviously.
2023-05-09 16:24:17 -07:00
Alexander Zielenski
4721ec7519 include apiextensions types in apiextensions generated openapi
k8s_tag_files_matching looks for a slash after its argument, so the current value doesnt match anything

also update codegen

this is required for apiextensions-apiserver tests. After fixing apiextensions server tests to use type-aware SSA (instead of erroneously using untyped SSA) there were errors since none of the apiextensions types were actually used in the openapi given to tests.
2023-05-01 13:18:44 -07:00
Tim Hockin
5668399a87
Codegen: use openapi-gen via k8s.io/code-generator 2023-04-12 17:08:36 -07:00
Kubernetes Prow Robot
ad85a92dd4
Merge pull request #116281 from thockin/codegen_subproject_chdir
Codegen: subproject cleanups and chdir
2023-04-12 09:58:31 -07:00
Kubernetes Prow Robot
4c022ceb2c
Merge pull request #116283 from thockin/codegen_fix_full_regen
Codegen: fix full (burn it to the ground) regen
2023-04-11 15:35:56 -07:00
Tim Hockin
73eb7c0930
Codegen: easier to read logs for subproject output 2023-04-11 15:19:27 -07:00
Tim Hockin
bbbb695060
Codegen: subproject: chdir to the project dir
This makes it feel more like an API to be used in other repos (which is
really what it is for).
2023-04-11 15:18:08 -07:00
Tim Hockin
893ec0ca45
Codegen: simpler k8s.io/code-generator/examples
This moves the hack/ directory and scripts to the examples dir, which is
a distinct module.  This avoids some Go unpleasantness around module
boundaries and just makes more sense.
2023-04-11 14:19:45 -07:00
Maciej Szulik
27ad623b3d
Skip vendor directory when removing generated files 2023-03-27 19:07:43 +02:00
Tim Hockin
64ecb161d4
Codegen: git grep returns non-zero if no match 2023-03-05 12:20:15 -08:00
Tim Hockin
241d46d1dd
Codegen: deepcopy needs to run before swagger 2023-03-05 12:20:15 -08:00
Tim Hockin
3405853e6d
Codegen: clean up stray ls-files use 2023-03-05 12:20:14 -08:00
Kubernetes Prow Robot
a1f4fa0b0c
Merge pull request #116141 from thockin/codegen_script_wide_vars
Codegen: set LC_ALL and unset GREP_OPTIONS
2023-02-28 14:54:23 -08:00
Tim Hockin
6a09ba8f52
Codegen: set LC_ALL and unset GREP_OPTIONS
LC_ALL is always wanted and GREP_OPTIONS is never wanted.  The `grep
--color=never` dates back to 2016, an issue with OLD grep on Macs, which
was hard to deal with when this was all Makefile magic.  Now that it's a
script, we can do it simpler.
2023-02-28 10:17:52 -08:00
Tim Hockin
23eaa6e1e4
Fix codegen for older bash 2023-02-27 11:57:46 -08:00
Jordan Liggitt
71174aa2da
Generate proto uncontainerized if host has required protoc version 2023-01-26 18:00:10 -05:00