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

Rebuild does not return root_password #181

Closed
pchandra19 opened this issue Mar 23, 2023 · 4 comments · Fixed by #276
Closed

Rebuild does not return root_password #181

pchandra19 opened this issue Mar 23, 2023 · 4 comments · Fixed by #276
Labels
bug Something isn't working
Milestone

Comments

@pchandra19
Copy link

pchandra19 commented Mar 23, 2023

Bug Report

Current Behavior
'Rebuild' returns the BoundAction but does not return the "root_password"

Input Code

server = self.client.servers.get_by_name(name='server')
res = server.rebuild(Image(id='image_id'))
print(res)

Expected behavior/code
The 'rebuild' should return the root_password along with the BoundAction.
The response from the Hetzner API is below ( See possible solution)

Environment

  • Python Version: 3.11.2
  • Hcloud-Python Version: 1.18.2

Possible Solution

{
  "action": {
    "command": "rebuild_server",
    "error": {
      "code": "action_failed",
      "message": "Action failed"
    },
    "finished": null,
    "id": 13,
    "progress": 0,
    "resources": [
      {
        "id": 42,
        "type": "server"
      }
    ],
    "started": "2016-01-30T23:50:00+00:00",
    "status": "running"
  },
  "root_password": null
}

Additional context/Screenshots
Add any other context about the problem here. If applicable, add screenshots to help explain.

@github-actions
Copy link

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

@github-actions github-actions bot added the Stale label Jun 22, 2023
@apricote apricote removed the Stale label Jun 22, 2023
@jooola jooola added this to the v2.0.0 milestone Jul 18, 2023
@jooola jooola added the bug Something isn't working label Jul 18, 2023
@jooola
Copy link
Member

jooola commented Jul 18, 2023

I am not sure if there is a way to fix this without breaking the existing API.

The server rebuild method currently returns a BoundAction, to include the new root password, we will need to wrap the previously returned action in a RebuildResponse, including both the action and the root_password.

@apricote
Copy link
Member

We had this exact issue in hcloud-go: hetznercloud/hcloud-go#245

  • We added a new method that returns the proper response
  • changed the old method to call the new one and modify the return value to stay consistent
  • mark the old method as deprecated

@github-actions
Copy link

This issue has been marked as stale because it has not had recent activity. The bot will close the issue if no further action occurs.

@github-actions github-actions bot added the Stale label Oct 17, 2023
@jooola jooola removed the Stale label Oct 17, 2023
jooola added a commit that referenced this issue Nov 17, 2023
Fixes #181

Allow returning a full response during the server rebuild by passing an
option to the rebuild method. The main reason for this is to not break
user land and give users time to upgrade. We also don't want to
introduce a new method `rebuild2` or `rebuild_with_full_response` to
keep the API clean.

The deprecation timeline is the following:
- Introduce the `return_response` argument and deprecated the default
behavior (`return_response=False`)
- Wait for the next major release to remove the ability to only return
the action and deprecated the usage of the `return_response` argument.
- Wait for the next+1 major release to fully remove the
`return_response` argument, or simply leave it unused.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants