Commit Graph

4386 Commits

Author SHA1 Message Date
Lubomir I. Ivanov
c29450eb00 kubeadm: apply retries to all API calls in idempotency.go
The idempotency.go (perhaps not so accurately named) contains
API calls that kubeadm does against an API server using client-go.

Some users seem to have unstable setups where for unknown reasons
the API server can be unavailable or refuse to respond as expected.

Use PollUntilContextTimeout in all exported functions to ensure
such API calls are all retry-able.

NOTE: The context passed to PollUntilContextTimeout is not propagated
in the polled function. Instead the poll function creates it's own
context 'ctx := context.Background()', this is to avoid
breaking expectations on the side of the callers, that expect
a certain type of error and not "context timeout" errors.

Additional changes:
- Make all context.TODO() -> context.Background()
- Update all unit tests and make sure during testing the retry
interval and timeout are short. Test coverage of idempotency.go
is at ~97%.
- Remove the TestMutateConfigMapWithConflict test. It does not
contribute much, because conflict handling is done at the API,
server side, not on the side of kubeadm. This simulating this is not
needed.
2024-02-18 13:14:32 +02:00
Jordan Liggitt
4ae2b3f75f Revert "kubeadm: increase ut coverage for app/util"
This reverts commit 36904475db.
2024-02-12 20:13:30 -05:00
xin.li
36904475db kubeadm: increase ut coverage for app/util
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-02-09 16:24:54 +08:00
Kubernetes Prow Robot
e7d84c9f08 Merge pull request #123171 from vrutkovs/kubeadm-issue3014
kubeadm: use current-context when validating kubelet kubeconfig
2024-02-07 09:04:06 -08:00
bzsuni
658e3308f3 etcd: Update to version 3.5.12
Signed-off-by: bzsuni <bingzhe.sun@daocloud.io>
2024-02-07 21:16:08 +08:00
Vadim Rutkovsky
fc610f0941 kubeadm: use current-context when validating kubelet kubeconfig
During initialization `kubeadm init` creates kubelet.conf with
specified name and during finalize phase validates that
this kubeconfig is not corrupted by checking for presence of specific
authinfo

However:
* kubelet doesn't require a specific name for this context
* in external CA mode this kubeconfig can be created outside of
  `kubeadm init`

This change updates kubeadm finalize stage to avoid overly strict
context check.
2024-02-07 14:14:13 +01:00
Kubernetes Prow Robot
dd301d0f23 Merge pull request #123118 from my-git9/idempotency-ut
kubeadm: increase ut coverage for apiclient/idempotency
2024-02-05 14:08:26 -08:00
Kubernetes Prow Robot
8cbe59308c Merge pull request #122786 from HirazawaUi/remove-kubeadm-useless-code
kubeadm: remove code to be removed in 1.30
2024-02-05 07:21:29 -08:00
xin.li
deec79ad8d kubeadm: increase ut coverage for apiclient/idempotency
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-02-05 23:02:48 +08:00
Kubernetes Prow Robot
4a4f5dbc07 Merge pull request #123093 from SataQiu/revert-115575-fix-20230207
Revert "kubeadm: fix a bug where the uploaded kubelet configuration in kube-system/kubelet-config ConfigMap does not respect user patch"
2024-02-02 12:47:32 -08:00
Kubernetes Prow Robot
173cf18920 Merge pull request #123077 from neolit123/1.30-fix-upgrade-node-root-fs
kubeadm: better checks if the node is CP during "upgrade node"
2024-02-02 08:40:11 -08:00
Lubomir I. Ivanov
774d666d1c kubeadm: better checks if the node is CP during "upgrade node"
Currently --rootfs does not work with "upgrade node" for CP nodes
because the only check of CP nodes is performed in newNodeOptions()
which runs before the root kubeadm command is run, thus the chroot()
path coming from --rootfs is not applied yet.

To work around that call the "isControlPlaneNode" check when
constructing the command data on command runtime.
2024-02-02 15:00:20 +02:00
Shida Qiu
f47c2a1ba6 Revert "kubeadm: fix a bug where the uploaded kubelet configuration in kube-system/kubelet-config ConfigMap does not respect user patch" 2024-02-02 20:34:30 +08:00
Kubernetes Prow Robot
2372837838 Merge pull request #123054 from neolit123/1.30-v1beta4-encryption-enhance
kubeadm: enhance encryption algorithm support in v1beta4
2024-02-02 01:11:09 -08:00
Markus Rudy
065066d1ab kubeadm: support digests in DeployedDNSAddon()
kubeadm upgrade checks the migration path for the existing CoreDNS
deployment pre-flight. Migration paths are defined for CoreDNS
versions, which are derived from the image tag used in the existing
deployment.

