Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restapi: incorrect href for parent href #549

Merged
merged 1 commit into from
Sep 18, 2022

Conversation

ArtiomDivak
Copy link
Member

@ArtiomDivak ArtiomDivak commented Jul 24, 2022

If User send REST API request for ovirt-engine/api/disks/{diskid}/disksnapshots?include_active&include_template he will get this incorrect href back <parent href="/ovirt-engine/api/disks/{diskid}" id="{parentid}"/>.
Now it will get correct output that will look like this <parent href="/ovirt-engine/api/disks/{parentdiskid}/disksnapshots/{parentid}" id="{parentid}"/>.

Bug-Url: https://bugzilla.redhat.com/2013697
Signed-off-by: Artiom Divak adivak@redhat.com

@mkemel
Copy link
Member

mkemel commented Jul 24, 2022

Additional info: Note that when 'include_template' flag is requested, and one of the disk_snapshots have a template disk as a parent (as described here https://bugzilla.redhat.com/1900597) - this template disk snapshot belongs to another disk, thus the href should be built accordingly.

Have you checked this scenario?
In this case, the parent snapshot will have another diskId, thus the URL will be incorrect.

@ArtiomDivak ArtiomDivak self-assigned this Jul 25, 2022
@sandrobonazzola sandrobonazzola added this to the ovirt-4.5.2 milestone Jul 27, 2022
@smelamud
Copy link
Member

smelamud commented Aug 3, 2022

As I see, similar change is already done by b1579af

@ahadas
Copy link
Member

ahadas commented Aug 3, 2022

As I see, similar change is already done by b1579af

right, that was for a particular snapshot and this one is for a collection of snapshots

Copy link
Member

@mkemel mkemel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note, that the href of the <disk_snapshot> element is also incorrect. It's not described in the bug, but maybe makes sense to fix that as well.

Copy link
Member

@mkemel mkemel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit more readable, but I still think you should do the mapper.map(disk, null) thing once for each Disk entity, and then work with a list of DiskSnapshots

@ArtiomDivak ArtiomDivak force-pushed the bug-2013697 branch 2 times, most recently from 643d418 to 38c254b Compare September 1, 2022 09:49
@mkemel
Copy link
Member

mkemel commented Sep 1, 2022

much better now, thanks minor comments inside I'm still not convinced that we should set the parent link to the template's image when include-template is not set - until now I only thought if it's a proper design but now I wonder if it could lead to backward compatibility issues for clients that use that link (they'll see a link to an image that is not returned). @ArtiomDivak @mkemel @bennyz @barpavel what do you think?

I think that this link is intended to fetch a specific disksnapshot. Thus returning it when include_template is not set makes even more sense - we don't have the parent image here in the returned array of disksnapshots, but here's a correct link that you can fetch it with. Also don't think that there would be any backward compatibility issues, since this href was never correct anyway.

@ahadas
Copy link
Member

ahadas commented Sep 1, 2022

Also don't think that there would be any backward compatibility issues, since this href was never correct anyway.

@mkemel so previously when include-template was not set we set an incorrect href for the parent of the top-level volume? wasn't it empty?

@mkemel
Copy link
Member

mkemel commented Sep 1, 2022

@mkemel so previously when include-template was not set we set an incorrect href for the parent of the top-level volume? wasn't it empty?

No, it wasn't empty. The parent ID is always there, it's just that the URL is built incorrectly.
BTW, include_template is a fairly new feature, and was added exactly as a solution to the fact that parent pointed to a disksnapshot not in the list.

@ahadas
Copy link
Member

ahadas commented Sep 1, 2022

No, it wasn't empty. The parent ID is always there, it's just that the URL is built incorrectly.

ack, in this case, it's really a bug fix more than an enhancement that users can complain about, ok.

Copy link
Member

@ahadas ahadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another minor comment, besides that lgm

@ahadas
Copy link
Member

ahadas commented Sep 1, 2022

/ost

1 similar comment
@ArtiomDivak
Copy link
Member Author

/ost

@ahadas
Copy link
Member

ahadas commented Sep 4, 2022

@oliel , @mwperina , can you please take a look?

@barpavel barpavel self-requested a review September 8, 2022 13:21
If User send REST API request  for ovirt-engine/api/disks/{diskid}/disksnapshots?include_active&include_template he will get this  incorrect href back <parent href="/ovirt-engine/api/disks/{diskid}" id="{parentid}"/>.
Now it will get correct output that will look like this <parent href="/ovirt-engine/api/disks/{diskid}/disksnapshots/{parentid}" id="{parentid}"/>.

Bug-Url: https://bugzilla.redhat.com/2013697
Signed-off-by: Artiom Divak <adivak@redhat.com>
Copy link
Member

@ahadas ahadas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ArtiomDivak I changed the code in GetDiskSnapshotByImageIdQuery to be a bit more null-safe, can you please check to see it still works so we'll get it in?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants