@@ -25,6 +25,8 @@ import (
2525	"github.com/spinkube/runtime-class-manager/internal/preset" 
2626)
2727
28+ const  defaultContainerdConfigLocation  =  "/etc/containerd/config.toml" 
29+ 
2830var  containerdConfigLocations  =  map [string ]preset.Settings {
2931	// Microk8s 
3032	"/var/snap/microk8s/current/args/containerd-template.toml" : preset .MicroK8s ,
@@ -34,8 +36,6 @@ var containerdConfigLocations = map[string]preset.Settings{
3436	"/var/lib/rancher/k3s/agent/etc/containerd/config.toml" : preset .K3s ,
3537	// K0s 
3638	"/etc/k0s/containerd.toml" : preset .K0s ,
37- 	// default 
38- 	"/etc/containerd/config.toml" : preset .Default ,
3939}
4040
4141func  DetectDistro (config  Config , hostFs  afero.Fs ) (preset.Settings , error ) {
@@ -50,6 +50,8 @@ func DetectDistro(config Config, hostFs afero.Fs) (preset.Settings, error) {
5050
5151	var  errs  []error 
5252
53+ 	// Check for distro-specific containerd config locations first. 
54+ 	// We do this because the default config may *also* exist in some scenarios. 
5355	for  loc , distro  :=  range  containerdConfigLocations  {
5456		_ , err  :=  hostFs .Stat (loc )
5557		if  err  ==  nil  {
@@ -59,5 +61,12 @@ func DetectDistro(config Config, hostFs afero.Fs) (preset.Settings, error) {
5961		errs  =  append (errs , err )
6062	}
6163
64+ 	// Check the default location last, assuming no distro-specific location has been detected. 
65+ 	_ , err  :=  hostFs .Stat (defaultContainerdConfigLocation )
66+ 	if  err  ==  nil  {
67+ 		return  preset .Default , nil 
68+ 	}
69+ 	errs  =  append (errs , err )
70+ 
6271	return  preset.Settings {}, fmt .Errorf ("failed to detect containerd config path: %w" , errors .Join (errs ... ))
6372}
0 commit comments