openSUSE / osc

The Command Line Interface to work with an Open Build Service
http://openbuildservice.org/
GNU General Public License v2.0
170 stars 183 forks source link

HTTP 400 causes osc to block #1514

Closed jengelh closed 6 months ago

jengelh commented 6 months ago

Describe the bug

When the OBS server responds with error 400, there is a wait incurred in osc.

Versions

To Reproduce

$ time osc -H co network:vpn/_meta
DEBUG: ----------------------------------------
DEBUG: GET https://api.opensuse.org/source/network:vpn/_meta/_meta
DEBUG: send: b'GET /source/network:vpn/_meta/_meta HTTP/1.1\r\nHost: api.opensuse.org\r\nAccept-Encoding: identity\r\nuser-agent: osc/1.6.1\r\nAccept: application/xml\r\n\r\n'
DEBUG: reply: 'HTTP/1.1 400 Bad Request\r\n'
DEBUG: header: Date: Tue, 12 Mar 2024 11:56:47 GMT
DEBUG: header: Server: Apache/2.4.51 (Linux/SUSE)
DEBUG: header: Strict-Transport-Security: max-age=31536000
DEBUG: header: cache-control: no-cache
DEBUG: header: vary: Accept,Accept-Encoding
DEBUG: header: referrer-policy: strict-origin-when-cross-origin
DEBUG: header: x-permitted-cross-domain-policies: none
DEBUG: header: x-xss-protection: 1; mode=block
DEBUG: header: x-opensuse-runtimes: {"view":0.44449465349316597,"db":2.3650050163269043,"backend":0}
DEBUG: header: x-request-id: 58d25c8c-d59a-4f1b-9dc5-802f4b788723
DEBUG: header: x-opensuse-apiversion: 2.11~alpha.20240312T104008.a4e76d08e
DEBUG: header: x-download-options: noopen
DEBUG: header: x-runtime: 0.009379
DEBUG: header: x-frame-options: SAMEORIGIN
DEBUG: header: x-content-type-options: nosniff
DEBUG: header: x-opensuse-errorcode: invalid_package_name
DEBUG: header: x-powered-by: Phusion Passenger(R)
DEBUG: header: status: 400 Bad Request
DEBUG: header: content-type: application/xml; charset=utf-8
DEBUG: header: Connection: close
DEBUG: header: Transfer-Encoding: chunked
DEBUG: send: b'GET /source/network:vpn/_meta/_meta HTTP/1.1\r\nHost: api.opensuse.org\r\nAccept-Encoding: identity\r\nuser-agent: osc/1.6.1\r\nAccept: application/xml\r\n\r\n'
DEBUG: reply: 'HTTP/1.1 400 Bad Request\r\n'
DEBUG: header: Date: Tue, 12 Mar 2024 11:56:47 GMT
DEBUG: header: Server: Apache/2.4.51 (Linux/SUSE)
DEBUG: header: Strict-Transport-Security: max-age=31536000
DEBUG: header: cache-control: no-cache
DEBUG: header: vary: Accept,Accept-Encoding
DEBUG: header: referrer-policy: strict-origin-when-cross-origin
DEBUG: header: x-permitted-cross-domain-policies: none
DEBUG: header: x-xss-protection: 1; mode=block
DEBUG: header: x-opensuse-runtimes: {"view":0.46945735812187195,"db":3.0157570838928223,"backend":0}
DEBUG: header: x-request-id: 43d5f2e8-e9ec-4252-9661-4e03127c2ae8
DEBUG: header: x-opensuse-apiversion: 2.11~alpha.20240312T104008.a4e76d08e
DEBUG: header: x-download-options: noopen
DEBUG: header: x-runtime: 0.010871
DEBUG: header: x-frame-options: SAMEORIGIN
DEBUG: header: x-content-type-options: nosniff
DEBUG: header: x-opensuse-errorcode: invalid_package_name
DEBUG: header: x-powered-by: Phusion Passenger(R)
DEBUG: header: status: 400 Bad Request
DEBUG: header: content-type: application/xml; charset=utf-8
DEBUG: header: Connection: close
DEBUG: header: Transfer-Encoding: chunked

