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

hook fails on all Jenkins commands except quietDown and cancelQuietDown #91

Open
axinojolais opened this issue Aug 13, 2020 · 6 comments · Fixed by #93
Open

hook fails on all Jenkins commands except quietDown and cancelQuietDown #91

axinojolais opened this issue Aug 13, 2020 · 6 comments · Fixed by #93

Comments

@axinojolais
Copy link

Hello !

Perhaps I'm missing something obvious, because it's strange that no one saw that before ?

In the following block, the statement in the if cannot be true unless action is either quietDown or cancelQuietDown. So return will not be called, and the else statement from the try block will be executed, leading to a hook error.

try:
# Jenkins doesn't return an error for some actions
if (client.jenkins_open(request) and
(action == "quietDown" or action == "cancelQuietDown")):
return
except requests.exceptions.HTTPError as error:
self._check_response(error)
else:
raise RuntimeError(fail_message)

I'm not sure what the intent is here, will investigate and make a PR

@axinojolais axinojolais changed the title hook fails all Jenkins commands except quietDown and cancelQuietDown hook fails on all Jenkins commands except quietDown and cancelQuietDown Aug 13, 2020
@axinojolais
Copy link
Author

According to https://python-jenkins.readthedocs.io/en/latest/api.html, jenkins_open returns a str so I have no idea how the original version of _execute_action ever worked :

def _execute_action(self, action, fail_message):
client = self._make_client()
request = requests.Request("POST", urljoin(self.url, action))
try:
client.jenkins_open(request)
except requests.exceptions.HTTPError as error:
self._check_response(error)
else:
raise RuntimeError(fail_message)

@alejdg
Copy link
Contributor

alejdg commented Aug 13, 2020

All actions, except for those two, when executed return HTTPError. This is a "normal" behavior in Jenkins.

So when things happen as expected all actions will fall into the except part. Only when something different occurs the else will part will be executed.

@axinojolais
Copy link
Author

Well the action safeRestart on the Jenkins I'm looking at (version 2.235.1) doesn't return HTTPError so the raise RuntimeError is reached. Every single time.

@alejdg
Copy link
Contributor

alejdg commented Aug 18, 2020

@axinojolais maybe jenkins has changed the return for that action, possibly for all of them.

So this issue is definitely valid and we should check what implemented actions are failing due to that and add them to the same place as quietDown and cancelQuietDown:

(action == "quietDown" or action == "cancelQuietDown")):

ben-ballot added a commit to ben-ballot/jenkins-charm that referenced this issue Sep 3, 2020
@axinojolais
Copy link
Author

@mthaddon @darkalia I don't agree this is fixed. #93 only fixes safeRestart. What about the other commands ? Have we tested them ? Do they work ?

@ben-ballot
Copy link

ben-ballot commented Sep 15, 2020

@mthaddon @darkalia I don't agree this is fixed. #93 only fixes safeRestart. What about the other commands ? Have we tested them ? Do they work ?

I agree it's not fixed. It's only part of the fix to unstuck a situation.
My bad for using "Fixes: #91" in the commit message.
We should check for those commands as well:

  • restart
  • exit
  • safeExit

@mthaddon mthaddon reopened this Sep 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants