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

vm: temporary workaround for #764 #823

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ func init() {
// dns
startCmd.Flags().IPSliceVarP(&startCmdArgs.Network.DNSResolvers, "dns", "n", nil, "DNS resolvers for the VM")
startCmd.Flags().StringSliceVar(&startCmdArgs.Flags.DNSHosts, "dns-host", nil, "custom DNS names to provide to resolver")

// cgroups v2 workaround
startCmd.Flags().BoolVar(&startCmdArgs.TempCgroupsV2, "cgroups-v2", false, "cgroups v2 workaround for docker-compose")
}

func dnsHostsFromFlag(hosts []string) map[string]string {
Expand Down Expand Up @@ -400,6 +403,10 @@ func prepareConfig(cmd *cobra.Command) {
startCmdArgs.ActivateRuntime = current.ActivateRuntime
}
}
// cgroups v2 temp workaround
if !cmd.Flag("cgroups-v2").Changed {
startCmdArgs.TempCgroupsV2 = current.TempCgroupsV2
}
if util.MacOS() {
if !cmd.Flag("network-driver").Changed {
startCmdArgs.Network.Driver = current.Network.Driver
Expand Down
3 changes: 3 additions & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ type Config struct {

// SSH config generation
SSHConfig bool `yaml:"sshConfig,omitempty"`

// Temporary workaround for cgroups v2.
TempCgroupsV2 bool `yaml:"cgroupsV2,omitempty"`
}

// Kubernetes is kubernetes configuration
Expand Down
5 changes: 5 additions & 0 deletions embedded/defaults/colima.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,8 @@ mounts: []
#
# Default: {}
env: {}

# Enable cgroups v2 as a temporary workaround for https://github.com/abiosoft/colima/issues/764.
# NOTE: this is incompatible with Kubernetes and Ubuntu Layer.
# NOTE: this config will be removed in future versions.
cgroupsV2: false
27 changes: 27 additions & 0 deletions environment/vm/lima/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,33 @@ func newConf(ctx context.Context, conf config.Config) (l Config, err error) {
Script: `grep -q "^rc_env_allow" /etc/rc.conf || echo 'rc_env_allow="*"' >> /etc/rc.conf`,
})

// cgroups v2 workaround
{
// delete setting if present
l.Provision = append(l.Provision, Provision{
Mode: ProvisionModeSystem,
Script: `(grep -q "^rc_cgroup_mode" /etc/rc.conf && sed -i '/^rc_cgroup_mode/d' /etc/rc.conf && service cgroups restart) || echo 'cgroup v2 config not found'`,
})

// validate workaround is supported
if conf.TempCgroupsV2 {
if conf.Kubernetes.Enabled {
logrus.Warnln("cgroups v2 workaround not compatible with Kubernetes, ignoring...")
conf.TempCgroupsV2 = false
}
if conf.Layer {
logrus.Warnln("cgroups v2 workaround not compatible with Ubuntu layer, ignoring...")
conf.TempCgroupsV2 = false
}
}

if conf.TempCgroupsV2 {
l.Provision = append(l.Provision, Provision{
Mode: ProvisionModeSystem,
Script: `echo 'rc_cgroup_mode="unified"' >> /etc/rc.conf && service cgroups restart`,
})
}
}
}

// network setup
Expand Down
Loading