hashicorp / packer-plugin-alicloud

Packer plugin for Alibaba Cloud Image Builder
https://www.packer.io/docs/builders/alicloud-ecs
Mozilla Public License 2.0
12 stars 21 forks source link

Add config vars to support cgroup v2 #139

Closed hbrls closed 3 months ago

hbrls commented 4 months ago

Description

Installing k3s with packer will fail, with the error message failed to find cpu cgroup (v2).

Need some config vars like:

https://github.com/AliyunContainerService/ack-image-builder/blob/master/scripts/set-cgroupv2.sh

https://help.aliyun.com/zh/ack/ack-managed-and-ack-dedicated/user-guide/create-cgroup-v2-nodes-from-a-custom-image

Use Case(s)

Any relevant use-cases that you see.

Potential configuration

Potential References

lbajolet-hashicorp commented 4 months ago

Hi @hbrls,

cgroupsv2 is an OS-specific feature, and not something that Packer has agency on AFAICT. Looking at the links you shared, declaring those environment variables is required if you want to enable cgroupsv2, this is not something Packer or the Alicloud plugin can change independently I'd think.

May I ask what you're requesting? Declaring an environment variable indeed belongs to the provisioner context, not the source, so I'd think we cannot change the builder to accomodate for that, but please let me know if I misunderstand something.

Thanks!

hbrls commented 3 months ago

After some document research, I think Alicloud do support v2. But it uses v2 to start a real ec2, vs. it uses v1 to start a packer build image process.

And I suppose the line can indicate Alicloud to use v2 also when packer build.

I've no knowledge about the base implement.

lbajolet-hashicorp commented 3 months ago

Hey @hbrls,

It's a system setting, the line you're referring to updates the boot parameters for the kernel so it enables cgroupsv2. This is OS-specific, not something Packer or this plugin can or should (imo) set, this requires access to the filesystem, we're outside the boundaries of what the builder can do here.

My advice if you need cgroupsv2 is to use the script provided by alicloud (if relevant), or refer to documentation to know which command to invoke/setting to enable in a shell script provisioner to run in the instance you're building the image from.

With this said, I don't think there's something to do on the Packer front, so I'll close this issue as this is not a bug, nor something that falls in the plugin's responsibility, but please feel free to reopen if there's something I'm missing.

Thanks!