Chef resource skipped even though not_if command exits 2 - amazon-web-services

The resource has a not_if guard, and I've verified that the exit code from the command is non-zero. Yet the output of the chef run shows that the resource is skipped due to not_if.
The resource looks like
device_id = "/dev/xvdf"
execute 'yes | mkfs -t ext4 #{device_id}' do
not_if 'blkid -o value -s TYPE #{device_id} && blkid -o value -s TYPE #{device_id} | grep ext4'
timeout 1200
end

Sigh. Ruby doesn't interpolate in single-quote strings. Changed them to double quote and fixed the issue.

Related

Passing valgrind flags from cmake

Complementary to this question, how can I pass flags to valgrind from cmake?
# enable valgrind checks
set(CTEST_MEMORYCHECK_TYPE "valgrind")
set(CTEST_MEMORYCHECK_COMMAND_OPTIONS "--leak-check=no")
According to the docs, The lines above should work, but after running cmake . + make I get:
$ ctest -T memcheck | grep "Memory Leak\|Defects"
1/1 MemCheck: #1: test ............................. Defects: 1
Memory Leak - 1
When I inspect the DartConfiguration.tcl file I don't see my flag there:
$ sed -n "79,80p" ./DartConfiguration.tcl
MemoryCheckCommand: /usr/local/bin/valgrind
MemoryCheckCommandOptions: # <--- nothing here ...
After manually editing DartConfiguration.tcl everything works fine:
$ sed -i "s/MemoryCheckCommandOptions:/MemoryCheckCommandOptions: --leak-check=no/g" DartConfiguration.tcl
$ ctest -T memcheck | grep "Memory Leak\|Defects"
$ # nothing ( good )
All the details exist in the public repo: https://github.com/OrenGitHub/ValgrindCmake
Particularly, the cmake test pipelines: here and here

Sending pcap file via packetgen dpdk

Sending a pcap file on port 0. I get the following error. Any fix would be appreciated!
The command used is:
sudo ./app/x86_64-native-linuxapp-gcc/pktgen -c 0X01 -n 1 --file-prefix=pg -w 4:00.1 -- -m 1.0 -T -P -s 0:~/Downloads/bigFlows.pcap
There are 2 obvious reasons for the failure.
Number of CPU cores for pktgen to work is 1 + number of ports in use
you have extra argument in comamnd executed in pktgen.
Checking the link, it show the command used is sudo ./app/x86_64-native-linuxapp-gcc/pktgen -c 0X01 -n 1 --file-prefix=pg -w 4:00.1 -- -m 1.0 -T -P -s 0:[~/Downloads/bigFlows.pcap]. You should not sue [] instead use 0:actual path to pcap.
Note: #SaifUllah during the live debug both core and pcap were show cased for you.

gsutil mb -c standard gs://gcpassignmentapp giving error No command was given Choose one of -b, -d, -e, or -r to do something

user#user-Latitude-E5440:~$ gsutil mb -c standard gs://gcpassignmentapp
No command was given.
Choose one of -b, -d, -e, or -r to do something.
Try `/usr/bin/gsutil --help' for more information.
user#user-Latitude-E5440:~$
I think you have a different program installed also named gsutil.

execute commands in a CoreOS cloud-config (e.g. to add swap)

I see that unlike the standard cloud-config file, there is no runcmd option in a CoreOS cloud-config file. Currently, I enable swap on a CoreOS machine by adding the following to my cloud-config:
units:
- name: swap.service
command: start
content: |
[Unit]
Description=Turn on swap
[Service]
Type=oneshot
Environment="SWAPFILE=/1GiB.swap"
RemainAfterExit=true
ExecStartPre=/usr/sbin/losetup -f ${SWAPFILE}
ExecStart=/usr/bin/sh -c "/sbin/swapon $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
ExecStop=/usr/bin/sh -c "/sbin/swapoff $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
ExecStopPost=/usr/bin/sh -c "/usr/sbin/losetup -d $(/usr/sbin/losetup -j ${SWAPFILE} | /usr/bin/cut -d : -f 1)"
[Install]
WantedBy=local.target
Then after initializing my CoreOS image I have to ssh into the machine and run:
sudo fallocate -l 1024m /1GiB.swap && sudo chmod 600 /1GiB.swap \
&& sudo chattr +C /1GiB.swap && sudo mkswap /1GiB.swap
sudo reboot
before swap will be enabled (e.g. as evidenced by top).
It seems like I should be able to accomplish the latter commands in the cloud-config file itself, but I'm not clear on how I can run such commands without a runmcd field in cloud-config. Perhaps this can be done either by editing my swap.service unit or perhaps by adding another unit, but I haven't figured out quite how.
So, that leaves me with two questions: (1) Can this be done or will it always be necessary to run the last commands manually? (2) If the former, then how?
As pointed out in this answer to an issue on Github, you end up writing a unit to invoke the command of your choice. This answer, gives a good example of using an arbitrary command:
#cloud-config
....
coreos:
units:
- name: runcmd.service
command: start
content: |
[Unit]
Description=Creates a tmp foo file
[Service]
Type=oneshot
ExecStart=/bin/sh -c "touch /tmp/foo;"
#cboettig - thanks to your unit file example and #philibaker note, I got this going - basically the only thing I had to do was to change the ExecStartPre to:
ExecStartPre=/bin/bash -c "\
fallocate -l 2g $SWAPFILE && \
chmod 600 $SWAPFILE && \
chattr +C $SWAPFILE && \
mkswap $SWAPFILE && \
losetup -f $SWAPFILE"
and that includes the entire setup in the preexec step.

Getting gdb to automatically load binary from core file

Can I get gdb to automatically load the binary that's specified in the core file?
Given a core file I now usually do:
gdb -c corefile
GNU gdb 6.8
...
Core was generated by `/path/to/binary'
Then i copy-paste that and run:
gdb -c corefile /path/to/binary
It seems like an unnecessary two-step process and yet I don't seen an obvious way of doing it based on the man page. Am I missing something?
You could just script it?
#!/bin/bash
gdb "`file "$1" | awk -F \' '{print $2}'`" "$1"
This is what I usually endup doing:
var=$(file corefile)
echo ${var##*from}
gdc() {
gdb -c "$1" "$(file "$1" | sed -r -e "s#.*execfn: '([^\']+)'.*#\1#")"
}
$ gdc corefile