Bug 234686 - sysutils/ec2-scripts: ec2_ephemeralswap always causes syntax error after FreeBSD 11
Summary: sysutils/ec2-scripts: ec2_ephemeralswap always causes syntax error after Free...
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Colin Percival
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-01-07 09:03 UTC by Koichiro Iwao
Modified: 2019-01-16 01:33 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (cperciva)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Koichiro Iwao freebsd_committer 2019-01-07 09:03:44 UTC
/usr/local/etc/rc.d/ec2_ephemeralswap: DEBUG: checkyesno: ec2_ephemeralswap_enable is set to YES.
/usr/local/etc/rc.d/ec2_ephemeralswap: DEBUG: checkyesno: ec2_ephemeralswap_enable is set to YES.
/usr/local/etc/rc.d/ec2_ephemeralswap: DEBUG: run_rc_command: doit: :
/usr/local/etc/rc.d/ec2_ephemeralswap: DEBUG: checkyesno: ec2_ephemeralswap_enable is set to YES.
/usr/local/etc/rc.d/ec2_ephemeralswap: DEBUG: run_rc_command: doit: ec2_ephemeralswap_run
expr: syntax error
[: -lt: unexpected operator
/usr/local/etc/rc.d/ec2_ephemeralswap: DEBUG: EC2 ephemeral disks are
No ephemeral disks are available, so no swap space is being created.

This is caused around line 54 since after FreeBSD 11, SWZONESTRUCTS is always empty. `vmstat -z` no longer returns SWAPMETA.

> SWZONESTRUCTS=`vmstat -z | tr -d , | awk '/^SWAPMETA/ { print $3 }'`

Probably the script should refer `swblk` instead. See also what's changed in sys/vm/swap_pager.c between FreeBSD 10 and 11.
Comment 1 Colin Percival freebsd_committer 2019-01-09 03:46:53 UTC
Oops, I meant to fix this a long time ago.  There will be other changes needed too.  For now I'm just going to disable this script.
Comment 2 commit-hook freebsd_committer 2019-01-09 03:56:09 UTC
A commit references this bug:

Author: cperciva
Date: Wed Jan  9 03:55:26 UTC 2019
New revision: 342875
URL: https://svnweb.freebsd.org/changeset/base/342875

Log:
  Turn off ec2_ephemeralswap for now

  This script broke around FreeBSD 11.0 as a result of SWAPMETA no longer
  being reported by vmstat -z; but it also needs to be reworked due to the
  arrival in EC2 of nvme ephemeral disks.

  I'll turn this option back on after I've found time to rewrite the
  script in question.

  PR:		234686
  Reported by:	meta@
  MFC after:	1 week

Changes:
  head/release/tools/ec2.conf
Comment 3 Koichiro Iwao freebsd_committer 2019-01-09 04:01:07 UTC
Do you have any plans to publish the repository of the scripts? For example, on GitHub or something like that. Then I can help you to develop it.
Comment 4 Colin Percival freebsd_committer 2019-01-09 04:57:41 UTC
Good point.  I've uploaded the code here: https://github.com/cperciva/ec2-scripts
Comment 5 Koichiro Iwao freebsd_committer 2019-01-09 05:13:37 UTC
(In reply to Colin Percival from comment #4)

Thanks!
Comment 6 Charles O'Donnell 2019-01-12 00:43:19 UTC
As Colin mentioned there is also the issue of the new nvme ephemeral disks, which increase the challenge of identification since they use the same device names as EBS.

$ fetch -qo - http://169.254.169.254/latest/meta-data/block-device-mapping     
ami
ebs2

$ dmesg | egrep nvme
nvme0: <Generic NVMe Device> mem 0xfebf0000-0xfebf3fff irq 11 at device 4.0 on pci0
nvme1: <Generic NVMe Device> mem 0xfebf8000-0xfebfbfff irq 10 at device 30.0 on pci0
nvme2: <Generic NVMe Device> mem 0xfebfc000-0xfebfffff,0xfe900000-0xfe901fff at device 31.0 on pci0

The only difference I found is in the device description:

$ dmesg | grep nvd
nvd0: <Amazon Elastic Block Store> NVMe namespace
nvd0: 10240MB (20971520 512 byte sectors)
nvd1: <Amazon Elastic Block Store> NVMe namespace
nvd1: 51200MB (104857600 512 byte sectors)
nvd2: <Amazon EC2 NVMe Instance Storage> NVMe namespace
nvd2: 95367MB (195312500 512 byte sectors)


Best,

Chuck
Comment 7 commit-hook freebsd_committer 2019-01-16 01:33:25 UTC
A commit references this bug:

Author: cperciva
Date: Wed Jan 16 01:32:42 UTC 2019
New revision: 343070
URL: https://svnweb.freebsd.org/changeset/base/343070

Log:
  MFC r342875: Turn off ec2_ephemeralswap for now

  PR:		234686

Changes:
_U  stable/12/
  stable/12/release/tools/ec2.conf