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

Mask swap.target doesn't take effect after reboot #10741

Closed
tu1h opened this issue Dec 22, 2023 · 7 comments · Fixed by #10751
Closed

Mask swap.target doesn't take effect after reboot #10741

tu1h opened this issue Dec 22, 2023 · 7 comments · Fixed by #10751
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@tu1h
Copy link
Member

tu1h commented Dec 22, 2023

I found that swap partition would still be actived after masking swap.target and rebooting.

Related to #10587

image

Environment:

  • Cloud provider or hardware configuration:

  • OS (printf "$(uname -srm)\n$(cat /etc/os-release)\n"):

Linux 3.10.0-1160.el7.x86_64 x86_64
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
  • Version of Ansible (ansible --version):

  • Version of Python (python --version):

Kubespray version (commit) (git rev-parse --short HEAD):

Network plugin used:

Full inventory with variables (ansible -i inventory/sample/inventory.ini all -m debug -a "var=hostvars[inventory_hostname]"):

Command used to invoke ansible:

Output of ansible run:

Anything else do we need to know:

@tu1h tu1h added the kind/bug Categorizes issue or PR as related to a bug. label Dec 22, 2023
@VannTen
Copy link
Contributor

VannTen commented Dec 22, 2023

Odd. What's in /proc/swaps ?

@tu1h
Copy link
Member Author

tu1h commented Dec 22, 2023

image

@VannTen
Copy link
Contributor

VannTen commented Dec 22, 2023 via email

@tu1h
Copy link
Member Author

tu1h commented Dec 22, 2023

  1. systemctl --version
systemd 219
+PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 -SECCOMP +BLKID +ELFUTILS +KMOD +IDN
  1. systemctl --type swap
UNIT                           LOAD   ACTIVE SUB    DESCRIPTION
dev-mapper-centos\x2dswap.swap loaded active active /dev/mapper/centos-swap
  1. systemctl cat dev-mapper-centos\x2dswap.swap
    No files found for dev-mapper-centosx2dswap.swap.
  2. systemctl show dev-mapper-centos\x2dswap.swap
What=/dev/mapper/centosx2dswap
Priority=-1
TimeoutUSec=1min 30s
ControlPID=0
Result=success
Slice=system.slice
MemoryCurrent=18446744073709551615
TasksCurrent=18446744073709551615
Delegate=no
CPUAccounting=no
CPUShares=18446744073709551615
StartupCPUShares=18446744073709551615
CPUQuotaPerSecUSec=infinity
BlockIOAccounting=no
BlockIOWeight=18446744073709551615
StartupBlockIOWeight=18446744073709551615
MemoryAccounting=no
MemoryLimit=18446744073709551615
DevicePolicy=auto
TasksAccounting=no
TasksMax=18446744073709551615
UMask=0022
LimitCPU=18446744073709551615
LimitFSIZE=18446744073709551615
LimitDATA=18446744073709551615
LimitSTACK=18446744073709551615
LimitCORE=18446744073709551615
LimitRSS=18446744073709551615
LimitNOFILE=4096
LimitAS=18446744073709551615
LimitNPROC=127948
LimitMEMLOCK=65536
LimitLOCKS=18446744073709551615
LimitSIGPENDING=127948
LimitMSGQUEUE=819200
LimitNICE=0
LimitRTPRIO=0
LimitRTTIME=18446744073709551615
OOMScoreAdjust=0
Nice=0
IOScheduling=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogLevelPrefix=yes
SecureBits=0
CapabilityBoundingSet=18446744073709551615
AmbientCapabilities=0
MountFlags=0
PrivateTmp=no
PrivateNetwork=no
PrivateDevices=no
ProtectHome=no
ProtectSystem=no
SameProcessGroup=no
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=0
RuntimeDirectoryMode=0755
KillMode=control-group
KillSignal=15
SendSIGKILL=yes
SendSIGHUP=no
Id=dev-mapper-centosx2dswap.swap
Names=dev-mapper-centosx2dswap.swap
Requires=-.mount system.slice
Conflicts=umount.target
Before=umount.target swap.target
After=-.mount system.slice systemd-journald.socket
RequiresMountsFor=/dev/mapper/centosx2dswap
Description=/dev/mapper/centosx2dswap
LoadState=loaded
ActiveState=inactive
SubState=dead
InactiveExitTimestampMonotonic=0
ActiveEnterTimestampMonotonic=0
ActiveExitTimestampMonotonic=0
InactiveEnterTimestampMonotonic=0
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=yes
IgnoreOnSnapshot=no
NeedDaemonReload=no
JobTimeoutUSec=0
JobTimeoutAction=none
ConditionResult=no
AssertResult=no
ConditionTimestampMonotonic=0
AssertTimestampMonotonic=0
Transient=no
CollectMode=inactive

