openlogic / AzureBuildCentOS

Kickstart scripts and other components to build CentOS images for Azure
Other
20 stars 22 forks source link

Why is swap enable by default ? #112

Closed julienym closed 3 years ago

julienym commented 3 years ago

Ref: https://github.com/openlogic/AzureBuildCentOS/blob/master/ks/azure/centos76-hpc-sriov.ks

I am not sure why the swapfile of 2G is created and when we don't even check for the settings in /etc/waagent.conf

We find on our host that the service temp-disk-swapfile.service is started (we don't know how) - except for the WantedBy=cloud-config.service

Any help would be appriciated! Thanks

Klaas- commented 3 years ago

Hi,

Ref: https://github.com/openlogic/AzureBuildCentOS/blob/master/ks/azure/centos76-hpc-sriov.ks

I am not sure why the swapfile of 2G is created and when we don't even check for the settings in /etc/waagent.conf

waagent is no longer being used for this, microsoft suggests to use cloud-init for swap creation, openlogic uses the service you see in https://github.com/openlogic/AzureBuildCentOS/blob/master/ks/azure/centos76-hpc-sriov.ks#L402-L477

We find on our host that the service temp-disk-swapfile.service is started (we don't know how) - except for the WantedBy=cloud-config.service

I am guessing you need to mask/remove that service if you want to disable swap. But I have not tested it.

The general question of "why is there swap" is most likely because Red Hat recommends it. I am not sure why they're not following the Red Hat recommendations (https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-swapspace for el7) or why Red Hat recommends the sizes they suggest in the docs :)

Having said that: I already pointed out that using a swapfile is not really considered a good idea by kernel developers ( https://github.com/openlogic/AzureBuildCentOS/issues/105#issuecomment-814979792 ) .

Any help would be appriciated! Thanks

julienym commented 3 years ago

Hi @Klaas-

We can't or don't want any swap since it is for Kubernetes nodes. Also if you need swap, should it not be done in cloud-init in a customizable way? (Disk perf, and size are important then)

The systemd service is not enabled, but can be activated - as my systemd's readings. We can't find why the service was activated yet, but right now we can't take the chance and must remove that service...

Klaas- commented 3 years ago

Hi @Klaas-

We can't or don't want any swap since it is for Kubernetes nodes. Also if you need swap, should it not be done in cloud-init in a customizable way? (Disk perf, and size are important then)

well it is customizable -- that is what you are doing :) having said that -- if you want the "centos of red hat openshift" you need to look into https://www.okd.io/ , that does not use centos as base but rather fedora coreos.

The systemd service is not enabled, but can be activated - as my systemd's readings. We can't find why the service was activated yet, but right now we can't take the chance and must remove that service...

as I said, I think masking the service should do the trick, if that is not enough rm the file and do a daemon-reload. It shouldn't come back on it's own -- its being created in the kickstart that is only used during creation of the image.