Commit Graph

2429 Commits

Author SHA1 Message Date
Michal Wozniak
3d68f362c3 Give terminal phase correctly to all pods that will not be restarted 2023-03-16 21:25:29 +01:00
David Porter
6ead3e3945 test: Update standalone test in node e2e
* Slightly changed pod spec to repro issue #116262
* Refactor test to ensure that the static pod is deleted even if the
  test fails

Signed-off-by: David Porter <david@porter.me>
2023-03-15 14:00:39 -07:00
Kubernetes Prow Robot
ad4cbd4c85
Merge pull request #116628 from SergeyKanzhelev/fixStandaloneTest
fix standalone test
2023-03-15 13:47:17 -07:00
Kubernetes Prow Robot
602ba9a714
Merge pull request #116611 from dims/missed-registering-kubelet-config-file-for-make-test-e2e-node-usecase
missed registering kubelet-config-file for the command line use case running test-e2e-node target
2023-03-14 19:27:21 -07:00
Sergey Kanzhelev
ef0485e428 first iteration to add standalone mode 2023-03-15 00:59:55 +00:00
Sergey Kanzhelev
1e6281e4a2 first iteration to add standalone mode 2023-03-14 20:46:41 +00:00
Davanum Srinivas
ee294de56d
missed registering kubelet-config-file for the command line use case running test-e2e-node target
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-03-14 15:46:31 -04:00
Kubernetes Prow Robot
1cb334960c
Merge pull request #116591 from gjkim42/add-service-feature-gates-to-e2e_node
Add service-feature-gates argument to node_e2e
2023-03-14 10:41:17 -07:00
Kubernetes Prow Robot
bab2774b21
Merge pull request #116517 from dims/re-organize-remote-e2e-test-to-be-pluggable
re-organize remote e2e test to be pluggable
2023-03-14 10:41:00 -07:00
Kubernetes Prow Robot
204a9a1f17
Merge pull request #116459 from ffromani/podresources-ratelimit-minimal
add podresources DOS prevention using rate limit
2023-03-14 08:36:45 -07:00
Davanum Srinivas
a1d157bf32
Add some missing flags
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-03-14 10:36:25 -04:00
Gunju Kim
cdf501f77b
Add service-feature-gates argument to node_e2e
This separates the "service-feature-gates" argument from the
"feature-gates" to set feature gates of API service independently.
2023-03-14 22:54:30 +09:00
Davanum Srinivas
a889cc7f79
prevent initializing the same flag more than once
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-03-13 17:07:00 -04:00
Davanum Srinivas
be42dcfd73
re-organize remote e2e test to be pluggable
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
2023-03-13 12:33:47 -04:00
Sergey Kanzhelev
009a2cbbc8 initialize feature gates in test project 2023-03-13 16:16:03 +00:00
Kubernetes Prow Robot
85524e7da6
Merge pull request #116518 from tzneal/refactor-remote-runner
test: refactor remote test running
2023-03-13 05:56:59 -07:00
Kubernetes Prow Robot
185cd95b9c
Merge pull request #113443 from yangjunmyfm192085/namespace-contextual-logging
namespace controller: use contextual logging
2023-03-13 04:34:44 -07:00
JunYang
f5bd8c86d4 namespace controller: use contextual logging 2023-03-13 14:59:17 +08:00
Todd Neal
23f71f0eba refactor remote test running 2023-03-12 21:26:01 -05:00
Francesco Romani
b837a0c1ff kubelet: podresources: DOS prevention with builtin ratelimit
Implement DOS prevention wiring a global rate limit for podresources
API. The goal here is not to introduce a general ratelimiting solution
for the kubelet (we need more research and discussion to get there),
but rather to prevent misuse of the API.

Known limitations:
- the rate limits value (QPS, BurstTokens) are hardcoded to
  "high enough" values.
  Enabling user-configuration would require more discussion
  and sweeping changes to the other kubelet endpoints, so it
  is postponed for now.
- the rate limiting is global. Malicious clients can starve other
  clients consuming the QPS quota.