<there is a wait here>

DEBUG: send: b'GET /source/network:vpn/_meta/_meta HTTP/1.1\r\nHost: api.opensuse.org\r\nAccept-Encoding: identity\r\nuser-agent: osc/1.6.1\r\nAccept: application/xml\r\n\r\n'
DEBUG: reply: 'HTTP/1.1 400 Bad Request\r\n'
DEBUG: header: Date: Tue, 12 Mar 2024 11:56:51 GMT
DEBUG: header: Server: Apache/2.4.51 (Linux/SUSE)
DEBUG: header: Strict-Transport-Security: max-age=31536000
DEBUG: header: cache-control: no-cache
DEBUG: header: vary: Accept,Accept-Encoding
DEBUG: header: referrer-policy: strict-origin-when-cross-origin
DEBUG: header: x-permitted-cross-domain-policies: none
DEBUG: header: x-xss-protection: 1; mode=block
DEBUG: header: x-opensuse-runtimes: {"view":0.686675775796175,"db":3.5206174850463867,"backend":0}
DEBUG: header: x-request-id: e6dccfd5-8e8a-44b9-9e03-7300312f03d3
DEBUG: header: x-opensuse-apiversion: 2.11~alpha.20240312T104008.a4e76d08e
DEBUG: header: x-download-options: noopen
DEBUG: header: x-runtime: 0.013611
DEBUG: header: x-frame-options: SAMEORIGIN
DEBUG: header: x-content-type-options: nosniff
DEBUG: header: x-opensuse-errorcode: invalid_package_name
DEBUG: header: x-powered-by: Phusion Passenger(R)
DEBUG: header: status: 400 Bad Request
DEBUG: header: content-type: application/xml; charset=utf-8
DEBUG: header: Connection: close
DEBUG: header: Transfer-Encoding: chunked

<there is a wait here>

DEBUG: send: b'GET /source/network:vpn/_meta/_meta HTTP/1.1\r\nHost: api.opensuse.org\r\nAccept-Encoding: identity\r\nuser-agent: osc/1.6.1\r\nAccept: application/xml\r\n\r\n'
DEBUG: reply: 'HTTP/1.1 400 Bad Request\r\n'
DEBUG: header: Date: Tue, 12 Mar 2024 11:56:59 GMT
DEBUG: header: Server: Apache/2.4.51 (Linux/SUSE)
DEBUG: header: Strict-Transport-Security: max-age=31536000
DEBUG: header: cache-control: no-cache
DEBUG: header: vary: Accept,Accept-Encoding
DEBUG: header: referrer-policy: strict-origin-when-cross-origin
DEBUG: header: x-permitted-cross-domain-policies: none
DEBUG: header: x-xss-protection: 1; mode=block
DEBUG: header: x-opensuse-runtimes: {"view":0.8732122369110584,"db":3.512157917022705,"backend":0}
DEBUG: header: x-request-id: a1607e99-ae5c-4c85-ad46-b74ccae03b55
DEBUG: header: x-opensuse-apiversion: 2.11~alpha.20240312T104008.a4e76d08e
DEBUG: header: x-download-options: noopen
DEBUG: header: x-runtime: 0.011785
DEBUG: header: x-frame-options: SAMEORIGIN
DEBUG: header: x-content-type-options: nosniff
DEBUG: header: x-opensuse-errorcode: invalid_package_name
DEBUG: header: x-powered-by: Phusion Passenger(R)
DEBUG: header: status: 400 Bad Request
DEBUG: header: content-type: application/xml; charset=utf-8
DEBUG: header: Connection: close
DEBUG: header: Transfer-Encoding: chunked
Server returned an error: HTTP Error 400: Bad Request
Error getting meta for project 'network:vpn' package '_meta'
invalid package name '_meta'

real    0m12.594s
user    0m0.320s
sys     0m0.035s

Expected outcome

Fail faster (like, 1s rather than 12s).

dmach commented 6 months ago

This is how good intentions backfire. The wait/retry is there because working with packages that have running services also end up with 400 and a retry seemed to be a reasonable fix. Let me try to fix it properly.

Related: #722 #1306