* [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors
@ 2021-02-22 19:32 Cleber Rosa
2021-02-22 19:32 ` [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET Cleber Rosa
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Cleber Rosa @ 2021-02-22 19:32 UTC (permalink / raw)
To: qemu-devel
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Alex Bennée, Cleber Rosa, Andrea Bolognani,
Wainer dos Santos Moschetta, Willian Rampazzo, Stefan Hajnoczi,
Philippe Mathieu-Daudé,
Beraldo Leal
When things go wrong with the GitLab API requests, it's useful to give
users more information about the possible causes.
Cleber Rosa (3):
scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET
scripts/ci/gitlab-pipeline-status: give more information on failures
scripts/ci/gitlab-pipeline-status: give more info when pipeline not
found
scripts/ci/gitlab-pipeline-status | 25 ++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)
--
2.25.4
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET
2021-02-22 19:32 [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Cleber Rosa
@ 2021-02-22 19:32 ` Cleber Rosa
2021-02-23 14:38 ` Wainer dos Santos Moschetta
2021-02-23 18:09 ` Alex Bennée
2021-02-22 19:32 ` [PATCH 2/3] scripts/ci/gitlab-pipeline-status: give more information on failures Cleber Rosa
` (3 subsequent siblings)
4 siblings, 2 replies; 13+ messages in thread
From: Cleber Rosa @ 2021-02-22 19:32 UTC (permalink / raw)
To: qemu-devel
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Alex Bennée, Cleber Rosa, Andrea Bolognani,
Wainer dos Santos Moschetta, Willian Rampazzo, Stefan Hajnoczi,
Philippe Mathieu-Daudé,
Beraldo Leal
This simply splits out the code that does an HTTP GET so that it
can be used for other API requests.
Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
scripts/ci/gitlab-pipeline-status | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status
index 78e72f6008..0c1e8bd8a7 100755
--- a/scripts/ci/gitlab-pipeline-status
+++ b/scripts/ci/gitlab-pipeline-status
@@ -48,18 +48,25 @@ def get_local_branch_commit(branch):
return result
-def get_pipeline_status(project_id, commit_sha1):
+def get_json_http_response(url):
"""
- Returns the JSON content of the pipeline status API response
+ Returns the JSON content of an HTTP GET request to gitlab.com
"""
- url = '/api/v4/projects/{}/pipelines?sha={}'.format(project_id,
- commit_sha1)
connection = http.client.HTTPSConnection('gitlab.com')
connection.request('GET', url=url)
response = connection.getresponse()
if response.code != http.HTTPStatus.OK:
raise CommunicationFailure("Failed to receive a successful response")
- json_response = json.loads(response.read())
+ return json.loads(response.read())
+
+
+def get_pipeline_status(project_id, commit_sha1):
+ """
+ Returns the JSON content of the pipeline status API response
+ """
+ url = '/api/v4/projects/{}/pipelines?sha={}'.format(project_id,
+ commit_sha1)
+ json_response = get_json_http_response(url)
# As far as I can tell, there should be only one pipeline for the same
# project + commit. If this assumption is false, we can add further
--
2.25.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/3] scripts/ci/gitlab-pipeline-status: give more information on failures
2021-02-22 19:32 [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Cleber Rosa
2021-02-22 19:32 ` [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET Cleber Rosa
@ 2021-02-22 19:32 ` Cleber Rosa
2021-02-23 14:40 ` Wainer dos Santos Moschetta
2021-02-23 18:09 ` Alex Bennée
2021-02-22 19:32 ` [PATCH 3/3] scripts/ci/gitlab-pipeline-status: give more info when pipeline not found Cleber Rosa
` (2 subsequent siblings)
4 siblings, 2 replies; 13+ messages in thread
From: Cleber Rosa @ 2021-02-22 19:32 UTC (permalink / raw)
To: qemu-devel
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Alex Bennée, Cleber Rosa, Andrea Bolognani,
Wainer dos Santos Moschetta, Willian Rampazzo, Stefan Hajnoczi,
Philippe Mathieu-Daudé,
Beraldo Leal
When an HTTP GET request fails, it's useful to go beyond the "not
successful" message, and show the code returned by the server.
Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
scripts/ci/gitlab-pipeline-status | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status
index 0c1e8bd8a7..ad62ab3cfc 100755
--- a/scripts/ci/gitlab-pipeline-status
+++ b/scripts/ci/gitlab-pipeline-status
@@ -56,7 +56,9 @@ def get_json_http_response(url):
connection.request('GET', url=url)
response = connection.getresponse()
if response.code != http.HTTPStatus.OK:
- raise CommunicationFailure("Failed to receive a successful response")
+ msg = "Received unsuccessful response: %s (%s)" % (response.code,
+ response.reason)
+ raise CommunicationFailure(msg)
return json.loads(response.read())
--
2.25.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/3] scripts/ci/gitlab-pipeline-status: give more info when pipeline not found
2021-02-22 19:32 [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Cleber Rosa
2021-02-22 19:32 ` [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET Cleber Rosa
2021-02-22 19:32 ` [PATCH 2/3] scripts/ci/gitlab-pipeline-status: give more information on failures Cleber Rosa
@ 2021-02-22 19:32 ` Cleber Rosa
2021-02-23 14:43 ` Wainer dos Santos Moschetta
2021-02-23 14:52 ` [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Wainer dos Santos Moschetta
2021-03-03 17:54 ` Thomas Huth
4 siblings, 1 reply; 13+ messages in thread
From: Cleber Rosa @ 2021-02-22 19:32 UTC (permalink / raw)
To: qemu-devel
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Alex Bennée, Cleber Rosa, Andrea Bolognani,
Wainer dos Santos Moschetta, Willian Rampazzo, Stefan Hajnoczi,
Philippe Mathieu-Daudé,
Beraldo Leal
This includes both input parameters (project id and commit) in the
message so to make it easier to debug returned API calls.
Signed-off-by: Cleber Rosa <crosa@redhat.com>
---
scripts/ci/gitlab-pipeline-status | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status
index ad62ab3cfc..924db327ff 100755
--- a/scripts/ci/gitlab-pipeline-status
+++ b/scripts/ci/gitlab-pipeline-status
@@ -74,7 +74,9 @@ def get_pipeline_status(project_id, commit_sha1):
# project + commit. If this assumption is false, we can add further
# filters to the url, such as username, and order_by.
if not json_response:
- raise NoPipelineFound("No pipeline found")
+ msg = "No pipeline found for project %s and commit %s" % (project_id,
+ commit_sha1)
+ raise NoPipelineFound(msg)
return json_response[0]
--
2.25.4
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET
2021-02-22 19:32 ` [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET Cleber Rosa
@ 2021-02-23 14:38 ` Wainer dos Santos Moschetta
2021-02-23 18:09 ` Alex Bennée
1 sibling, 0 replies; 13+ messages in thread
From: Wainer dos Santos Moschetta @ 2021-02-23 14:38 UTC (permalink / raw)
To: Cleber Rosa, qemu-devel
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Philippe Mathieu-Daudé,
Andrea Bolognani, Willian Rampazzo, Stefan Hajnoczi,
Alex Bennée, Beraldo Leal
Hi,
On 2/22/21 4:32 PM, Cleber Rosa wrote:
> This simply splits out the code that does an HTTP GET so that it
> can be used for other API requests.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
> scripts/ci/gitlab-pipeline-status | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
Only fix the "utlity" typo in $SUBJECT:
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
>
> diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status
> index 78e72f6008..0c1e8bd8a7 100755
> --- a/scripts/ci/gitlab-pipeline-status
> +++ b/scripts/ci/gitlab-pipeline-status
> @@ -48,18 +48,25 @@ def get_local_branch_commit(branch):
> return result
>
>
> -def get_pipeline_status(project_id, commit_sha1):
> +def get_json_http_response(url):
> """
> - Returns the JSON content of the pipeline status API response
> + Returns the JSON content of an HTTP GET request to gitlab.com
> """
> - url = '/api/v4/projects/{}/pipelines?sha={}'.format(project_id,
> - commit_sha1)
> connection = http.client.HTTPSConnection('gitlab.com')
> connection.request('GET', url=url)
> response = connection.getresponse()
> if response.code != http.HTTPStatus.OK:
> raise CommunicationFailure("Failed to receive a successful response")
> - json_response = json.loads(response.read())
> + return json.loads(response.read())
> +
> +
> +def get_pipeline_status(project_id, commit_sha1):
> + """
> + Returns the JSON content of the pipeline status API response
> + """
> + url = '/api/v4/projects/{}/pipelines?sha={}'.format(project_id,
> + commit_sha1)
> + json_response = get_json_http_response(url)
>
> # As far as I can tell, there should be only one pipeline for the same
> # project + commit. If this assumption is false, we can add further
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] scripts/ci/gitlab-pipeline-status: give more information on failures
2021-02-22 19:32 ` [PATCH 2/3] scripts/ci/gitlab-pipeline-status: give more information on failures Cleber Rosa
@ 2021-02-23 14:40 ` Wainer dos Santos Moschetta
2021-02-23 18:09 ` Alex Bennée
1 sibling, 0 replies; 13+ messages in thread
From: Wainer dos Santos Moschetta @ 2021-02-23 14:40 UTC (permalink / raw)
To: Cleber Rosa, qemu-devel
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Philippe Mathieu-Daudé,
Andrea Bolognani, Willian Rampazzo, Stefan Hajnoczi,
Alex Bennée, Beraldo Leal
On 2/22/21 4:32 PM, Cleber Rosa wrote:
> When an HTTP GET request fails, it's useful to go beyond the "not
> successful" message, and show the code returned by the server.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
> scripts/ci/gitlab-pipeline-status | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
>
> diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status
> index 0c1e8bd8a7..ad62ab3cfc 100755
> --- a/scripts/ci/gitlab-pipeline-status
> +++ b/scripts/ci/gitlab-pipeline-status
> @@ -56,7 +56,9 @@ def get_json_http_response(url):
> connection.request('GET', url=url)
> response = connection.getresponse()
> if response.code != http.HTTPStatus.OK:
> - raise CommunicationFailure("Failed to receive a successful response")
> + msg = "Received unsuccessful response: %s (%s)" % (response.code,
> + response.reason)
> + raise CommunicationFailure(msg)
> return json.loads(response.read())
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/3] scripts/ci/gitlab-pipeline-status: give more info when pipeline not found
2021-02-22 19:32 ` [PATCH 3/3] scripts/ci/gitlab-pipeline-status: give more info when pipeline not found Cleber Rosa
@ 2021-02-23 14:43 ` Wainer dos Santos Moschetta
0 siblings, 0 replies; 13+ messages in thread
From: Wainer dos Santos Moschetta @ 2021-02-23 14:43 UTC (permalink / raw)
To: Cleber Rosa, qemu-devel
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Philippe Mathieu-Daudé,
Andrea Bolognani, Willian Rampazzo, Stefan Hajnoczi,
Alex Bennée, Beraldo Leal
On 2/22/21 4:32 PM, Cleber Rosa wrote:
> This includes both input parameters (project id and commit) in the
> message so to make it easier to debug returned API calls.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
> ---
> scripts/ci/gitlab-pipeline-status | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
>
> diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status
> index ad62ab3cfc..924db327ff 100755
> --- a/scripts/ci/gitlab-pipeline-status
> +++ b/scripts/ci/gitlab-pipeline-status
> @@ -74,7 +74,9 @@ def get_pipeline_status(project_id, commit_sha1):
> # project + commit. If this assumption is false, we can add further
> # filters to the url, such as username, and order_by.
> if not json_response:
> - raise NoPipelineFound("No pipeline found")
> + msg = "No pipeline found for project %s and commit %s" % (project_id,
> + commit_sha1)
> + raise NoPipelineFound(msg)
> return json_response[0]
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors
2021-02-22 19:32 [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Cleber Rosa
` (2 preceding siblings ...)
2021-02-22 19:32 ` [PATCH 3/3] scripts/ci/gitlab-pipeline-status: give more info when pipeline not found Cleber Rosa
@ 2021-02-23 14:52 ` Wainer dos Santos Moschetta
2021-02-23 15:19 ` Erik Skultety
2021-03-03 17:54 ` Thomas Huth
4 siblings, 1 reply; 13+ messages in thread
From: Wainer dos Santos Moschetta @ 2021-02-23 14:52 UTC (permalink / raw)
To: Cleber Rosa, qemu-devel
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Philippe Mathieu-Daudé,
Andrea Bolognani, Willian Rampazzo, Stefan Hajnoczi,
Alex Bennée, Beraldo Leal
Hi Cleber,
In case you need to send a v2, mind to add the following patch together?
commit 3c4ed8a78e096e4d7df0398c29887a9d468ae120 (HEAD -> gitlab_runners)
Author: Wainer dos Santos Moschetta <wainersm@redhat.com>
Date: Tue Feb 23 11:26:08 2021 -0300
scripts/ci/gitlab-pipeline-status: Handle ValueError exceptions nicely
With this change, when getting the local branch, it will handle nicely
any threw ValueError exception instead of print the stack trace.
Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
diff --git a/scripts/ci/gitlab-pipeline-status
b/scripts/ci/gitlab-pipeline-status
index 924db327ff..6177df973a 100755
--- a/scripts/ci/gitlab-pipeline-status
+++ b/scripts/ci/gitlab-pipeline-status
@@ -160,7 +160,11 @@ def main():
args = parser.parse_args()
if not args.commit:
- args.commit = get_local_branch_commit(args.branch)
+ try:
+ args.commit = get_local_branch_commit(args.branch)
+ except ValueError as error:
+ print("ERROR: %s" % error)
+ sys.exit(1)
success = False
try:
On 2/22/21 4:32 PM, Cleber Rosa wrote:
> When things go wrong with the GitLab API requests, it's useful to give
> users more information about the possible causes.
>
> Cleber Rosa (3):
> scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET
> scripts/ci/gitlab-pipeline-status: give more information on failures
> scripts/ci/gitlab-pipeline-status: give more info when pipeline not
> found
>
> scripts/ci/gitlab-pipeline-status | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors
2021-02-23 14:52 ` [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Wainer dos Santos Moschetta
@ 2021-02-23 15:19 ` Erik Skultety
2021-02-23 15:53 ` Wainer dos Santos Moschetta
0 siblings, 1 reply; 13+ messages in thread
From: Erik Skultety @ 2021-02-23 15:19 UTC (permalink / raw)
To: Wainer dos Santos Moschetta
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Stefan Hajnoczi,
Alex Bennée, Andrea Bolognani, qemu-devel, Willian Rampazzo,
Cleber Rosa, Philippe Mathieu-Daudé,
Beraldo Leal
On Tue, Feb 23, 2021 at 11:52:17AM -0300, Wainer dos Santos Moschetta wrote:
> Hi Cleber,
>
> In case you need to send a v2, mind to add the following patch together?
>
> commit 3c4ed8a78e096e4d7df0398c29887a9d468ae120 (HEAD -> gitlab_runners)
> Author: Wainer dos Santos Moschetta <wainersm@redhat.com>
> Date: Tue Feb 23 11:26:08 2021 -0300
>
> scripts/ci/gitlab-pipeline-status: Handle ValueError exceptions nicely
>
> With this change, when getting the local branch, it will handle nicely
> any threw ValueError exception instead of print the stack trace.
>
> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
>
> diff --git a/scripts/ci/gitlab-pipeline-status
> b/scripts/ci/gitlab-pipeline-status
> index 924db327ff..6177df973a 100755
> --- a/scripts/ci/gitlab-pipeline-status
> +++ b/scripts/ci/gitlab-pipeline-status
> @@ -160,7 +160,11 @@ def main():
> args = parser.parse_args()
>
> if not args.commit:
> - args.commit = get_local_branch_commit(args.branch)
> + try:
> + args.commit = get_local_branch_commit(args.branch)
> + except ValueError as error:
> + print("ERROR: %s" % error)
> + sys.exit(1)
1 is the default error code, so you should pass the error message to sys.exit
directly without the print. If you don't want that, at least redirect the
print to sys.stderr.
Erik
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors
2021-02-23 15:19 ` Erik Skultety
@ 2021-02-23 15:53 ` Wainer dos Santos Moschetta
0 siblings, 0 replies; 13+ messages in thread
From: Wainer dos Santos Moschetta @ 2021-02-23 15:53 UTC (permalink / raw)
To: Erik Skultety
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Stefan Hajnoczi,
Alex Bennée, Andrea Bolognani, qemu-devel, Willian Rampazzo,
Cleber Rosa, Philippe Mathieu-Daudé,
Beraldo Leal
Hi,
On 2/23/21 12:19 PM, Erik Skultety wrote:
> On Tue, Feb 23, 2021 at 11:52:17AM -0300, Wainer dos Santos Moschetta wrote:
>> Hi Cleber,
>>
>> In case you need to send a v2, mind to add the following patch together?
>>
>> commit 3c4ed8a78e096e4d7df0398c29887a9d468ae120 (HEAD -> gitlab_runners)
>> Author: Wainer dos Santos Moschetta <wainersm@redhat.com>
>> Date: Tue Feb 23 11:26:08 2021 -0300
>>
>> scripts/ci/gitlab-pipeline-status: Handle ValueError exceptions nicely
>>
>> With this change, when getting the local branch, it will handle nicely
>> any threw ValueError exception instead of print the stack trace.
>>
>> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>
>>
>> diff --git a/scripts/ci/gitlab-pipeline-status
>> b/scripts/ci/gitlab-pipeline-status
>> index 924db327ff..6177df973a 100755
>> --- a/scripts/ci/gitlab-pipeline-status
>> +++ b/scripts/ci/gitlab-pipeline-status
>> @@ -160,7 +160,11 @@ def main():
>> args = parser.parse_args()
>>
>> if not args.commit:
>> - args.commit = get_local_branch_commit(args.branch)
>> + try:
>> + args.commit = get_local_branch_commit(args.branch)
>> + except ValueError as error:
>> + print("ERROR: %s" % error)
>> + sys.exit(1)
> 1 is the default error code, so you should pass the error message to sys.exit
> directly without the print. If you don't want that, at least redirect the
> print to sys.stderr.
There are occurrences of the same pattern on the script, so I better
send a separate series to change them all. Thanks for pointing it out Erik!
- Wainer
>
> Erik
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET
2021-02-22 19:32 ` [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET Cleber Rosa
2021-02-23 14:38 ` Wainer dos Santos Moschetta
@ 2021-02-23 18:09 ` Alex Bennée
1 sibling, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2021-02-23 18:09 UTC (permalink / raw)
To: Cleber Rosa
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Stefan Hajnoczi, Andrea Bolognani, Wainer dos Santos Moschetta,
qemu-devel, Willian Rampazzo, Philippe Mathieu-Daudé,
Beraldo Leal
Cleber Rosa <crosa@redhat.com> writes:
> This simply splits out the code that does an HTTP GET so that it
> can be used for other API requests.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
fix sp as per Wainer, otherwise:
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> scripts/ci/gitlab-pipeline-status | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status
> index 78e72f6008..0c1e8bd8a7 100755
> --- a/scripts/ci/gitlab-pipeline-status
> +++ b/scripts/ci/gitlab-pipeline-status
> @@ -48,18 +48,25 @@ def get_local_branch_commit(branch):
> return result
>
>
> -def get_pipeline_status(project_id, commit_sha1):
> +def get_json_http_response(url):
> """
> - Returns the JSON content of the pipeline status API response
> + Returns the JSON content of an HTTP GET request to gitlab.com
> """
> - url = '/api/v4/projects/{}/pipelines?sha={}'.format(project_id,
> - commit_sha1)
> connection = http.client.HTTPSConnection('gitlab.com')
> connection.request('GET', url=url)
> response = connection.getresponse()
> if response.code != http.HTTPStatus.OK:
> raise CommunicationFailure("Failed to receive a successful response")
> - json_response = json.loads(response.read())
> + return json.loads(response.read())
> +
> +
> +def get_pipeline_status(project_id, commit_sha1):
> + """
> + Returns the JSON content of the pipeline status API response
> + """
> + url = '/api/v4/projects/{}/pipelines?sha={}'.format(project_id,
> + commit_sha1)
> + json_response = get_json_http_response(url)
>
> # As far as I can tell, there should be only one pipeline for the same
> # project + commit. If this assumption is false, we can add further
--
Alex Bennée
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/3] scripts/ci/gitlab-pipeline-status: give more information on failures
2021-02-22 19:32 ` [PATCH 2/3] scripts/ci/gitlab-pipeline-status: give more information on failures Cleber Rosa
2021-02-23 14:40 ` Wainer dos Santos Moschetta
@ 2021-02-23 18:09 ` Alex Bennée
1 sibling, 0 replies; 13+ messages in thread
From: Alex Bennée @ 2021-02-23 18:09 UTC (permalink / raw)
To: Cleber Rosa
Cc: Fam Zheng, Thomas Huth, Eduardo Habkost, Erik Skultety,
Stefan Hajnoczi, Andrea Bolognani, Wainer dos Santos Moschetta,
qemu-devel, Willian Rampazzo, Philippe Mathieu-Daudé,
Beraldo Leal
Cleber Rosa <crosa@redhat.com> writes:
> When an HTTP GET request fails, it's useful to go beyond the "not
> successful" message, and show the code returned by the server.
>
> Signed-off-by: Cleber Rosa <crosa@redhat.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> scripts/ci/gitlab-pipeline-status | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/ci/gitlab-pipeline-status b/scripts/ci/gitlab-pipeline-status
> index 0c1e8bd8a7..ad62ab3cfc 100755
> --- a/scripts/ci/gitlab-pipeline-status
> +++ b/scripts/ci/gitlab-pipeline-status
> @@ -56,7 +56,9 @@ def get_json_http_response(url):
> connection.request('GET', url=url)
> response = connection.getresponse()
> if response.code != http.HTTPStatus.OK:
> - raise CommunicationFailure("Failed to receive a successful response")
> + msg = "Received unsuccessful response: %s (%s)" % (response.code,
> + response.reason)
> + raise CommunicationFailure(msg)
> return json.loads(response.read())
--
Alex Bennée
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors
2021-02-22 19:32 [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Cleber Rosa
` (3 preceding siblings ...)
2021-02-23 14:52 ` [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Wainer dos Santos Moschetta
@ 2021-03-03 17:54 ` Thomas Huth
4 siblings, 0 replies; 13+ messages in thread
From: Thomas Huth @ 2021-03-03 17:54 UTC (permalink / raw)
To: Cleber Rosa, qemu-devel
Cc: Fam Zheng, Eduardo Habkost, Erik Skultety, Stefan Hajnoczi,
Andrea Bolognani, Wainer dos Santos Moschetta,
Philippe Mathieu-Daudé,
Willian Rampazzo, Alex Bennée, Beraldo Leal
On 22/02/2021 20.32, Cleber Rosa wrote:
> When things go wrong with the GitLab API requests, it's useful to give
> users more information about the possible causes.
>
> Cleber Rosa (3):
> scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET
> scripts/ci/gitlab-pipeline-status: give more information on failures
> scripts/ci/gitlab-pipeline-status: give more info when pipeline not
> found
>
> scripts/ci/gitlab-pipeline-status | 25 ++++++++++++++++++-------
> 1 file changed, 18 insertions(+), 7 deletions(-)
>
Thanks, I've queued the three patches now to my testing-next branch:
https://gitlab.com/thuth/qemu/-/commits/testing-next/
Thomas
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2021-03-03 17:55 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-22 19:32 [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Cleber Rosa
2021-02-22 19:32 ` [PATCH 1/3] scripts/ci/gitlab-pipeline-status: split utlity function for HTTP GET Cleber Rosa
2021-02-23 14:38 ` Wainer dos Santos Moschetta
2021-02-23 18:09 ` Alex Bennée
2021-02-22 19:32 ` [PATCH 2/3] scripts/ci/gitlab-pipeline-status: give more information on failures Cleber Rosa
2021-02-23 14:40 ` Wainer dos Santos Moschetta
2021-02-23 18:09 ` Alex Bennée
2021-02-22 19:32 ` [PATCH 3/3] scripts/ci/gitlab-pipeline-status: give more info when pipeline not found Cleber Rosa
2021-02-23 14:43 ` Wainer dos Santos Moschetta
2021-02-23 14:52 ` [PATCH 0/3] gitlab-pipeline-status script: provide more information on errors Wainer dos Santos Moschetta
2021-02-23 15:19 ` Erik Skultety
2021-02-23 15:53 ` Wainer dos Santos Moschetta
2021-03-03 17:54 ` Thomas Huth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).