Add e2e test to exercise the flow, because the wiring itself
is mostly boilerplate and API adaptation.
2023-03-11 08:00:54 +01:00
Sergey Kanzhelev
13855373e5 three more checks for containers lifecycle 2023-03-10 18:42:14 +00:00
Kubernetes Prow Robot
08fbe92fa7
Merge pull request #116423 from ffromani/e2e-podres-node-conformance
e2e: podresources: promote platform-independent test as NodeConformance
2023-03-10 00:06:52 -08:00
Kubernetes Prow Robot
8ce3a2bbef
Merge pull request #116398 from tzneal/rework-init-containers-test
rework init containers test to remove host file dependency
2023-03-09 22:44:25 -08:00
Kubernetes Prow Robot
45b96eae98
Merge pull request #113145 from smarterclayton/zombie_terminating_pods
kubelet: Force deleted pods can fail to move out of terminating
2023-03-09 15:32:30 -08:00
Francesco Romani
5ca235e0ee e2e: podresources: promote platform-independent test as NodeConformance
We have quite a few podresources e2e tests and, as the feature
progresses to GA, we should consider moving them to NodeConformance.
Unfortunately most of them require linux-specific features not in the
test themselves but in the test prelude (fixture) to check or create the
node conditions (e.g. presence or not of devices, online CPUS...) to be
verified in the test proper.

For this reason we promote only a single test for starters.

Signed-off-by: Francesco Romani <fromani@redhat.com>
2023-03-09 16:26:01 +01:00
Todd Neal
78ca93e39c rework init containers test to remove host file dependency
Since we can't rely on the test runner and hosts under test to
be on the same machine, we write to the terminate log from each
container and concatenate the results.
2023-03-08 23:17:17 -06:00
Clayton Coleman
6b9a381185
kubelet: Force deleted pods can fail to move out of terminating
If a CRI error occurs during the terminating phase after a pod is
force deleted (API or static) then the housekeeping loop will not
deliver updates to the pod worker which prevents the pod's state
machine from progressing. The pod will remain in the terminating
phase but no further attempts to terminate or cleanup will occur
until the kubelet is restarted.

The pod worker now maintains a store of the pods state that it is
attempting to reconcile and uses that to resync unknown pods when
SyncKnownPods() is invoked, so that failures in sync methods for
unknown pods no longer hang forever.

The pod worker's store tracks desired updates and the last update
applied on podSyncStatuses. Each goroutine now synchronizes to
acquire the next work item, context, and whether the pod can start.
This synchronization moves the pending update to the stored last
update, which will ensure third parties accessing pod worker state
don't see updates before the pod worker begins synchronizing them.

As a consequence, the update channel becomes a simple notifier
(struct{}) so that SyncKnownPods can coordinate with the pod worker
to create a synthetic pending update for unknown pods (i.e. no one
besides the pod worker has data about those pods). Otherwise the
pending update info would be hidden inside the channel.

In order to properly track pending updates, we have to be very
careful not to mix RunningPods (which are calculated from the
container runtime and are missing all spec info) and config-
sourced pods. Update the pod worker to avoid using ToAPIPod()
and instead require the pod worker to directly use
update.Options.Pod or update.Options.RunningPod for the
correct methods. Add a new SyncTerminatingRuntimePod to prevent
accidental invocations of runtime only pod data.

Finally, fix SyncKnownPods to replay the last valid update for
undesired pods which drives the pod state machine towards
termination, and alter HandlePodCleanups to:

- terminate runtime pods that aren't known to the pod worker
- launch admitted pods that aren't known to the pod worker

Any started pods receive a replay until they reach the finished
state, and then are removed from the pod worker. When a desired
pod is detected as not being in the worker, the usual cause is
that the pod was deleted and recreated with the same UID (almost
always a static pod since API UID reuse is statistically
unlikely). This simplifies the previous restartable pod support.
We are careful to filter for active pods (those not already
terminal or those which have been previously rejected by
admission). We also force a refresh of the runtime cache to
ensure we don't see an older version of the state.

Future changes will allow other components that need to view the
pod worker's actual state (not the desired state the podManager
represents) to retrieve that info from the pod worker.

Several bugs in pod lifecycle have been undetectable at runtime
because the kubelet does not clearly describe the number of pods
in use. To better report, add the following metrics:

  kubelet_desired_pods: Pods the pod manager sees
  kubelet_active_pods: "Admitted" pods that gate new pods
  kubelet_mirror_pods: Mirror pods the kubelet is tracking
  kubelet_working_pods: Breakdown of pods from the last sync in
    each phase, orphaned state, and static or not
  kubelet_restarted_pods_total: A counter for pods that saw a
    CREATE before the previous pod with the same UID was finished
  kubelet_orphaned_runtime_pods_total: A counter for pods detected
    at runtime that were not known to the kubelet. Will be
    populated at Kubelet startup and should never be incremented
    after.

