Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
bf97b8fa
Commit
bf97b8fa
authored
Feb 06, 2025
by
Brad Davidson
Committed by
Brad Davidson
Feb 07, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix containerd hosts.toml path on windows
Signed-off-by:
Brad Davidson
<
brad.davidson@rancher.com
>
parent
838d6877
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
2 deletions
+20
-2
config.go
pkg/agent/containerd/config.go
+1
-1
config_linux.go
pkg/agent/containerd/config_linux.go
+6
-0
config_test.go
pkg/agent/containerd/config_test.go
+1
-1
config_windows.go
pkg/agent/containerd/config_windows.go
+12
-0
No files found.
pkg/agent/containerd/config.go
View file @
bf97b8fa
...
@@ -53,7 +53,7 @@ func writeContainerdHosts(cfg *config.Node, containerdConfig templates.Container
...
@@ -53,7 +53,7 @@ func writeContainerdHosts(cfg *config.Node, containerdConfig templates.Container
// Write out new templates
// Write out new templates
for
host
,
config
:=
range
hosts
{
for
host
,
config
:=
range
hosts
{
hostDir
:=
filepath
.
Join
(
cfg
.
Containerd
.
Registry
,
host
)
hostDir
:=
filepath
.
Join
(
cfg
.
Containerd
.
Registry
,
host
Directory
(
host
)
)
hostsFile
:=
filepath
.
Join
(
hostDir
,
"hosts.toml"
)
hostsFile
:=
filepath
.
Join
(
hostDir
,
"hosts.toml"
)
hostsTemplate
,
err
:=
templates
.
ParseHostsTemplateFromConfig
(
templates
.
HostsTomlTemplate
,
config
)
hostsTemplate
,
err
:=
templates
.
ParseHostsTemplateFromConfig
(
templates
.
HostsTomlTemplate
,
config
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
pkg/agent/containerd/config_linux.go
View file @
bf97b8fa
...
@@ -27,6 +27,12 @@ const (
...
@@ -27,6 +27,12 @@ const (
runtimesPath
=
"/usr/local/nvidia/toolkit:/opt/kwasm/bin"
runtimesPath
=
"/usr/local/nvidia/toolkit:/opt/kwasm/bin"
)
)
// hostDirectory returns the name of the host dir for a given registry.
// This is a no-op on linux, as all possible host:port strings are valid paths.
func
hostDirectory
(
host
string
)
string
{
return
host
}
func
getContainerdArgs
(
cfg
*
config
.
Node
)
[]
string
{
func
getContainerdArgs
(
cfg
*
config
.
Node
)
[]
string
{
args
:=
[]
string
{
args
:=
[]
string
{
"containerd"
,
"containerd"
,
...
...
pkg/agent/containerd/config_test.go
View file @
bf97b8fa
...
@@ -1500,7 +1500,7 @@ func Test_UnitGetHostConfigs(t *testing.T) {
...
@@ -1500,7 +1500,7 @@ func Test_UnitGetHostConfigs(t *testing.T) {
for
host
,
config
:=
range
got
{
for
host
,
config
:=
range
got
{
hostsTemplate
,
err
:=
templates
.
ParseHostsTemplateFromConfig
(
templates
.
HostsTomlTemplate
,
config
)
hostsTemplate
,
err
:=
templates
.
ParseHostsTemplateFromConfig
(
templates
.
HostsTomlTemplate
,
config
)
assert
.
NoError
(
t
,
err
,
"ParseHostTemplateFromConfig for %s"
,
host
)
assert
.
NoError
(
t
,
err
,
"ParseHostTemplateFromConfig for %s"
,
host
)
t
.
Logf
(
"%s/hosts.d/%s/hosts.toml
\n
%s"
,
tempDir
,
host
,
hostsTemplate
)
t
.
Logf
(
"%s/hosts.d/%s/hosts.toml
\n
%s"
,
tempDir
,
host
Directory
(
host
)
,
hostsTemplate
)
}
}
// Confirm that the main containerd config.toml renders properly
// Confirm that the main containerd config.toml renders properly
...
...
pkg/agent/containerd/config_windows.go
View file @
bf97b8fa
...
@@ -4,6 +4,8 @@
...
@@ -4,6 +4,8 @@
package
containerd
package
containerd
import
(
import
(
"net"
"github.com/containerd/containerd"
"github.com/containerd/containerd"
"github.com/k3s-io/k3s/pkg/agent/templates"
"github.com/k3s-io/k3s/pkg/agent/templates"
"github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/k3s-io/k3s/pkg/daemons/config"
...
@@ -13,6 +15,16 @@ import (
...
@@ -13,6 +15,16 @@ import (
"k8s.io/cri-client/pkg/util"
"k8s.io/cri-client/pkg/util"
)
)
// hostDirectory returns the name of the host dir for a given registry.
// Colons are not allowed in windows paths, so convert `:port` to `_port_`.
// Ref: https://github.com/containerd/containerd/blob/v1.7.25/remotes/docker/config/hosts.go#L291-L298
func
hostDirectory
(
host
string
)
string
{
if
host
,
port
,
err
:=
net
.
SplitHostPort
(
host
);
err
==
nil
&&
port
!=
""
{
return
host
+
"_"
+
port
+
"_"
}
return
host
}
func
getContainerdArgs
(
cfg
*
config
.
Node
)
[]
string
{
func
getContainerdArgs
(
cfg
*
config
.
Node
)
[]
string
{
args
:=
[]
string
{
args
:=
[]
string
{
"containerd"
,
"containerd"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment