Skip to content
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

Custom agent/etc/containerd/certs.d/* files are deleted by k3s on startup #10787

Closed
skirsten opened this issue Aug 30, 2024 · 2 comments
Closed
Assignees

Comments

@skirsten
Copy link
Contributor

skirsten commented Aug 30, 2024

Environmental Info:
k3s version v1.30.4+k3s1 (98262b5)
go version go1.22.5

Node(s) CPU architecture, OS, and Version:
doesn't matter

Cluster Configuration:
doesn't matter

Describe the bug:
During generation of the containerd hosts config, the agent/etc/containerd/certs.d directory is completely deleted.
This happens here:

os.RemoveAll(cfg.Containerd.Registry)

Steps To Reproduce:

  • put your own files into the agent/etc/containerd/certs.d folder
  • (optional) use k3s like this for a long time, upgrade k3s
  • start k3s
  • spend hours debugging stuff
  • figure out the files are deleted
  • be sad

Expected behavior:
I should be able to provide my own configs because I need full control over capabilities etc.

Actual behavior:
My own configs are deleted.

Additional context / logs:
At first glance I was thinking "why is there a os.RemoveAll in the code" but I can understand why this was implemented like this.
The writeContainerdHosts function needs to support deleting outdated files from previous configurations.

So my idea how to fix this would be instead of deleting all files, list all files and check if they start with # File generated by k3s. DO NOT EDIT.. And only delete them if they do.

What do you think?

Also, unfortunately its not possible to supply multiple config_path because then containerd won't start.

@brandond
Copy link
Contributor

That does sound like a good potential solution. I think there might be some corner cases to work around, where we may drop certificates into that directory, but not create a hosts.toml - but that could probably be addressed by ensuring that we create a stub hosts.toml even if only placing certificates.

@fmoral2
Copy link
Contributor

fmoral2 commented Sep 11, 2024

#10838 (comment)

@fmoral2 fmoral2 closed this as completed Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done Issue
Development

No branches or pull requests

3 participants