The kubeadm ClusterConfiguration.DNS.ImageMeta supports suffixing the
tag with a digest, but at upgrade time does not derive the version
correctly from an image with digest suffix, because DeployedDNSAddon
does not deal with digests correctly. This commit makes DeployedDNSAddon
digest-aware.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
2024-02-01 10:04:15 +01:00
Lubomir I. Ivanov
2cab79710d kubeadm: enhance encryption algorithm support in v1beta4
Previous v1beta4 work added support for
ClusterConfiguration.EncryptionAlgorithm, however the possible
values were limited to just "RSA" (2048 key size) and "ECDSA" (P256).

Allow more arbitrary algorithm types, that can also include key size
or curve type encoded in the name:
"RSA-2048" (default), "RSA-3072", "RSA-4096" or "ECDSA-P256".

Update the deprecation notice of the PublicKeysECDSA FeatureGate
as ideally it should be removed only after v1beta3 is removed.
2024-01-31 23:49:21 +02:00
Kubernetes Prow Robot
918f7c28af Merge pull request #122875 from my-git9/readwriterut
kubeadm: increase ut coverage certs/renewal/readwriter
2024-01-29 06:49:35 -08:00
xin.li
d7c1a61e04 kubeadm: increase ut coverage certs/renewal/readwriter
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-01-29 19:52:59 +08:00
Paco Xu
8bc63027d9 remove extra space in log 2024-01-29 16:34:44 +08:00
Kubernetes Prow Robot
7340ce932b Merge pull request #122978 from SataQiu/fix-20240126
kubeadm: fix the error check bug in certlist test
2024-01-26 10:10:00 +01:00
Kubernetes Prow Robot
e327eb3295 Merge pull request #122901 from pacoxu/fix-kubeadm-existing-crb-2
kubeadm: don't fail post upgrade for already existing error
2024-01-26 04:25:40 +01:00
SataQiu
5ab9f3d15f kubeadm: fix the err check bug in certlist test 2024-01-26 11:01:03 +08:00
Kubernetes Prow Robot
c156f4c4b4 Merge pull request #122616 from neolit123/1.30-v1beta4-image-pull-serial
kubeadm: add support for parallel image pulls in v1beta4
2024-01-25 16:01:38 +01:00
HirazawaUi
6e5e1d0317 Remove useless org mutate code 2024-01-25 21:49:14 +08:00
Paco Xu
ec1516b45d kubeadm: don't fail post upgrade in EnsureAdminClusterRoleBindingImpl if the error is crb already exists 2024-01-25 18:15:29 +08:00
Dan Winship
b46455ddfe Fix to previous EnsureAdminClusterRoleBindingImpl fix
The previous fix changed the behavior of
EnsureAdminClusterRoleBindingImpl under the assumption that the unit
test was correct and the real-world behavior was wrong, but in fact,
the real-world behavior was already correct, and the unit test was
expecting the wrong result because of the difference in behavior
between real and fake clients.
2024-01-22 08:23:41 -05:00
Dan Winship
b18caee5df Fix EnsureAdminClusterRoleBindingImpl error handling
The code assumed Create() returned nil on error, but that's only true
for the fake clients in unit tests.
2024-01-21 10:53:52 -05:00
Lubomir I. Ivanov
0ba903fd57 kubeadm: enable parallel pulls of images
- Update the logic in checks.go to separate serial and parallel image
pulls.
- Add a new CRI function PullImagesInParallel() with a private
implementation.
- Unit test the private implementation.
- Update other unit tests in checks_test.go.
2024-01-19 14:26:21 +02:00
Lubomir I. Ivanov
510df7eab1 kubeadm: add validation of ImagePullPolicy in the API
The validation is currently performed on runtime during the
ImagePull preflight check. Given this is an API add the validation
under apis/kubeadm.
2024-01-19 14:26:21 +02:00
Lubomir I. Ivanov
754ffa3477 kubeadm: add ImagePullSerial field to v1beta4 NodeRegistationOptions
ImagePullSerial specifies if image pulling performed
by kubeadm must be done serially or in parallel.
Default: true
2024-01-19 14:26:20 +02:00
Kubernetes Prow Robot
e9756693d0 Merge pull request #122850 from neolit123/1.30-v1beta4-timeouts
kubeadm: use separate context in GetConfigMapWithShortRetry
2024-01-19 03:28:14 +01:00
Lubomir I. Ivanov
2cdd9a7130 kubeadm: use separate context in GetConfigMapWithShortRetry
Intentionally pass a new context to this API call.
This will let the API call run independently of the parent
context timeout, which is quite short and can cause the API
call to return abruptly.
2024-01-19 00:19:07 +02:00
Kubernetes Prow Robot
8835dabc3b Merge pull request #122841 from neolit123/1.30-v1beta4-timeouts
kubeadm: special case context errors in GetConfigMapWithShortRetry
2024-01-18 15:57:24 +01:00
Lubomir I. Ivanov
26a79e4c0b kubeadm: special case context errors in GetConfigMapWithShortRetry
If some code is about to go over the context deadline,
"x/time/rate/rate.go" would return and untyped error with the string
"would exceed context deadline". If some code already exceeded
the deadline the error would be of type DeadlineExceeded.
Ignore such context errors and only store API and connectivity errors.
2024-01-18 15:35:25 +02:00
Kubernetes Prow Robot
05780d58bf Merge pull request #122788 from my-git9/renewal-manager
kubeadm: increase ut coverage for certs/renewal/manager
2024-01-17 17:20:03 +01:00
xin.li
6451fb0fe2 kubeadm: increase ut coverage for certs/renewal/manager
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-01-17 21:51:24 +08:00
Kubernetes Prow Robot
a4a56701b5 Merge pull request #122811 from neolit123/1.30-v1beta4-timeouts
kubeadm: keep a function with short timeout in idempotency.go
2024-01-17 04:37:11 +01:00
Kubernetes Prow Robot
d399535b01 Merge pull request #122762 from yxxhero/check-initData-and-joinData-safely
Fix type assertion error in init and join commands for kubeadm
2024-01-17 04:37:05 +01:00
yxxhero
d21fc96db3 Fix type assertion error in init and join commands for kubeadm
Signed-off-by: yxxhero <aiopsclub@163.com>
2024-01-17 07:50:29 +08:00
Lubomir I. Ivanov
54a6e6a772 kubeadm: keep a function with short timeout in idempotency.go
- Name the function GetConfigMapWithShortRetry to be
easier to understand that the function is with a very short timeout.
Add note that this function should be used in cases there is a
fallback to local config.
- Apply custom hardcoded interval of 50ms and timeout of 350ms to it.
Previously the fucntion used exp backoff with 5 steps up to ~340ms.
2024-01-16 17:53:21 +02:00
Kubernetes Prow Robot
8ba29970e6 Merge pull request #122529 from neolit123/1.30-v1beta4-timeouts
kubeadm: add a Timeouts struct to v1beta4
2024-01-15 19:33:58 +01:00
HirazawaUi
46c4249e3e Remove code to be removed in 1.30 2024-01-15 19:40:04 +08:00
Lubomir I. Ivanov
5f876b9d0a kubeadm: switch from ExponentialBackoff() to PollUntilContextTimeout()
Switch to PollUntilContextTimeout() everywhere to allow
usage of the exposed timeouts in the kubeadm API. Exponential backoff
options are more difficult to expose in this regard and a bit too
detailed for the common user - i.e. have "steps", "factor" and so on.
2024-01-14 15:07:56 +02:00
Lubomir I. Ivanov
caf5311413 kubeadm: start using the Timeouts struct values
Propagate usage of the Timeout struct values.
Apply sanitazation to timeout constants in contants.go.
2024-01-14 15:07:56 +02:00
Lubomir I. Ivanov
374e41cf66 kubeadm: replace deprecated wait.Poll() and wait.PollImmediate()
Replace the usage of the deprecated wait.Poll() and
wait.PollImmediate() functions with wait.PollUntilContextTimeout().
Since we don't have piping of context around kubeadm,
use context.Background() everywhere.

