Skip to content

feature: remove feed when swapping away from rollout#315

Merged
b-rowan merged 1 commit intomasterfrom
remove-feed-on-static-sw
Aug 19, 2025
Merged

feature: remove feed when swapping away from rollout#315
b-rowan merged 1 commit intomasterfrom
remove-feed-on-static-sw

Conversation

@b-rowan
Copy link
Copy Markdown
Member

@b-rowan b-rowan commented Jun 19, 2025

Fixes: #314

@b-rowan b-rowan requested a review from easybe June 19, 2025 15:14
@easybe
Copy link
Copy Markdown
Collaborator

easybe commented Aug 13, 2025

This does not seem to work with Postgres:

postgres-1  | 2025-08-13 09:44:46.014 UTC [42] ERROR:  syntax error at or near "PRAGMA" at character 1
postgres-1  | 2025-08-13 09:44:46.014 UTC [42] STATEMENT:  PRAGMA foreign_keys=off;
postgres-1  | 
postgres-1  |       CREATE TABLE "device_new" (
postgres-1  |           "id" CHAR(255) NOT NULL PRIMARY KEY,
postgres-1  |           "name" CHAR(255),
postgres-1  |           "assigned_software_id" INT,
postgres-1  |           "force_update" INT NOT NULL DEFAULT 0,
postgres-1  |           "sw_version" CHAR(255),
postgres-1  |           "hardware_id" INT NOT NULL,
postgres-1  |           "feed" CHAR(255) DEFAULT 'default',  -- NULL allowed here
postgres-1  |           "update_mode" INT NOT NULL DEFAULT 0,
postgres-1  |           "last_state" INT NOT NULL DEFAULT 0,
postgres-1  |           "progress" INT,
postgres-1  |           "last_log" TEXT,
postgres-1  |           "last_seen" BIGINT,
postgres-1  |           "last_ip" CHAR(15),
postgres-1  |           "last_ipv6" CHAR(40),
goosebit-1  | Traceback (most recent call last):
postgres-1  |           "auth_token" CHAR(32)
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/tortoise/backends/asyncpg/client.py", line 89, in _translate_exceptions
postgres-1  |       );
goosebit-1  |     return await func(self, *args, **kwargs)
postgres-1  | 
goosebit-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
postgres-1  |       INSERT INTO "device_new" SELECT
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/tortoise/backends/base_postgres/client.py", line 152, in execute_script
postgres-1  |           id, name, assigned_software_id, force_update, sw_version,
goosebit-1  |     await connection.execute(query)
postgres-1  |           hardware_id, feed, update_mode, last_state, progress,
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/asyncpg/connection.py", line 349, in execute
postgres-1  |           last_log, last_seen, last_ip, last_ipv6, auth_token
goosebit-1  |     result = await self._protocol.query(query, timeout)
postgres-1  |       FROM "device";
goosebit-1  |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
postgres-1  | 
goosebit-1  |   File "asyncpg/protocol/protocol.pyx", line 375, in query
postgres-1  |       DROP TABLE "device";
goosebit-1  | asyncpg.exceptions.PostgresSyntaxError: syntax error at or near "PRAGMA"
postgres-1  | 
goosebit-1  | 
postgres-1  |       ALTER TABLE "device_new" RENAME TO "device";
goosebit-1  | During handling of the above exception, another exception occurred:
postgres-1  | 
goosebit-1  | 
postgres-1  |       PRAGMA foreign_keys=on;
goosebit-1  | Traceback (most recent call last):
postgres-1  |       
goosebit-1  |   File "/usr/local/bin/aerich", line 8, in <module>
goosebit-1  |     sys.exit(main())
goosebit-1  |              ~~~~^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/aerich/cli.py", line 365, in main
goosebit-1  |     cli()
goosebit-1  |     ~~~^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1211, in __call__
goosebit-1  |     return anyio.run(self._main, main, args, kwargs, **opts)
goosebit-1  |            ~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/anyio/_core/_eventloop.py", line 74, in run
goosebit-1  |     return async_backend.run(func, args, {}, backend_options)
goosebit-1  |            ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2316, in run
goosebit-1  |     return runner.run(wrapper())
goosebit-1  |            ~~~~~~~~~~^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/asyncio/runners.py", line 118, in run
goosebit-1  |     return self._loop.run_until_complete(task)
goosebit-1  |            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/asyncio/base_events.py", line 725, in run_until_complete
goosebit-1  |     return future.result()
goosebit-1  |            ~~~~~~~~~~~~~^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/anyio/_backends/_asyncio.py", line 2304, in wrapper
goosebit-1  |     return await func(*args)
goosebit-1  |            ^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1214, in _main
goosebit-1  |     return await main(*args, **kwargs)
goosebit-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1126, in main
goosebit-1  |     rv = await self.invoke(ctx)
goosebit-1  |          ^^^^^^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1750, in invoke
goosebit-1  |     return await _process_result(await sub_ctx.command.invoke(sub_ctx))
goosebit-1  |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 1496, in invoke
goosebit-1  |     return await ctx.invoke(self.callback, **ctx.params)
goosebit-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/asyncclick/core.py", line 829, in invoke
goosebit-1  |     rv = await rv
goosebit-1  |          ^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/aerich/cli.py", line 142, in upgrade
goosebit-1  |     migrated = await command.upgrade(run_in_transaction=in_transaction, fake=fake)
goosebit-1  |                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/aerich/__init__.py", line 204, in upgrade
goosebit-1  |     await self._upgrade(conn, version_file, fake=fake)
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/aerich/__init__.py", line 186, in _upgrade
goosebit-1  |     await conn.execute_script(await upgrade(conn))
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/tortoise/backends/base_postgres/client.py", line 33, in _translate_exceptions
goosebit-1  |     return await self._translate_exceptions(func, *args, **kwargs)
goosebit-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
goosebit-1  |   File "/usr/local/lib/python3.13/site-packages/tortoise/backends/asyncpg/client.py", line 91, in _translate_exceptions
goosebit-1  |     raise OperationalError(exc)
goosebit-1  | tortoise.exceptions.OperationalError: syntax error at or near "PRAGMA"

