Skip to content

Commit

Permalink
fixed containerd service folder name (#156)
Browse files Browse the repository at this point in the history
Signed-off-by: Piyush Kumar <[email protected]>
  • Loading branch information
kpiyush17 authored Oct 10, 2024
1 parent 7c415f6 commit a3df964
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/kairos-io/kairos/provider-kubeadm
go 1.23.1

require (
github.com/coreos/go-systemd/v22 v22.5.0
github.com/kairos-io/kairos-sdk v0.5.0
github.com/mudler/go-pluggable v0.0.0-20230126220627-7710299a0ae5
github.com/mudler/yip v1.10.0
Expand Down Expand Up @@ -30,6 +31,7 @@ require (
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/godbus/dbus/v5 v5.0.6 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnht
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs=
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
Expand Down Expand Up @@ -149,6 +151,8 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe
github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI=
github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8=
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/godbus/dbus/v5 v5.0.6 h1:mkgN1ofwASrYnJ5W6U/BxG15eXXXjirgZc7CLqkcaro=
github.com/godbus/dbus/v5 v5.0.6/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
Expand Down
26 changes: 25 additions & 1 deletion stages/proxy.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package stages

import (
"context"
"fmt"
"path/filepath"
"strings"

"github.com/coreos/go-systemd/v22/dbus"
"github.com/kairos-io/kairos-sdk/clusterplugin"
"github.com/kairos-io/kairos/provider-kubeadm/domain"
"github.com/kairos-io/kairos/provider-kubeadm/utils"
Expand All @@ -26,7 +28,7 @@ func GetPreKubeadmProxyStage(kubeadmConfig domain.KubeadmConfig, cluster cluster
Content: kubeletProxyEnv(kubeadmConfig.ClusterConfiguration, cluster.Env),
},
{
Path: filepath.Join("/etc/systemd/system/containerd.service.d", "http-proxy.conf"),
Path: filepath.Join(fmt.Sprintf("/etc/systemd/system/%s.service.d", getContainerdServiceFolderName()), "http-proxy.conf"),
Permissions: 0400,
Content: containerdProxyEnv(kubeadmConfig.ClusterConfiguration, cluster.Env),
},
Expand Down Expand Up @@ -85,3 +87,25 @@ func containerdProxyEnv(clusterCfg kubeadmapiv3.ClusterConfiguration, proxyMap m
}
return strings.Join(proxy, "\n")
}

func getContainerdServiceFolderName() string {
ctx := context.Background()
systemdConnection, err := dbus.NewSystemConnectionContext(ctx)
if err != nil {
panic(err)
}

defer systemdConnection.Close()

status, err := systemdConnection.ListUnitsByNamesContext(ctx, []string{"spectro-containerd.service"})
if err != nil {
panic(err)
}

for _, s := range status {
if s.LoadState == "loaded" {
return "spectro-containerd"
}
}
return "containerd"
}

0 comments on commit a3df964

Please sign in to comment.