Swap not getting enabled.

18 views
Skip to first unread message

m ahuja

unread,
Jul 30, 2017, 12:58:25 PM7/30/17
to Puppet Users
I do the following command in a series of commands.
I make swap using fallocate -l 65G & chmod 0600
I /sbin/mkswap /mnt/../../swapXXX
I /bin/echo -en '\n/mnt../../swapXXX swap swap auto 0 0\n' >> /etc/fstab

I then do the following and it fails. What am I doing wrong?

 exec { "attach swap file":
        command => "/sbin/swapon -af -p 1",
        require => Exec["make fstab entry"],
        unless => "/sbin/swapon -s | grep /mnt/ephemeral0/cassandra/swap65G",
    } ->

From log file:

/Stage[main]/Ax::Cassandra::Node/Exec[attach swap file]/returns: executed successfully

dmesg shows 
"Adding 68157436k swap on /mnt/ephemeral0/../swap65G.  Priority:1 extents:45 across:72851452k SSFS"

free -m
             total       used       free     shared    buffers     cached
Mem:          3774       3213        561          8        106       1646
-/+ buffers/cache:       1460       2314
Swap:            0          0          0

No swap.
But if I run the command on command line it runs fine.
If I do a puppet apply --debug --version it works fine.
The puppet file is applied as root. 

WHAT am I doing wrong? It's messing with my mind.

sudo /sbin/swapon -af -p 1
admin@:~$ free -m
             total       used       free     shared    buffers     cached
Mem:          3774       3232        542          8        106       1646
-/+ buffers/cache:       1479       2295
Swap:        66559          0      66559

Dmesg now has two entries!
[Sun Jul 30 02:34:54 2017] Adding 68157436k swap on /mnt/ephemeral0/cassandra/swap65G.  Priority:1 extents:45 across:72851452k SSFS
[Sun Jul 30 02:50:43 2017] Adding 68157436k swap on /mnt/ephemeral0/cassandra/swap65G.  Priority:1 extents:45 across:72851452k SSFS

Really whats going on?

jcbollinger

unread,
Jul 31, 2017, 9:51:35 AM7/31/17
to Puppet Users


On Sunday, July 30, 2017 at 11:58:25 AM UTC-5, m ahuja wrote:
I do the following command in a series of commands.
I make swap using fallocate -l 65G & chmod 0600
I /sbin/mkswap /mnt/../../swapXXX
I /bin/echo -en '\n/mnt../../swapXXX swap swap auto 0 0\n' >> /etc/fstab


You really ought to use a Mount resource to manage the /etc/fstab entry, but that's surely unrelated to the problem you describe.

 

I then do the following and it fails. What am I doing wrong?

 exec { "attach swap file":
        command => "/sbin/swapon -af -p 1",
        require => Exec["make fstab entry"],
        unless => "/sbin/swapon -s | grep /mnt/ephemeral0/cassandra/swap65G",
    } ->

From log file:

/Stage[main]/Ax::Cassandra::Node/Exec[attach swap file]/returns: executed successfully


Puppet seems to disagree with you: the command does not fail, in the sense that its exit status is not different from 0.

 

dmesg shows 
"Adding 68157436k swap on /mnt/ephemeral0/../swap65G.  Priority:1 extents:45 across:72851452k SSFS"



And that seems to confirm that it did not fail.

 
free -m
             total       used       free     shared    buffers     cached
Mem:          3774       3213        561          8        106       1646
-/+ buffers/cache:       1460       2314
Swap:            0          0          0

No swap.


But that is indeed odd.

 
But if I run the command on command line it runs fine.
If I do a puppet apply --debug --version it works fine.


Did you mean "--verbose"? Anyway, it is odd if the effect on the system varies with the use of the --debug or --verbose option, but it is not clear whether those are the only things that differ between the run that has the result you want and the one that doesn't.

You haven't given us (or at least me) enough to work with.  I would like to see a complete manifest that is sufficient to demonstrate the problem, together with sufficient procedural instructions for how to reproduce the incorrect behavior.  Until I see those, my best guess is that in your success case you apply a different, more narrowly-scoped starting manifest, and there is something else being applied in the failure case that causes the swap file to be disabled before the end of the run.


John

Reply all
Reply to author
Forward
0 new messages