@piwinkler
Copy link
Contributor

can reproduce it
OS
Linux 3.10.0-1160.105.1.el7.x86_64 x86_64
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

possible solution is to mask every swap unit file

[root@foo ~]# systemctl --type swap
UNIT                                                                      LOAD   ACTIVE SUB    DESCRIPTION
dev-disk-by\x2duuid-4470b768\x2def1c\x2d40f8\x2d8751\x2d104e00bfd3c6.swap loaded active active /dev/disk/by-uuid/4470b768-ef1c-40f8-8751-104e00bfd3c6

[root@foo ~]# systemctl mask "dev-disk-by\x2duuid-4470b768\x2def1c\x2d40f8\x2d8751\x2d104e00bfd3c6.swap"

on a more recent system there are no unit files generated after the swap target got masked

@VannTen
Copy link
Contributor

VannTen commented Dec 29, 2023

systemctl cat dev-mapper-centos\x2dswap.swap

Can you quote the unit name / escape the \ ? I think the shell is swallowing it.

(And I forgot last time: could you also post the result of systemctl status on the unit ? And any relevants logs if you can look at them before log rotation)

on a more recent system there are no unit files generated after the swap target got masked

No unit files or not started ? AFAIK they should be generated by fstab-generator, just not started.

@tu1h
Copy link
Member Author

tu1h commented Jan 2, 2024

@VannTen I post some details.

systemctl cat dev-mapper-centos\x2dswap.swap

# /run/systemd/generator/dev-mapper-centos\x2dswap.swap
# Automatically generated by systemd-fstab-generator

[Unit]
SourcePath=/etc/fstab
Documentation=man:fstab(5) man:systemd-fstab-generator(8)

[Swap]
What=/dev/mapper/centos-swap

systemctl show "dev-mapper-centos\x2dswap.swap"