To reproduce this, you can run:

sed -i '/docker/d' .dockerignore
docker build -t upstreamdata/goosebit -f docker/dev.dockerfile .
docker compose -f docker/demo/docker-compose.yml up

Copy link
Copy Markdown
Collaborator

@easybe easybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

@b-rowan
Copy link
Copy Markdown
Member Author

b-rowan commented Aug 13, 2025

Whats the best way to generate aerich migrations for these changes for postgres? The manual migrations there are for sqlite...

@easybe
Copy link
Copy Markdown
Collaborator

easybe commented Aug 13, 2025

Whats the best way to generate aerich migrations for these changes for postgres? The manual migrations there are for sqlite...

One option is to use Docker (docker compose -f docker/demo/docker-compose.yml up) and expose the DB port like this: husqvarnagroup@4044294

Then you can point gooseBit on your machine to it:

db_uri: postgres://db_user:db_pw@localhost:5432/goosebit

Alternatively, you can also work inside a container using docker exec.

@easybe
Copy link
Copy Markdown
Collaborator

easybe commented Aug 14, 2025

I pushed a commit that fixes the migration for Postgres. Please quash it if you approve.

@b-rowan b-rowan force-pushed the remove-feed-on-static-sw branch from 70bc957 to cf8be22 Compare August 14, 2025 19:37
@b-rowan b-rowan requested a review from easybe August 14, 2025 19:37
Copy link
Copy Markdown
Collaborator

@easybe easybe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@easybe easybe force-pushed the remove-feed-on-static-sw branch from cf8be22 to 1866a69 Compare August 14, 2025 20:06
@easybe
Copy link
Copy Markdown
Collaborator

easybe commented Aug 14, 2025

I'd say this is ready to go.

@easybe
Copy link
Copy Markdown
Collaborator

easybe commented Aug 19, 2025

@b-rowan could you approve and merge this?

@b-rowan b-rowan force-pushed the remove-feed-on-static-sw branch from 1866a69 to c7d8701 Compare August 19, 2025 18:31
@b-rowan b-rowan requested a review from easybe August 19, 2025 18:35
@b-rowan b-rowan merged commit 3f9f1fb into master Aug 19, 2025
6 checks passed
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 this pull request may close these issues.

Not obvious in device table if feed or manually assigned/latest version is configured

2 participants