Open popey opened 1 month ago
BONUS almost certainly a related bug.
If you answer 'Y' to the Cancel build? [Y/n]
, it also fails! :D
~/Source/anchore/grype-snap/ > snapcraft remote-build --launchpad-accept-public-upload
remote-build is experimental and is subject to change. Use with caution.
Stopped: amd64,arm64,armhf,ppc64el,s390x / (3232.4s) Stopped: amd64,arm64,armhf,ppc64el,s390x / (5571.9s)
Cancel builds? [Y/n]: y
snapcraft internal error: HTTPError()
Here's the log.
2024-07-19 16:47:11.589 Emitter: Resuming control of the terminal
2024-07-19 16:47:11.589 Cancelling builds.
2024-07-19 16:47:11.591 snapcraft internal error: HTTPError()
2024-07-19 16:47:11.607 Traceback (most recent call last):
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/snapcraft/commands/remote.py", line 234, in _run
2024-07-19 16:47:11.607 returncode = self._monitor_and_complete(build_id, builds)
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/snapcraft/commands/remote.py", line 254, in _monitor_and_complete
2024-07-19 16:47:11.607 for states in builder.monitor_builds():
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_application/services/remotebuild.py", line 165, in monitor_builds
2024-07-19 16:47:11.607 states = self._get_build_states()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_application/services/remotebuild.py", line 368, in _get_build_states
2024-07-19 16:47:11.607 self._refresh_builds()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_application/services/remotebuild.py", line 374, in _refresh_builds
2024-07-19 16:47:11.607 build.lp_refresh()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_application/launchpad/models/base.py", line 184, in lp_refresh
2024-07-19 16:47:11.607 self._obj.lp_refresh()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/lazr/restfulclient/resource.py", line 811, in lp_refresh
2024-07-19 16:47:11.607 super(Entry, self).lp_refresh(new_url, etag)
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/lazr/restfulclient/resource.py", line 335, in lp_refresh
2024-07-19 16:47:11.607 representation = self._root._browser.get(
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/lazr/restfulclient/_browser.py", line 494, in get
2024-07-19 16:47:11.607 response, content = self._request(url, extra_headers=headers)
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/lazr/restfulclient/_browser.py", line 441, in _request
2024-07-19 16:47:11.607 response, content = self._request_and_retry(
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/lazr/restfulclient/_browser.py", line 400, in _request_and_retry
2024-07-19 16:47:11.607 response, content = self._connection.request(
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/httplib2/__init__.py", line 1692, in request
2024-07-19 16:47:11.607 (response, new_content) = self._request(
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/launchpadlib/launchpad.py", line 144, in _request
2024-07-19 16:47:11.607 response, content = super(LaunchpadOAuthAwareHttp, self)._request(
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/lazr/restfulclient/_browser.py", line 204, in _request
2024-07-19 16:47:11.607 return super(RestfulHttp, self)._request(
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/httplib2/__init__.py", line 1444, in _request
2024-07-19 16:47:11.607 (response, content) = self._conn_request(conn, request_uri, method, body, headers)
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/httplib2/__init__.py", line 1396, in _conn_request
2024-07-19 16:47:11.607 response = conn.getresponse()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/usr/lib/python3.10/http/client.py", line 1375, in getresponse
2024-07-19 16:47:11.607 response.begin()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/usr/lib/python3.10/http/client.py", line 318, in begin
2024-07-19 16:47:11.607 version, status, reason = self._read_status()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/usr/lib/python3.10/http/client.py", line 279, in _read_status
2024-07-19 16:47:11.607 line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/usr/lib/python3.10/socket.py", line 705, in readinto
2024-07-19 16:47:11.607 return self._sock.recv_into(b)
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/usr/lib/python3.10/ssl.py", line 1303, in recv_into
2024-07-19 16:47:11.607 return self.read(nbytes, buffer)
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/usr/lib/python3.10/ssl.py", line 1159, in read
2024-07-19 16:47:11.607 return self._sslobj.read(len, buffer)
2024-07-19 16:47:11.607 KeyboardInterrupt
2024-07-19 16:47:11.607
2024-07-19 16:47:11.607 During handling of the above exception, another exception occurred:
2024-07-19 16:47:11.607 Traceback (most recent call last):
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_application/application.py", line 530, in run
2024-07-19 16:47:11.607 return_code = dispatcher.run() or 0
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run
2024-07-19 16:47:11.607 return self._loaded_command.run(self._parsed_command_args)
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_application/commands/base.py", line 196, in run
2024-07-19 16:47:11.607 result = self._run(parsed_args, **kwargs) or result
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/snapcraft/commands/remote.py", line 238, in _run
2024-07-19 16:47:11.607 builder.cancel_builds()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_application/services/remotebuild.py", line 219, in cancel_builds
2024-07-19 16:47:11.607 build.cancel()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/craft_application/launchpad/models/build.py", line 127, in cancel
2024-07-19 16:47:11.607 self._obj.cancel()
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/lazr/restfulclient/resource.py", line 642, in __call__
2024-07-19 16:47:11.607 response, content = self.root._browser._request(
2024-07-19 16:47:11.607 File "/snap/snapcraft/12136/lib/python3.10/site-packages/lazr/restfulclient/_browser.py", line 465, in _request
2024-07-19 16:47:11.607 raise HTTPError(response, content)
2024-07-19 16:47:11.607 lazr.restfulclient.errors.HTTPError: HTTP Error 304: Not Modified
2024-07-19 16:47:11.607 Response headers:
2024-07-19 16:47:11.607 ---
2024-07-19 16:47:11.607 date: Fri, 19 Jul 2024 15:47:10 GMT
2024-07-19 16:47:11.607 etag: "9d289065e4626431521fd8b5197bea6fe86c3001-38332cb4d8dcd449cf45c3aa7d48937a74e75f5d"
2024-07-19 16:47:11.607 server: gunicorn
2024-07-19 16:47:11.607 status: 304
2024-07-19 16:47:11.607 vary: Accept
2024-07-19 16:47:11.607 ---
2024-07-19 16:47:11.607 Response body:
2024-07-19 16:47:11.607 ---
2024-07-19 16:47:11.607 b''
2024-07-19 16:47:11.607 ---
2024-07-19 16:47:11.608 Full execution log: '/home/alan/.local/state/snapcraft/log/snapcraft-20240719-150929.404271.log'
I can confirm this is a bug with this code block: https://github.com/canonical/snapcraft/blob/3325af0c585ec957e322db22216bf329a6701b6c/snapcraft/commands/remote.py#L233-L245
In addition to fixing this bug, using exit code constants from the os
module would make that code more readable.
Thank you for reporting us your feedback!
The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3140.
This message was autogenerated
Bug Description
snapcraft remote-build supports starting a remote-build from a client, killing snapcraft, then recovering/continuing the build from a different place.
In the past pressing ctrl-c on a remote build would just drop to the prompt. Now, you get asked to 'cleanup' with y/n options. Choose 'no' and it does the cleanup anyway, and terminates the remote build. This seems counterintuitive.
To Reproduce
snapcraft remote-build --launchpad-accept-public-upload
Cancel builds? [Y/n]:
prompt, say 'n'Snapcraft will say 'Cleaning up' and while doing so, the build will be killed in launchpad.
Environment
snapcraft.yaml
Additional context
We discussed this on 2024-07-19 at the snapcraft clinic.