Bug 234686

Summary: sysutils/ec2-scripts: ec2_ephemeralswap always causes syntax error after FreeBSD 11
Product: Ports & Packages Reporter: Koichiro Iwao <meta>
Component: Individual Port(s)Assignee: Colin Percival <cperciva>
Status: In Progress ---    
Severity: Affects Some People CC: cao, meta
Priority: --- Flags: bugzilla: maintainer-feedback? (cperciva)
Version: Latest   
Hardware: Any   
OS: Any   

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

  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

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)

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 -     

$ 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)


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

  MFC r342875: Turn off ec2_ephemeralswap for now

  PR:		234686

_U  stable/12/
Comment 8 Charles O'Donnell 2019-02-14 12:46:50 UTC
nvmecontrol provides a means to identify instance storage devices.

# nvmecontrol devlist | grep 'Instance Storage'
 nvme2: Amazon EC2 NVMe Instance Storage