-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Update lxd_container with new API endpoint #7854
Conversation
67a3c07
to
ae494d5
Compare
ae494d5
to
bd12c25
Compare
This comment was marked as outdated.
This comment was marked as outdated.
bd12c25
to
8d601dc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! Please add a changelog fragment. Thanks.
self.api_endpoint = '/1.0/containers' | ||
elif self.type == 'virtual-machine': | ||
self.api_endpoint = '/1.0/virtual-machines' | ||
self.api_endpoint = '/1.0/instances' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is likely a breaking change for older LXD versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LXD has supported this endpoint since v4.0 (LTS) released April 3, 2020: https://github.com/canonical/lxd/blob/lxd-4.0.0/doc/api-extensions.md (announcement)
I'm not sure what backwards compatibility guarantees community.general
makes or how best to preserve backwards compatibility with older versions. Can you provide guidance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LXD v3.0 LTS branch reached EOL in July 2023: https://discuss.linuxcontainers.org/t/lxc-lxd-lxcfs-3-0-end-of-life-announcement/17600
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The module unfortunately does not specify an explicit lower bound of the LXD versions it supports.
The best way would be to have some version detection and then a version based behavior selection (grep for LooseVersion
in this repo to see how version comparisons can be done). I would guess there is an API endpoint which allows you to get info on LXD itself, including its version, that can be used for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's currently breaking for pure LXD and not just Incus. With LXD version 5.19
@@ -547,6 +543,8 @@ def _create_instance(self): | |||
url_params['target'] = self.target | |||
if self.project: | |||
url_params['project'] = self.project | |||
if self.type: | |||
url_params['type'] = self.type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this also break older LXD versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have not explicitly tested it, but a quick peruse of the code suggests that unexpected query parameters are ignored: https://github.com/canonical/lxd/blob/cf9bf2ac072044118dfbd9d49f2342298a52c2d2/lxd/instances_get.go#L244
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be good.
CI is failing on files unrelated to this PR - I'm unsure how to resolve. |
The CI failure is unrelated, I fixed it in #7858 - it should go away on the next CI run. |
Hi, I see #7858 has been merged. Is it possible to run the CI on this PR in order to get it merged? Regards |
@antifob It sounds like the maintainers are looking for additional changes to support EOL'd versions of LXD, which I'm not in a position to test. I suggest if someone has the time to do so, they create a new PR. |
I understand the concern, but the currently-used API endpoints no longer exist so this module. @felixfontein It seems this module is currently broken and can't move forward because of deprecation concerns. Considering that it's the choice of users of deprecated LXD versions (if they even exist) to stay there, would adding a new |
@antifob I very well understand that the module is currently broken, but fixing it by breaking it for other users for which it currently works is not the solution. Please check out our guidelines: #582 (comment) / https://docs.ansible.com/ansible/devel/community/collection_contributors/collection_requirements.html#collections-requirements Adding an |
My attempt at fixing this issue #7980 it also fixes the placement of where |
SUMMARY
Fixes #7853
ISSUE TYPE
COMPONENT NAME
lxd_container
ADDITIONAL INFORMATION
https://documentation.ubuntu.com/lxd/en/latest/rest-api/#instances-containers-and-virtual-machines notes that
/1.0/instances
supports both containers and virtual machines.API docs can be found here:
Additional discussion here: https://discuss.linuxcontainers.org/t/ansible-guidance-receiving-errors-when-using-lxd-container-plugin/18734/8