What=/dev/mapper/centos-swap
Priority=-1
TimeoutUSec=1min 30s
ControlPID=0
Result=success
Slice=system.slice
MemoryCurrent=18446744073709551615
TasksCurrent=18446744073709551615
Delegate=no
CPUAccounting=no
CPUShares=18446744073709551615
StartupCPUShares=18446744073709551615
CPUQuotaPerSecUSec=infinity
BlockIOAccounting=no
BlockIOWeight=18446744073709551615
StartupBlockIOWeight=18446744073709551615
MemoryAccounting=no
MemoryLimit=18446744073709551615
DevicePolicy=auto
TasksAccounting=no
TasksMax=18446744073709551615
UMask=0022
LimitCPU=18446744073709551615
LimitFSIZE=18446744073709551615
LimitDATA=18446744073709551615
LimitSTACK=18446744073709551615
LimitCORE=18446744073709551615
LimitRSS=18446744073709551615
LimitNOFILE=4096
LimitAS=18446744073709551615
LimitNPROC=127948
LimitMEMLOCK=65536
LimitLOCKS=18446744073709551615
LimitSIGPENDING=127948
LimitMSGQUEUE=819200
LimitNICE=0
LimitRTPRIO=0
LimitRTTIME=18446744073709551615
OOMScoreAdjust=0
Nice=0
IOScheduling=0
CPUSchedulingPolicy=0
CPUSchedulingPriority=0
TimerSlackNSec=50000
CPUSchedulingResetOnFork=no
NonBlocking=no
StandardInput=null
StandardOutput=journal
StandardError=inherit
TTYReset=no
TTYVHangup=no
TTYVTDisallocate=no
SyslogPriority=30
SyslogLevelPrefix=yes
SecureBits=0
CapabilityBoundingSet=18446744073709551615
AmbientCapabilities=0
MountFlags=0
PrivateTmp=no
PrivateNetwork=no
PrivateDevices=no
ProtectHome=no
ProtectSystem=no
SameProcessGroup=no
IgnoreSIGPIPE=yes
NoNewPrivileges=no
SystemCallErrorNumber=0
RuntimeDirectoryMode=0755
KillMode=control-group
KillSignal=15
SendSIGKILL=yes
SendSIGHUP=no
Id=dev-mapper-centos\x2dswap.swap
Names=dev-mapper-centos\x2dswap.swap
Requires=system.slice -.mount
BindsTo=dev-mapper-centos\x2dswap.device
RequiredBy=swap.target
WantedBy=dev-mapper-centos\x2dswap.device
Conflicts=umount.target
Before=umount.target swap.target
After=dev-mapper-centos\x2dswap.device system.slice systemd-journald.socket -.mount
RequiresMountsFor=/dev/mapper/centos-swap
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
Description=/dev/mapper/centos-swap
LoadState=loaded
ActiveState=inactive
SubState=dead
FragmentPath=/run/systemd/generator/dev-mapper-centos\x2dswap.swap
SourcePath=/etc/fstab
UnitFileState=bad
UnitFilePreset=disabled
InactiveExitTimestamp=Wed 2023-06-21 05:03:14 EDT
InactiveExitTimestampMonotonic=32663728
ActiveEnterTimestamp=Wed 2023-06-21 05:03:14 EDT
ActiveEnterTimestampMonotonic=32677758
ActiveExitTimestamp=Tue 2024-01-02 02:15:31 EST
ActiveExitTimestampMonotonic=252979130
InactiveEnterTimestamp=Tue 2024-01-02 02:15:31 EST
InactiveEnterTimestampMonotonic=252979130
CanStart=yes
CanStop=yes
CanReload=no
CanIsolate=no
StopWhenUnneeded=no
RefuseManualStart=no
RefuseManualStop=no
AllowIsolate=no
DefaultDependencies=yes
OnFailureJobMode=replace
IgnoreOnIsolate=yes
IgnoreOnSnapshot=no
NeedDaemonReload=no
JobTimeoutUSec=0
JobTimeoutAction=none
ConditionResult=yes
AssertResult=yes
ConditionTimestamp=Wed 2023-06-21 05:03:14 EDT
ConditionTimestampMonotonic=32661410
AssertTimestamp=Wed 2023-06-21 05:03:14 EDT
AssertTimestampMonotonic=32661410
Transient=no
CollectMode=inactive

systemctl status "dev-mapper-centos\x2dswap.swap"

● dev-mapper-centos\x2dswap.swap - /dev/mapper/centos-swap
   Loaded: loaded (/etc/fstab; bad; vendor preset: disabled)
   Active: inactive (dead) since Tue 2024-01-02 02:15:31 EST; 2h 6min ago
     What: /dev/mapper/centos-swap
     Docs: man:fstab(5)
           man:systemd-fstab-generator(8)

Jun 21 05:03:14 localhost.localdomain systemd[1]: Activating swap /dev/mapper/centos-swap...
Jun 21 05:03:14 localhost.localdomain systemd[1]: Activated swap /dev/mapper/centos-swap.

journalctl -xu swap.target

-- Logs begin at Wed 2023-06-21 05:02:42 EDT, end at Tue 2024-01-02 04:22:30 EST. --
Jun 21 05:02:48 localhost.localdomain systemd[1]: Stopped target Swap.
-- Subject: Unit swap.target has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit swap.target has finished shutting down.
Jun 21 05:03:14 localhost.localdomain systemd[1]: Reached target Swap.
-- Subject: Unit swap.target has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit swap.target has finished starting up.
--
-- The start-up result is done.
Jan 02 02:16:31 node1 systemd[1]: Cannot add dependency job for unit swap.target, ignoring: Unit is masked.
Jan 02 02:16:31 node1 systemd[1]: Cannot add dependency job for unit swap.target, ignoring: Unit is masked.
Jan 02 02:16:31 node1 systemd[1]: Cannot add dependency job for unit swap.target, ignoring: Unit is masked.
Jan 02 02:19:30 node1 systemd[1]: Cannot add dependency job for unit swap.target, ignoring: Unit is masked.
Jan 02 02:23:36 node1 systemd[1]: Cannot add dependency job for unit swap.target, ignoring: Unit is masked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants