Commit Graph

439 Commits

Author SHA1 Message Date
Patrick Ohly
961129c5f1 scheduler_perf: add logging flags
This enables testing of different real production configurations (JSON
vs. text, different log levels, contextual logging).
2023-02-28 23:08:17 +01:00
Patrick Ohly
c008732948 test/integration: add StartEtcd
In contrast to EtcdMain, it can be called by individual tests or benchmarks and
each caller will get a fresh etcd instance. However, it uses the same
underlying code and the same port for all instances, so tests cannot run in
parallel.
2023-02-28 23:05:17 +01:00
Kubernetes Prow Robot
70fee660fb
Merge pull request #115854 from kerthcet/cleanup/apiserver-cleanup
Cleanup resources when initializing error in integration
2023-02-24 15:58:05 -08:00
Kante Yin
ad55d0cbc9 Use context instead when cleaning up
Signed-off-by: Kante Yin <kerthcet@gmail.com>
2023-02-17 17:13:35 +08:00
Davanum Srinivas
4ecb4670cc
Remove unnecessary ETCD_UNSUPPORTED_ARCH for arm64
we should only use this env var for `arm`, since `arm64` is fully
supported by etcd folks, let us drop this!

(ex - https://github.com/etcd-io/etcd/releases/tag/v3.5.6)

ppc64le comment should be dropped as well

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-02-16 21:29:13 -05:00
Patrick Ohly
f131cabfa0 test: use go-uber/goleak for strict leak checking
It provides more readable output and has additional APIs for using it inside a
unit test. goleak.IgnoreCurrent is needed to filter out the goroutine that gets
started when importing go.opencensus.io/stats/view.

In order to handle background goroutines that get created on demand and cannot
be stopped (like the one for LogzHealth), a helper function ensures that those
are running before calling goleak.IgnoreCurrent. Keeping those goroutines
running is not a problem and thus not worth the effort of adding new APIs to
stop them.

Other goroutines are genuine leaks for which no fix is available. Those get
suppressed via IgnoreTopFunction, which works as long as that function
is unique enough.

Example output for the leak fixed in https://github.com/kubernetes/kubernetes/pull/115423:

    E0202 09:30:51.641841   74789 etcd.go:205] "EtcdMain goroutine check" err=<
        found unexpected goroutines:
        [Goroutine 4889 in state chan receive, with k8s.io/apimachinery/pkg/watch.(*Broadcaster).loop on top of the stack:
        goroutine 4889 [chan receive]:
        k8s.io/apimachinery/pkg/watch.(*Broadcaster).loop(0xc0076183c0)
        	/nvme/gopath/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/watch/mux.go:268 +0x65
        created by k8s.io/apimachinery/pkg/watch.NewBroadcaster
        	/nvme/gopath/src/k8s.io/kubernetes/vendor/k8s.io/apimachinery/pkg/watch/mux.go:77 +0x116
    >
2023-02-14 12:11:37 +01:00
Davanum Srinivas
1671efe7a8
Do not use a global variable for etcdURL
we are saving this information in an env variable `KUBE_INTEGRATION_ETCD_URL`

So just pick it up from there when needed. Currently when someone uses
framework.RunCustomEtcd directly, the global variable is *not* set and the
code that uses `GetEtcdURL` returns empty string.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-01-22 14:11:26 -05:00
Patrick Ohly
2f6c4f5eab e2e: use Ginkgo context
All code must use the context from Ginkgo when doing API calls or polling for a
change, otherwise the code would not return immediately when the test gets
aborted.
2022-12-16 20:14:04 +01:00
Kubernetes Prow Robot
0e9a2e6bcf
Merge pull request #113669 from wojtek-t/clean_shutdown_final
Clean shutdown final
2022-11-07 16:01:45 -08:00
Kubernetes Prow Robot
7369bd27e0
Merge pull request #113679 from alculquicondor/test-approver
Add alculquicondor to test/integration/framework OWNERS
2022-11-07 12:42:40 -08:00
Aldo Culquicondor
337c515db8
Add alculquicondor to test/integration/framework OWNERS
Change-Id: I60c91252abf985e36ba2296f763dc61792cec4d0
2022-11-07 13:13:50 -05:00
Kubernetes Prow Robot
73f6b96f0a
Merge pull request #113615 from kerthcet/feat/add-benchmark-tests
Add nodeInclusionPolicy benchmark tests to scheduler_perf
2022-11-07 09:18:28 -08:00
Wojciech Tyczyński
1b976760db Improve debuggability of leaking goroutines 2022-11-07 15:04:08 +01:00
kerthcet
20492f5555 Remove GetReadySchedulableNodes in scheduler_perf
When preparing or cleaning up nodes, list all schedulable ones

Signed-off-by: kerthcet <kerthcet@gmail.com>
2022-11-05 00:13:21 +08:00
Wojciech Tyczyński
7253f708a8 Decrease goroutines 2022-11-04 10:34:36 +01:00
Aldo Culquicondor
5e03865f65
Add benchmark for large indexed job
Change-Id: I556f0cce5842699c98654cfb5a66e7c8d63b2e2e
2022-11-02 11:56:26 -04:00
Monis Khan
4e68e9b5ad
kms: fix go routine leak in gRPC connection
Signed-off-by: Monis Khan <mok@microsoft.com>
2022-09-08 11:46:57 -04:00
Anish Ramasekar
f19f3f4099
Implement KMS v2alpha1
- add feature gate
- add encrypted object and run generated_files
- generate protobuf for encrypted object and add unit tests
- move parse endpoint to util and refactor
- refactor interface and remove unused interceptor
- add protobuf generate to update-generated-kms.sh
- add integration tests
- add defaulting for apiVersion in kmsConfiguration
- handle v1/v2 and default in encryption config parsing
- move metrics to own pkg and reuse for v2
- use Marshal and Unmarshal instead of serializer
- add context for all service methods
- check version and keyid for healthz

Signed-off-by: Anish Ramasekar <anish.ramasekar@gmail.com>
2022-08-03 19:04:47 +00:00
Wojciech Tyczyński
ef607d131f Prevent from future leaks of goroutines in integration tests 2022-07-26 20:08:09 +02:00
Wojciech Tyczyński
5b042f0bf4 Remove RunAnAPIServer from integration tests 2022-07-25 17:52:31 +02:00
Wojciech Tyczyński
aca03a4090 Cleanup no longer used Create/Delete TestingNamespace 2022-07-21 19:44:14 +02:00
Wojciech Tyczyński
6b59525746 Clean shutdown of flowcontrol integration tests 2022-06-15 16:53:42 +02:00
Wojciech Tyczyński
c802118e81 Update scheduler tests 2022-05-27 14:57:21 +02:00
Wojciech Tyczyński
6ae4bbbfc2 Add namespace utility test functions 2022-05-26 16:20:56 +02:00
Wojciech Tyczyński
6f706775bc Clean shutdown of test apiserver 2022-05-26 10:42:48 +02:00
Wojciech Tyczyński
deef9e40de Simplify Create/Delete-TestingNamespace functions 2022-05-15 23:06:26 +02:00
Kubernetes Prow Robot
8245695028
Merge pull request #109919 from stevekuznetsov/skuznets/clarify-integration-namespace
test/integration: clarify namespace utilities
2022-05-10 05:17:56 -07:00
Steve Kuznetsov
173c1da99e
test/integration: clarify namespace utilities
For a developer that's not very familiar with the integration flow, it
is very surprising to see that the namespace creation logic does not
create anything and that the namespace deletion logic does not delete
anything, either.

Signed-off-by: Steve Kuznetsov <skuznets@redhat.com>
2022-05-09 09:57:01 -07:00
Antonio Ojea
eba27127db integration: force close httpserver on exit 2022-05-09 16:18:26 +02:00
Kubernetes Prow Robot
edac6fce2a
Merge pull request #109338 from kerthcet/cleanup/forget-to-close-when-error
test/integration/framework: call closeFn() in startAPIServerOrDie() on error
2022-05-03 19:31:22 -07:00
Kubernetes Prow Robot
cc2807c521
Merge pull request #109303 from wojtek-t/clean_storage_shutdown
Cleanup rest storage resources on shutdown
2022-05-03 19:30:57 -07:00
Kubernetes Prow Robot
743238e951
Merge pull request #108048 from aojea/custom_etcd_integration
integration: custom etcd gracefully termination
2022-05-03 17:18:48 -07:00
Wojciech Tyczyński
e95f8f2e42 Clean apiserver shutdown in integration tests 2022-04-19 15:59:13 +02:00
Antonio Ojea
1756fe60d4 integration: custom etcd gracefully termination
when running integration tests without an external etcd, the framework
spawns an etcd instance executing it in its own process and killing
it once the test stops.

Instead of killing it directly, allow etcd to exit gracefully or kill
it after 5 seconds.
2022-04-18 19:09:38 +02:00
kerthcet
fbf07e989c fix: forget to call close() in error
Signed-off-by: kerthcet <kerthcet@gmail.com>
2022-04-06 22:21:23 +08:00
Jefftree
67d3dbfaae Separate OpenAPI V2 and V3 Config 2022-03-29 17:49:56 -07:00
Antonio Ojea
2660ac8a6d integration framework: log number of leaked goroutines 2022-03-01 15:31:13 +01:00
Kubernetes Prow Robot
21c0f6f6ff
Merge pull request #107677 from pohly/scheduler-integration-benchmark
scheduler integration benchmark improvements
2022-02-14 01:23:28 -08:00
Patrick Ohly
e1e84c8e5f scheduler_perf: run with -v=0 by default
This provides a mechanism for overriding the forced increase of the klog
verbosity to 4 when starting the apiserver and uses that for the scheduler_perf
benchmark. Other tests run as before.

A global variable was used because adding an explicit parameter to several
helper functions would have caused a lot of code churn (test ->
integration/util.StartApiserver ->
integration/framework.RunAnAPIServerUsingServer ->
integration/framework.startAPIServerOrDie).
2022-02-11 16:58:33 +01:00
ahrtr
fe95aa614c io/ioutil has already been deprecated in golang 1.16, so replace all ioutil with io and os 2022-02-03 05:32:12 +08:00
Jeffrey Ying
ecb9b620fe
Revert "Populate OpenAPI in all integration tests" 2022-01-26 13:30:03 -05:00
Jefftree
eb8f6fe0f9 Populate OpenAPI in all integration tests 2022-01-25 14:16:31 -08:00
jlsong01
3006aa534b fix flake on TestQuotaLimitService 2022-01-19 21:58:57 +08:00
Antonio Ojea
cd9b22aabc apiserver endpoint reconciler ip families
The apiserver may be configured to generate the Service
kubernetes.default and its endpoints addresses.

This service is single-stack, hence, the endpoints and the ClusterIP
must have the same IP family.
2021-12-13 15:43:41 +01:00
Jiahui Feng
9c05de2f31 prune enum when OpenAPIEnums is disabled. 2021-11-09 13:00:00 -08:00
Patrick Ohly
21d1bcd6b8 initialize logging after flag parsing
It wasn't documented that InitLogs already uses the log flush frequency, so
some commands have called it before parsing (for example, kubectl in the
original code for logs.go). The flag never had an effect in such commands.

Fixing this turned into a major refactoring of how commands set up flags and
run their Cobra command:

- component-base/logs: implicitely registering flags during package init is an
  anti-pattern that makes it impossible to use the package in commands which
  want full control over their command line. Logging flags must be added
  explicitly now, something that the new cli.Run does automatically.

- component-base/logs: AddFlags would have crashed in kubectl-convert if it
  had been called because it relied on the global pflag.CommandLine. This
  has been fixed and kubectl-convert now has the same --log-flush-frequency
  flag as other commands.

- component-base/logs/testinit: an exception are tests where flag.CommandLine has
  to be used. This new package can be imported to add flags to that
  once per test program.

- Normalization of the klog command line flags was inconsistent. Some commands
  unintentionally didn't normalize to the recommended format with hyphens. This
  gets fixed for sample programs, but not for production programs because
  it would be a breaking change.

This refactoring has the following user-visible effects:

- The validation error for `go run ./cmd/kube-apiserver --logging-format=json
  --add-dir-header` now references `add-dir-header` instead of `add_dir_header`.

- `staging/src/k8s.io/cloud-provider/sample` uses flags with hyphen instead of
  underscore.

- `--log-flush-frequency` is not listed anymore in the --logging-format flag's
  `non-default formats don't honor these flags` usage text because it will also
  work for non-default formats once it is needed.

- `cmd/kubelet`: the description of `--logging-format` uses hyphens instead of
  underscores for the flags, which now matches what the command is using.

- `staging/src/k8s.io/component-base/logs/example/cmd`: added logging flags.

- `apiextensions-apiserver` no longer prints a useless stack trace for `main`
  when command line parsing raises an error.
2021-09-30 13:46:49 +02:00
Kubernetes Prow Robot
86d23cf441
Merge pull request #105206 from pohly/test-integration-help
test/integration: skip etcd startup for -help flag
2021-09-24 10:29:23 -07:00
Patrick Ohly
81b4a695b3 test/integration: skip etcd startup for -help flag
By parsing flags in the test's main function before starting etcd we bail out
early without ever starting etcd when the test was invoked with -help.

Otherwise etcd must be available, gets started and then hangs because
flag.Parse itself exits when called by testing.go. This bypasses the code in
EtcdMain which normally stops etcd.
2021-09-24 11:51:58 +02:00
Kubernetes Prow Robot
686379281d
Merge pull request #97665 from heqg/unused-function-NewSingleContentTypeSerializer
remove unused function of NewSingleContentTypeSerializer
2021-09-21 22:16:00 -07:00
Abu Kashem
d99497ef6d
apf: update e2e test to use v1beta2 2021-09-09 08:28:58 -04:00