Add a metric check to our e2e tests that verifies the values are
captured correctly during a serial test, and then verify them in
detail in unit tests.

Adds 23 series to the kubelet /metrics endpoint.
2023-03-08 22:03:51 -06:00
Kubernetes Prow Robot
8d5c96fed2
Merge pull request #116093 from swatisehgal/topologymanager-ga-graduation
node: topologymgr: Graduate Kubelet Topology Manager to GA
2023-03-08 16:56:06 -08:00
Kubernetes Prow Robot
8ee9b82b10
Merge pull request #115984 from tzneal/init-container-tests
add more init container testing
2023-03-08 15:42:08 -08:00
Todd Neal
123ab80333 add more init container lifetime testing
Add some additional init container tests that work via monitoring
container lifetime based on logs written to a common file. This allows
more easily writing assertions about the container lifetimes with
respect to one another.
2023-03-08 14:39:10 -06:00
David Porter
9c20cee504
Revert "node: device-mgr: Handle recovery flow by checking if healthy devices exist" 2023-03-07 11:50:52 -08:00
Swati Sehgal
e5ad3cbf6a node: topologymgr: update node e2e test tags
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2023-03-07 09:52:07 +00:00
David Porter
d3214226de test: Fix node e2e shutdown test flake
Bump the timeout as the previous timeout was sometimes too short,
resulting in the pod status update not sent. Also, fixed a typo in
previous refactor.

Signed-off-by: David Porter <david@porter.me>
2023-03-06 15:38:45 -08:00
Swati Sehgal
d536a342b4 node: topologymgr: GA graduation implies Feature Gate is ON by default
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2023-03-06 12:51:05 +00:00
Swati Sehgal
01a9148887 node: device-mgr: e2e: adapt to sample device plugin refactoring
These updates are to adapt to the sample device plugin
refactoring done here: 92e00203e0.

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2023-03-06 12:15:59 +00:00
Swati Sehgal
bae8a164e0 node: device-mgr: e2e: address e2e test review comments
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2023-03-06 12:15:58 +00:00
Swati Sehgal
674879a959 node: device-mgr: e2e: Update the e2e test to reproduce issue:109595
Breakdown of the steps implemented as part of this e2e test is as follows:
1. Create a file `registration` at path `/var/lib/kubelet/device-plugins/sample/`
2. Create sample device plugin with an environment variable with
   `REGISTER_CONTROL_FILE=/var/lib/kubelet/device-plugins/sample/registration` that
    waits for a client to delete the control file.
3. Trigger plugin registeration by deleting the abovementioned directory.
4. Create a test pod requesting devices exposed by the device plugin.
5. Stop kubelet.
6. Remove pods using CRI to ensure new pods are created after kubelet restart.
7. Restart kubelet.
8. Wait for the sample device plugin pod to be running. In this case,
   the registration is not triggered.
9. Ensure that resource capacity/allocatable exported by the device plugin is zero.
10. The test pod should fail with `UnexpectedAdmissionError`
11. Delete the test pod.
12. Delete the sample device plugin pod.
13. Remove `/var/lib/kubelet/device-plugins/sample/` and its content, the directory
    created to control registration

Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2023-03-06 12:15:58 +00:00
Swati Sehgal
db7afc1cd8 node: device-mgr: e2e: Implement End to end test
This commit reuses e2e tests implmented as part of https://github.com/kubernetes/kubernetes/pull/110729.
The commit is borrowed from the aforementioned PR as is to preserve
authorship. Subsequent commit will update the end to end test to
simulate the problem this PR is trying to solve by reproducing
the issue: 109595.

Co-authored-by: Francesco Romani <fromani@redhat.com>
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2023-03-06 11:52:23 +00:00
Kubernetes Prow Robot
20c3a007f5
Merge pull request #115693 from bobbypage/shutdown_test
test: e2e node shutdown test logging improvements
2023-03-03 15:20:57 -08:00
David Porter
c5a1f0188b
test: Add node e2e test to verify static pod termination
Add node e2e test to verify that static pods can be started after a
previous static pod with the same config temporarily failed termination.

The scenario is:

1. Static pod is started
2. Static pod is deleted
3. Static pod termination fails (internally `syncTerminatedPod` fails)
4. At later time, pod termination should succeed
5. New static pod with the same config is (re)-added
6. New static pod is expected to start successfully

