{"action":"created","issue":{"url":"https://api.github.com/repos/saltstack/salt/issues/28203","repository_url":"https://api.github.com/repos/saltstack/salt","labels_url":"https://api.github.com/repos/saltstack/salt/issues/28203/labels{/name}","comments_url":"https://api.github.com/repos/saltstack/salt/issues/28203/comments","events_url":"https://api.github.com/repos/saltstack/salt/issues/28203/events","html_url":"https://github.com/saltstack/salt/issues/28203","id":112769993,"number":28203,"title":"blockdev.formatted failing on 2nd+ run, despite disk already being formatted ","user":{"login":"edhgoose","id":1108173,"avatar_url":"https://avatars.githubusercontent.com/u/1108173?v=3","gravatar_id":"","url":"https://api.github.com/users/edhgoose","html_url":"https://github.com/edhgoose","followers_url":"https://api.github.com/users/edhgoose/followers","following_url":"https://api.github.com/users/edhgoose/following{/other_user}","gists_url":"https://api.github.com/users/edhgoose/gists{/gist_id}","starred_url":"https://api.github.com/users/edhgoose/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/edhgoose/subscriptions","organizations_url":"https://api.github.com/users/edhgoose/orgs","repos_url":"https://api.github.com/users/edhgoose/repos","events_url":"https://api.github.com/users/edhgoose/events{/privacy}","received_events_url":"https://api.github.com/users/edhgoose/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/saltstack/salt/labels/Bug","name":"Bug","color":"e11d21"},{"url":"https://api.github.com/repos/saltstack/salt/labels/High%20Severity","name":"High Severity","color":"ff9143"},{"url":"https://api.github.com/repos/saltstack/salt/labels/P3","name":"P3","color":"0a3d77"},{"url":"https://api.github.com/repos/saltstack/salt/labels/Platform","name":"Platform","color":"fef2c0"},{"url":"https://api.github.com/repos/saltstack/salt/labels/State%20Module","name":"State Module","color":"006b75"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/saltstack/salt/milestones/13","html_url":"https://github.com/saltstack/salt/milestones/Approved","labels_url":"https://api.github.com/repos/saltstack/salt/milestones/13/labels","id":9265,"number":13,"title":"Approved","description":"All issues that are ready to be worked on, both bugs and features.","creator":{"login":"thatch45","id":507599,"avatar_url":"https://avatars.githubusercontent.com/u/507599?v=3","gravatar_id":"","url":"https://api.github.com/users/thatch45","html_url":"https://github.com/thatch45","followers_url":"https://api.github.com/users/thatch45/followers","following_url":"https://api.github.com/users/thatch45/following{/other_user}","gists_url":"https://api.github.com/users/thatch45/gists{/gist_id}","starred_url":"https://api.github.com/users/thatch45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thatch45/subscriptions","organizations_url":"https://api.github.com/users/thatch45/orgs","repos_url":"https://api.github.com/users/thatch45/repos","events_url":"https://api.github.com/users/thatch45/events{/privacy}","received_events_url":"https://api.github.com/users/thatch45/received_events","type":"User","site_admin":false},"open_issues":3165,"closed_issues":3955,"state":"open","created_at":"2011-05-14T04:00:56Z","updated_at":"2016-08-30T17:57:03Z","due_on":null,"closed_at":null},"comments":5,"created_at":"2015-10-22T10:02:49Z","updated_at":"2016-08-30T17:59:39Z","closed_at":null,"body":"Hi,\r\n\r\nI'm seeing an issue with my use of `blockdev.formatted` state.\r\n\r\nI've set up a new Amazon EC2 instance using the standard Amazon AMI and I've founded a second EBS volume with 50gb of space. The disk is mounted at `/dev/sdf` which Amazon shows as `/dev/xvdf` on the instance.\r\n\r\nI'm using the following state configuration to format and then mount the disk:\r\n\r\n````\r\nformatted_elasticsearch_data:\r\n  blockdev.formatted:\r\n    - name: /dev/xvdf\r\n    - fs_type: ext4\r\n\r\nmnt_elasticsearch_data:\r\n  mount.mounted:\r\n    - name: {{ elasticsearch.data_dir }}\r\n    - device: /dev/xvdf\r\n    - fstype: ext4\r\n    - mkmnt: True\r\n````\r\n\r\nEverything works perfectly the first time. The volume is formatted and mounted at the correct point. I can continue as normal from there.\r\n\r\nHowever, when I run this state again I get the following output:\r\n\r\n````\r\n----------\r\n          ID: formatted_elasticsearch_data\r\n    Function: blockdev.formatted\r\n        Name: /dev/xvdf\r\n      Result: False\r\n     Comment: Failed to format /dev/xvdf\r\n     Started: 09:19:23.718308\r\n    Duration: 434.387 ms\r\n     Changes:\r\n````\r\n\r\nFrom looking at the code at https://github.com/saltstack/salt/blob/develop/salt/states/blockdev.py, I see the following line is used to investigate whether the disk has the correct `fstype` (at both lines 130 and 162 in current development branch):\r\n\r\n` blk = __salt__['cmd.run']('lsblk -o fstype {0}'.format(name)).splitlines()`\r\n\r\nIf I run `lsblk -o fstype` (plus a few other columns) on the instance directly I note that the fstype is not set to `ext4` as I would expect:\r\n\r\n````\r\nNAME    FSTYPE LABEL MOUNTPOINT\r\nxvda\r\n└─xvda1 ext4   /     /\r\nxvdf                 /usr/local/var/data/elasticsearch/disk1\r\n````\r\n\r\nThis output would trigger the error path that I'm seeing on line 169 and then 175.\r\n\r\nIs there an alternate way the system can determine if the block is formatted correctly? Amazon suggests using this command `sudo file -s /dev/xvdf` here http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html, which outputs the below, but I'm way out of my depth here!\r\n\r\nOutput from: `sudo file -s /dev/xvdf`:\r\n\r\n````\r\n/dev/xvdf: Linux rev 1.0 ext4 filesystem data, UUID=2891c754-391e-4e80-bc3b-b70d7089a042 (needs journal recovery) (extents) (large files) (huge files)\r\n````\r\n\r\nAlternatively, does `df -T` work?\r\n\r\n````\r\nFilesystem     Type 1K-blocks    Used Available Use% Mounted on\r\n/dev/xvdf      ext4  51475068 3350592  45486652   7% /usr/local/var/data/elasticsearch/disk1\r\n````\r\n\r\nHere's my output from salt --versions-report (I'm aware that I'm not running the latest, but I couldn't see anything in the blockdev.formatted implementation that would change the outcome given the underlying command appears to be giving an unexpected output).\r\n\r\n````\r\nSalt: 2015.5.5\r\n         Python: 2.6.9 (unknown, Apr  1 2015, 18:16:00)\r\n         Jinja2: 2.7.2\r\n       M2Crypto: 0.21.1\r\n msgpack-python: 0.4.6\r\n   msgpack-pure: Not Installed\r\n       pycrypto: 2.6.1\r\n        libnacl: Not Installed\r\n         PyYAML: 3.10\r\n          ioflo: Not Installed\r\n          PyZMQ: 14.3.1\r\n           RAET: Not Installed\r\n            ZMQ: 3.2.5\r\n           Mako: Not Installed\r\n        Tornado: Not Installed\r\n        timelib: Not Installed\r\n       dateutil: Not Installed\r\n````"},"comment":{"url":"https://api.github.com/repos/saltstack/salt/issues/comments/243525506","html_url":"https://github.com/saltstack/salt/issues/28203#issuecomment-243525506","issue_url":"https://api.github.com/repos/saltstack/salt/issues/28203","id":243525506,"user":{"login":"rallytime","id":6547906,"avatar_url":"https://avatars.githubusercontent.com/u/6547906?v=3","gravatar_id":"","url":"https://api.github.com/users/rallytime","html_url":"https://github.com/rallytime","followers_url":"https://api.github.com/users/rallytime/followers","following_url":"https://api.github.com/users/rallytime/following{/other_user}","gists_url":"https://api.github.com/users/rallytime/gists{/gist_id}","starred_url":"https://api.github.com/users/rallytime/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rallytime/subscriptions","organizations_url":"https://api.github.com/users/rallytime/orgs","repos_url":"https://api.github.com/users/rallytime/repos","events_url":"https://api.github.com/users/rallytime/events{/privacy}","received_events_url":"https://api.github.com/users/rallytime/received_events","type":"User","site_admin":false},"created_at":"2016-08-30T17:59:39Z","updated_at":"2016-08-30T17:59:39Z","body":"I am not sure if this is a regression or not. It would be good to get some tests written for this issue."}}
{"actor":{"display_login":"rallytime"}}