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
Bug 1963730: writes the dynamic certs atomically #1103
Bug 1963730: writes the dynamic certs atomically #1103
Conversation
|
@p0lyn0mial: This pull request references Bugzilla bug 1963730, which is invalid:
Comment In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
8e3e42c
to
6fe78a9
Compare
|
/assign @sttts |
|
@p0lyn0mial: This pull request references Bugzilla bug 1963730, which is invalid:
Comment In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
6fe78a9
to
b84bc2e
Compare
pkg/operator/staticpod/file_utils.go
Outdated
| } | ||
|
|
||
| func writeTemporaryFile(content []byte, filePerms os.FileMode, contentDir, filename string) (string, error) { | ||
| klog.Infof("Creating a temporary file for %q ...", path.Join(contentDir, filename)) |
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.
do we really need all this logging? Would streamline the func WriteFileAtomic to not output anything.
| @@ -408,3 +398,29 @@ func (o *InstallOptions) Run(ctx context.Context) error { | |||
| recorder.Eventf("StaticPodInstallerCompleted", "Successfully installed revision %s", o.Revision) | |||
| return nil | |||
| } | |||
|
|
|||
| func writeConfig(content []byte, atomic bool, contentDir, filename string) error { | |||
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.
why do we need atomic bool?
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.
because not all files need to be written in that way. The other files are written to a per revision directory, like
| if err := o.copySecretsAndConfigMaps(ctx, resourceDir, secretPrefixes, optionalSecretPrefixes, configPrefixes, optionalConfigPrefixes, true, false); err != nil { |
we could use prefixed arg but that would be a little less explicit.
|
/hold until proof PRs are green |
3af072d
to
43d70e5
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: p0lyn0mial, sttts The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold cancel |
|
/bugzilla refresh |
|
@p0lyn0mial: This pull request references Bugzilla bug 1963730, which is valid. The bug has been updated to refer to the pull request using the external bug tracker. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
@p0lyn0mial: Some pull requests linked via external trackers have merged: The following pull requests linked via external trackers have not merged: These pull request must merge or be unlinked from the Bugzilla bug in order for it to move to the next state. Once unlinked, request a bug refresh with Bugzilla bug 1963730 has not been moved to the MODIFIED state. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
As of today, the dynamic certificates i.e.
kube-apiserver-certsare accessed by at least two processes, namely the installer pod and the cert-syncer.Up until now, there was no coordination between these processes that might have lead to many unexpected errors, like https://bugzilla.redhat.com/show_bug.cgi?id=1963730
This PR writes all certificates in an atomic way by first creating a temporary file, writing the content to it, and then renaming it to the original file.
os.Renamecallssyscall.Renamewhich in turn uses the rename syscall (Linux) which provides atomicity (https://man7.org/linux/man-pages/man2/rename.2.html)The previous attempt didn't work as it would break the DR scripts - #1098