-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
static-pods: write manifest to tempfile before persisting it #1409
static-pods: write manifest to tempfile before persisting it #1409
Conversation
One thing to note, kubelet is emitting error logs for static pods created after the node becomes
This has no impact on the static-pods themselves. They are just not visible via the
This happens for images before this fix as well. But I do not remember seeing this error when I was testing the static-pods feature for the 1.0.6 release. The weird thing is, static-pods created via user-data are fine; kubelet is able to create a mirror pod for them without problem. This and the fact that the logs say |
4645ccb
to
eb41bc5
Compare
Push above addresses @tjkirch 's comments. Tested the changes, results are the same as described in the PR testing description. |
// Create the pod manifest file as a temporary file first and finish writing to it | ||
// before swapping any files out | ||
let mut temp_manifest_file = NamedTempFile::new_in(dir).context(error::CreateTempfile)?; | ||
temp_manifest_file | ||
.write(manifest) | ||
.context(error::ManifestWrite { name })?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes the case where a manifest exists that kubelet is watching, but it seems like it has the same potential problem for a newly created manifest: kubelet could try to load it before we've written any content, or before we've finished writing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It loads any file in that directory regardless of name? I was assuming it'd look for at least some kind of pattern. If that's the case, we could put the temp file in a parent directory, or a new temp directory we create next to the target directory..?
eb41bc5
to
c9793f4
Compare
Push above addresses @bcressey 's comment. Tested with the same steps in the PR description, and things work as expected. |
When writing static pod manifest, create them as temporary files and finish writing to them before persisting them in the destination file path.
c9793f4
to
bf996cb
Compare
Push above addresses #1409 (comment) Tested things and they work as described in the PR description still. The temporary directory gets cleaned-up correctly when it goes out of scope. |
Issue number:
Fixes #1396
Description of changes:
Testing done:
Built aws-k8s-1.19 image and launched 4 instances
For each instance I was able to set 3 static pods repeatedly like so:
Then
sudo sheltie
d to check kubelet logs. I no longer see any error logs pertaining to empty config files. All static pods gets created successfully and runs on the node. I repeated the for loop a few more times to make sure.Note that the three static pods I created uses a generic manifest for nginx pods, that's why the image is
docker.io/library/nginx:1.14.2
I also tried launching instances with static pods specified in the userdata, those pods also get created successfully.
Terms of contribution:
By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.