Friday, 2024-08-09

opendevreviewRajat Dhasmana proposed openstack/glance stable/2023.2: Fix LP#2054575  https://review.opendev.org/c/openstack/glance/+/92602505:36
whoami-rajat_abhishekk, rosmaita can you also review this backport for 2023.2 ? ^05:37
abhishekkyeah I will, 05:37
whoami-rajat_thanks!05:49
abhishekknp!05:50
opendevreviewAbhishek Kekane proposed openstack/glance master: Add iso file format inspector  https://review.opendev.org/c/openstack/glance/+/92367615:09
abhishekkdansmith: replied to your comment on above patch, please have a look when you get time16:42
dansmithabhishekk: apply that test patch I showed and you'll see :)16:42
abhishekkack16:42
dansmithone of the cases gets caught with "format doesn't match" which is good (and we should have that case in the tests16:43
dansmiththe other one ends up with image.disk_format=qcow2 because we actually converted it16:43
abhishekkack Ideally it should also get caught in format inspection?16:50
dansmithformat_inspector will detect it's an iso, we just need to not allow it to ever proceed to conversion if it does16:51
dansmithand right now it will only stop if the user set disk_format to iso,16:51
dansmithif they lie about disk_format, we'll proceed further16:51
dansmithwe really need to make it so they can't ever lie.. basically disk_format *must* match format_inspector, else fail16:52
dansmithoh wait16:52
abhishekkhere we are mocking it to return iso every time16:52
dansmithno actually, it won't even be caught this way16:52
dansmithyeah, because glance isn't using the detection stuff, yeah16:52
dansmithso maybe best to convert it to use detect_file_format() like nova does now16:53
dansmithand just enforce source_format==str(inspector)16:53
dansmithand if they match and ==iso, then return16:53
abhishekkOk, need to see how nova is doing it16:54
dansmithI'll link you16:54
dansmithhttps://github.com/openstack/nova/blob/master/nova/virt/images.py#L16116:55
abhishekkI think first let me test it what happens if I provide iso image and set disk_format as qcow2 manually with this code16:55
abhishekkthanks16:56
dansmithabhishekk: sorry I should have realized this before I said the logic looks good16:56
dansmiththis whole thing is such a mess and will be better for everyone after glance refuses to let you upload X and call it Y I think16:57
abhishekkwait16:57
abhishekkglance image-create-via-import --container-format bare --disk-format qcow2 --stores cheap --file good.iso 16:57
abhishekk--name iso_as_qcow2_test16:57
abhishekkAug 09 16:54:41 akekane-uwsgi devstack@g-api.service[2088764]: ERROR glance.async_.taskflow_executor [-] Failed to execute task f81a5ef2-16e1-4305-bb94-59dec519d6a0: Image format detection failed: RuntimeError: Image format detection failed16:58
dansmithoh right, so it fails because you said it was a qcow2 but it's not16:58
abhishekkright16:58
dansmithbut what about saying it's raw, but with target_format=qcow2?16:58
abhishekkit will fail as well, let me check16:59
dansmithif I fix that in the test I still get the same two fails16:59
dansmither wait, no16:59
abhishekkhttps://paste.opendev.org/show/bxxyNBJWZtebBlHRQlFE/17:02
dansmithokay yeah, if I make it do the thing the runtime code will do, I still get the fail on the raw case but the qcow case is caught17:02
dansmithbecause raw file inspector will never fail17:03
dansmithright, but run with --disk_format=raw but target_format=qcow217:03
abhishekkohh, sorry, it was qcow2 17:04
dansmither, yeah output_format sorry17:04
abhishekkRight disk_format raw, output_format qcow2 and passing iso file as input is converting image to qcow217:05
* dansmith nods17:06
dansmithnow, I guess it is technically okay because we ran qemu-img -f raw, which means it won't interpret the file, but nova will think it's a qcow2 file and detect it as an iso, and then fail to boot and a user will wonder wtf17:07
dansmithso *maybe* not a big security concern, but still not right and pretty confusing I think17:08
abhishekkyeah17:08
dansmithnot sure whether it's best to fix that now (probably is) or just wait until we rebase on oslo when we are changing all of it17:08
abhishekkSo in this case detect_file_format will return it as ISO17:08
dansmithyes17:08
abhishekkI think better to fix it now so that we can backport it 17:09
dansmithack, sounds good17:09
abhishekkis it working for nova?17:13
abhishekkI am getting, Unknown error inspecting image format: 'str' object has no attribute 'safety_check': AttributeError: 'str' object has no attribute 'safety_check'17:13
dansmithI'd have to see your code, but yes17:15
abhishekkack, I just copied ISOInspector as it is from nova17:15
dansmithyeah, I mean show me what is giving you the str/safety_check error17:17
abhishekkinspector = format_inspector.detect_file_format(self.src_path)17:19
abhishekkif not inspector.safety_check():17:19
abhishekkthis line ^^17:19
dansmithabhishekk: your line 1011 is wrong, doesn't match nova's: https://github.com/openstack/nova/blob/master/nova/image/format_inspector.py#L102617:21
dansmithyou're appending format to the detections list instead of the actual inspector object17:21
abhishekklooking17:21
dansmithso you're getting back a string from detection if non-raw17:22
abhishekk:/17:22
dansmithright?17:23
abhishekkyeah, checking now again17:27
abhishekkdone, sorry for the mess17:27
dansmithall good, this stuff *is* a mess17:28
abhishekkagree, and thanks for taking care of it17:28
abhishekkwill push new PS tomorrow changing to use detect_from_file caused failure of 19 unit tests :D17:39
dansmithack17:40
abhishekkforgot that tomorrow is Saturday18:33
opendevreviewAbhishek Kekane proposed openstack/glance master: Add iso file format inspector  https://review.opendev.org/c/openstack/glance/+/92367618:35
opendevreviewGhanshyam proposed openstack/glance master: Remove default override for RBAC config options  https://review.opendev.org/c/openstack/glance/+/92608718:36

Generated by irclog2html.py 2.17.3 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!