To repro this scenario, setup a pod using a NFS mount. The NFS server is
stopped which will result in volumes failing to unmount and
`syncTerminatedPod` to fail. The NFS server is later started, allowing
the volume to unmount successfully.

xref:

1. https://github.com/kubernetes/kubernetes/pull/113145#issuecomment-1289587988
2. https://github.com/kubernetes/kubernetes/pull/113065
3. https://github.com/kubernetes/kubernetes/pull/113093

Signed-off-by: David Porter <david@porter.me>
2023-03-03 10:00:48 -06:00
David Porter
1c75c2cda8
test: Add e2e to verify static pod termination
Add a node e2e to verify that if a static pod is terminated while the
container runtime or CRI returns an error, the pod is eventually
terminated successfully.

This test serves as a regression test for k8s.io/issue/113145 which
fixes an issue where force deleted pods may not be terminated if the
container runtime fails during a `syncTerminatingPod`.

To test this behavior, start a static pod, stop the container runtime,
and later start the container runtime. The static pod is expected to
eventually terminate successfully.

To start and stop the container runtime, we need to find the container
runtime systemd unit name. Introduce a util function
`findContainerRuntimeServiceName` which finds the unit name by getting
the pid of the container runtime from the existing
`ContainerRuntimeProcessName` flag passed into node e2e and using
systemd dbus `GetUnitNameByPID` function to convert the pid of the
container runtime to a unit name. Using the unit name, introduce helper
functions to start and stop the container runtime.

Signed-off-by: David Porter <david@porter.me>
2023-03-03 10:00:48 -06:00
David Porter
8647c23c11 test: Fix path to e2e node sample device plugin
The existing path is incorrect (missing `sample-device-plugin`)
directory and thus causing test failures. The full path should be
`test/e2e/testing-manifests/sample-device-plugin/sample-device-plugin.yaml`.

Signed-off-by: David Porter <david@porter.me>
2023-03-02 19:22:59 -08:00
Kubernetes Prow Robot
78e5db0931
Merge pull request #115107 from swatisehgal/handle-device-mgr-recovery-sample-dp-changes
node: device-mgr: sample device plugin: Add support to control registration process
2023-03-02 05:42:55 -08:00
Kubernetes Prow Robot
59a7e34052
Merge pull request #115442 from bobbypage/unknown_pods_test
test: Add e2e node test to check for unknown pods
2023-03-01 19:08:55 -08:00
Kubernetes Prow Robot
1646ed8222
Merge pull request #116057 from bobbypage/nodee2elog
test: Add log artifact for ginkgo node e2e and tune default ginkgo flags
2023-03-01 16:55:16 -08:00
Swati Sehgal
7ea35d0cd8 node: device-mgr: sample device plugin: manifest to avoid registration
Signed-off-by: Swati Sehgal <swsehgal@redhat.com>
2023-03-01 10:01:34 +00:00
Kubernetes Prow Robot
0469455ff7
Merge pull request #116082 from mimowo/fix-oomkiller-test
Fix the flaky OOMKiller test by sleep at start
2023-02-28 14:53:37 -08:00
David Porter
e001884594 test: Add some default flags ginkgo flags for node e2e
Add the following ginkgo flags for each node e2e similar to the
existing hack/ginkgo-e2e.sh script.

* --no-color, colors aren't rendered properly in prow and make examining
  the log in text editors more difficult, so let's disable them.
  `hack/ginkgo-e2e.sh` (used for kind e2e tests) also disables them
  already.
* -v, enable verbose logs. This is needed so we get more detailed info
  even when the tests pass. This is useful so we can compare successful
  runs to failed runs.

Signed-off-by: David Porter <david@porter.me>
2023-02-28 00:24:40 -08:00
David Porter
e9ecdf3534 test: Emit ginkgo log for each node e2e
When running multiple node e2e with multiple machine images, the tests
are run separately for each node. The final build log has all of the
results for each of the hosts combined together which make debugging the
log difficult. To make it easier, emit a log for each host that was run.
This log will be written to the results directory and uploaded as an
artifact in prow jobs.

Signed-off-by: David Porter <david@porter.me>
2023-02-28 00:21:34 -08:00
David Porter
0980f026c9 test: Remove tests argument from node e2e image config
This was never being used, the only config that used it was deleted in
https://github.com/kubernetes/test-infra/pull/26017 so we don't need
this anymore, so let's delete it.

Signed-off-by: David Porter <david@porter.me>
2023-02-28 00:21:03 -08:00