Some wait.Poll() functions were converted to "immediate" as there
is no point for them to not be. This is done for consistency.

Replace the only instance of wait.JitterUntil with
wait.PollUntilContextTimeout. JitterUntil is not deprecated
but this is also done for consistency.
2024-01-14 15:07:55 +02:00
Mario Valderrama
dcdfd71450 Fix kubeadm init regression
Don't create admin rolebindings when --kubeconfig is set to a
non-default value.

Fixes: https://github.com/kubernetes/kubeadm/issues/2992

Signed-off-by: Mario Valderrama <mario.valderrama@ionos.com>
2024-01-12 16:58:40 +01:00
Kubernetes Prow Robot
331e5561ab Merge pull request #122642 from my-git9/componentconfigs-ut-q
kubeadm: increase ut coverage app/componentconfigs
2024-01-10 02:47:06 +01:00
xin.li
1a69fd4cb0 kubeadm: increase ut coverage app/componentconfigs
Signed-off-by: xin.li <xin.li@daocloud.io>
2024-01-09 21:52:11 +08:00
Kubernetes Prow Robot
18608cc56b Merge pull request #122619 from neolit123/1.30-v1beta4-control-reset-unmount
kubeadm: skip unmount on missing /var/lib/kubelet
2024-01-08 08:47:41 +01:00
Lubomir I. Ivanov
073cfdfac9 kubeadm: skip unmount on missing /var/lib/kubelet
If the user deletes the /var/lib/kubelet manually, "reset" will throw
an error that the dir is missing. Instead of handling this error,
print it as a warning and skip unmount of directories inside it.

This allows "reset" to continue to be reentrant and can be called
even even if "init/join" are not called yet and some of the
k8s directories on a node do not exist.

Continue to error on individual unmount errors.

Remove the function absoluteKubeletRunDirectory() and
call filepath.EvalSymlinks() directly.
2024-01-08 08:40:32 +02:00