)]}'
{"openstack/cloud/_compute.py":[{"author":{"_account_id":15334,"name":"Stephen Finucane","display_name":"stephenfin","email":"stephenfin@redhat.com","username":"sfinucan"},"change_message_id":"65c97432d3761efd72cd2b737b0ca189a0232123","unresolved":true,"context_lines":[{"line_number":809,"context_line":"                    \" on the cloud\".format(group\u003dgroup))"},{"line_number":810,"context_line":"            kwargs[\u0027scheduler_hints\u0027] \u003d {"},{"line_number":811,"context_line":"                \u0027group\u0027: group_obj[\u0027id\u0027]"},{"line_number":812,"context_line":"            }"},{"line_number":813,"context_line":""},{"line_number":814,"context_line":"        kwargs.setdefault(\u0027max_count\u0027, kwargs.get(\u0027max_count\u0027, 1))"},{"line_number":815,"context_line":"        kwargs.setdefault(\u0027min_count\u0027, kwargs.get(\u0027min_count\u0027, 1))"}],"source_content_type":"text/x-python","patch_set":1,"id":"311adbd4_6f8fbc23","line":812,"updated":"2022-11-25 17:27:43.000000000","message":"If I enable debugging, I see that this is definitely incorrect and the group scheduler hint doesn\u0027t get passed to the server.\n\n  \u003e\u003e\u003e import openstack\n  \u003e\u003e\u003e conn \u003d openstack.connect()\n  \u003e\u003e\u003e server_group \u003d conn.create_server_group(\n  ...     \u0027foo-server-group\u0027,\n  ...     policy\u003d\u0027anti-affinity\u0027,\n  ... )\n  \u003e\u003e\u003e openstack.enable_logging(debug\u003dTrue)\n  \u003e\u003e\u003e server \u003d conn.create_server(\n  ...     \u0027foo\u0027,\n  ...      image\u003d\u0027cirros-0.5.2-x86_64-disk\u0027,\n  ...      flavor\u003d\u0027m1.tiny\u0027,\n  ...      network\u003d\u0027public\u0027,\n  ...      group\u003dserver_group,\n  ...      scheduler_hints\u003d{\u0027different_host\u0027: []},\n  ...      wait\u003dTrue,\n  ...  )\n  ... # lots of omitted output\n  REQ: curl -g -i -X POST http://10.0.109.180/compute/v2.1/servers -H \"Content-Type: application/json\" -H \"OpenStack-API-Version: compute 2.73\" -H \"User-Agent: openstacksdk/0.102.1 keystoneauth1/5.1.0 python-requests/2.28.1 CPython/3.8.15\" -H \"X-Auth-Token: {SHA256}cc0ee0397e3123d90cbdc4632af61f80a600ab091ab2444eb804edc8aa18fa55\" -H \"X-OpenStack-Nova-API-Version: 2.73\" -d \u0027{\"server\": {\"flavorRef\": \"1\", \"max_count\": 1, \"min_count\": 1, \"networks\": [{\"uuid\": \"1207f309-02d5-40f7-bd37-90f08facf895\"}], \"name\": \"foo\", \"imageRef\": \"6609a3f9-cfae-46f8-84ba-90af41f0977f\"}}\u0027\n  ... # more omitted output\n  \u003e\u003e\u003e server.delete(conn.compute)\n\nHowever, this fix still isn\u0027t correct. You\u0027ll see in the above that I\u0027m passing a \u0027scheduler_hints\u0027 keyword. Based on the previous code, I\u0027d expect these to get combined. That isn\u0027t happening.\n\n  REQ: curl -g -i -X POST http://10.0.109.180/compute/v2.1/servers -H \"Content-Type: application/json\" -H \"OpenStack-API-Version: compute 2.73\" -H \"User-Agent: openstacksdk/0.102.1 keystoneauth1/5.1.0 python-requests/2.28.1 CPython/3.8.15\" -H \"X-Auth-Token: {SHA256}4b70091bc538d8cb139786bb3558000cd6ba1d62870f836671b3b5eaa6f6d4ac\" -H \"X-OpenStack-Nova-API-Version: 2.73\" -d \u0027{\"server\": {\"name\": \"foo\", \"min_count\": 1, \"networks\":\n [{\"uuid\": \"1207f309-02d5-40f7-bd37-90f08facf895\"}], \"imageRef\": \"6609a3f9-cfae-46f8-84ba-90af41f0977f\", \"max_count\": 1, \"flavorRef\": \"1\"}, \"OS-SCH-HNT:scheduler_hints\": {\"group\": \"eb1a8f8f-b8bd-4593-9a76-c147ac361c45\"}}\u0027\n\nThe relevant bit is this:\n\n  \"OS-SCH-HNT:scheduler_hints\": {\"group\": \"eb1a8f8f-b8bd-4593-9a76-c147ac361c45\"}\n\nThat should look like:\n\n  \"OS-SCH-HNT:scheduler_hints\": {\"group\": \"eb1a8f8f-b8bd-4593-9a76-c147ac361c45\", \"different_host\": []}\n\nSomething like this should do the trick:\n\n  if \u0027scheduler_hints\u0027 not in kwargs:\n      kwargs[\u0027scheduler_hints\u0027] \u003d {}\n  kwargs[\u0027scheduler_hints\u0027][\u0027group\u0027] \u003d group_obj[\u0027id\u0027]\n\nCan you address this and add unit tests? Unit tests would be helpful to (a) prove the fix and (b) prevent regressions.","commit_id":"1e6144fb3ed6cd706336c256d8352a9c54870979"},{"author":{"_account_id":35573,"name":"Patrik Lundin","email":"patlu@sunet.se","username":"eest"},"change_message_id":"de2eba85bed9ccb340b6a81bd9229015c92be7c8","unresolved":false,"context_lines":[{"line_number":809,"context_line":"                    \" on the cloud\".format(group\u003dgroup))"},{"line_number":810,"context_line":"            kwargs[\u0027scheduler_hints\u0027] \u003d {"},{"line_number":811,"context_line":"                \u0027group\u0027: group_obj[\u0027id\u0027]"},{"line_number":812,"context_line":"            }"},{"line_number":813,"context_line":""},{"line_number":814,"context_line":"        kwargs.setdefault(\u0027max_count\u0027, kwargs.get(\u0027max_count\u0027, 1))"},{"line_number":815,"context_line":"        kwargs.setdefault(\u0027min_count\u0027, kwargs.get(\u0027min_count\u0027, 1))"}],"source_content_type":"text/x-python","patch_set":1,"id":"84a3336a_1a197a6c","line":812,"in_reply_to":"311adbd4_6f8fbc23","updated":"2022-11-28 13:44:02.000000000","message":"Thanks for the review! You are correct, I had misunderstood the expected override-behaviour and of course it makes sense that only the \"group\" key is overridden if necessary. I have uploaded a modified diff based on your suggestion which also includes tests.\n\nWould appreciate some extra eyes on the testt as I think they are correct (and have verified them with tox -e py310 -- -n unit/cloud/test_create_server.py) but I am not sure they are are looking as expected. One thing about them that left me scratching my head for a while is that the call to self.cloud.create_server(scheduler_hints\u003dmy_hints, group\u003dmy_group) will result in \"my_hints\" being overwritten by the group lookup. Not sure if this is expected behaviour or not.\n\nFinally, i mistakenly opened a new issue because of a broken character when trying to credit you as co-athour, i have abandoned that change but let me know if i should do something more: https://review.opendev.org/c/openstack/openstacksdk/+/865828","commit_id":"1e6144fb3ed6cd706336c256d8352a9c54870979"}]}
