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

Finalize PDS in-process AppView removal #1198

Merged
merged 113 commits into from
Oct 2, 2023
Merged

Finalize PDS in-process AppView removal #1198

merged 113 commits into from
Oct 2, 2023

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Jun 12, 2023

Finalizing the work of removing the AppView from the PDS & syncing this branch (which is being used for the current PDS distribution in sandbox) up with main

  • Refactor config
  • Wipe migrations
  • Tidying/clean up

@dholms dholms changed the title Remove in-process AppView from PDS Finalize PDS in-process AppView removal Sep 27, 2023
@dholms dholms marked this pull request as ready for review September 27, 2023 01:24
Copy link
Collaborator

@bnewbold bnewbold left a comment

Choose a reason for hiding this comment

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

Left minor devex-related comments. I would lean towards just merging this huge effort and then address any of those in a follow-on, instead of trying to resolve them first.

In that category: make run-dev-pds doesn't work on this branch; I think (and make run-dev-bsky) should not maybe point to services/pds/ and services/bsky/?

@@ -0,0 +1,24 @@
# See more env options in src/config/env.ts
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we merge this file with the existing packages/pds/example.dev.env? which gets auto-copied for use with make run-dev-pds. I'd otherwise be worried this .env.example will be hard to find (default hidden dotfile) and get stale.

If we did that, would need to ensure that the config actually works for local dev, instead of sandbox. I think just commenting out partial strings would work.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup yup that makes sense 👍

i actually forgot we already had an .env.example

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

alright I actually removed the make run-dev-pds & make run-dev-bsky commands as well as their env files

Right now, the best way to run these services in dev is in the dev-env the packages themselves aren't set up very well with service entry files. So I also moved over the dotenv code to dev-env so that it's env can be adjusted

I don't think we were using those Make commands at all during development, but lmk if this affects your ability to develop.

In the future, it might be worth taking another pass at refactoring running each of theses services in dev mode

Copy link
Collaborator

Choose a reason for hiding this comment

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

I do use those make commands fairly often, for the PDS and appview, distinct from dev-env. my workflow is basically to run make run-dev-* in a bunch of different terminals and a bunch of repos, while editing 1-2 code bases.

but I can try to get all that working in a follow-up PR, don't need to block this one on that side feature

packages/pds/src/config/env.ts Show resolved Hide resolved
Copy link
Collaborator

@devinivy devinivy left a comment

Choose a reason for hiding this comment

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

Looking pretty solid, pretty much just left a few misc questions and notes 💎

packages/dev-env/src/network-no-appview.ts Outdated Show resolved Hide resolved
Comment on lines 7 to 17
handler: async ({ params, auth }) => {
const requester = auth.credentials.did
const res =
await ctx.appViewAgent.api.app.bsky.actor.searchActorsTypeahead(
params,
await ctx.serviceAuthHeaders(requester),
)
return {
encoding: 'application/json',
body: res.data,
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Now that there's no logic in many of these routes, it's really tempting to create a lighter-weight passthrough proxy handler. Can just avoid a fair amount of parsing, validation, memory usage, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree 🤔

Could see about trying to wire something simple up - would be nice


const bskyAppViewCfg: ServerConfig['bskyAppView'] = {
url: env.bskyAppViewUrl ?? 'https://api.bsky-sandbox.dev',
did: env.bskyAppViewDid ?? 'did:plc:abc', // get real did
Copy link
Collaborator

Choose a reason for hiding this comment

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

If the user sets bskyAppViewUrl but not bskyAppViewDid this could get out of whack, but this should be correct in the more likely case that neither are set:

Suggested change
did: env.bskyAppViewDid ?? 'did:plc:abc', // get real did
did: env.bskyAppViewDid ?? 'did:web:api.bsky-sandbox.dev',

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually may just get rid of the defaults & throw if not included 🤔

This was added really just for ease of running in sandbox

Comment on lines +9 to +14
await db.schema
.createTable('app_migration')
.addColumn('id', 'varchar', (col) => col.primaryKey())
.addColumn('success', 'int2', (col) => col.notNull().defaultTo(0))
.addColumn('completedAt', 'varchar', (col) => col)
.execute()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we can get rid of this table and the app migration system.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

maybe? it might be helpful with some automatic migrations for the pds distribution in the future tho 🤔

I think the runtime flag table is asking for it more tbh

.addColumn('did', 'varchar', (col) => col.primaryKey())
.addColumn('root', 'varchar', (col) => col.notNull())
.addColumn('indexedAt', 'varchar', (col) => col.notNull())
.addColumn('takedownId', 'varchar')
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we may need to run a manual migration for the live service to change these cols to varchars.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh good snag 🤔

Would we rather these be varchars or integers? Does it matter?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can't quite remember why we changed it to a varchar back in the day

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it was so that you can store any identifier there, i.e. if the takedown came from some external system that didn't use integers to identify their actions. Pretty sure it was foreseeing removing some of the moderation machinery from the PDS, making that field less coupled to the current implementation.

Overall it doesn't matter a ton either way, though 👍

packages/pds/tests/proxied/views.test.ts Outdated Show resolved Hide resolved
packages/pds/src/storage/disk-blobstore.ts Outdated Show resolved Hide resolved
? Database.postgres({
url: cfg.dbPostgresUrl,
schema: cfg.dbPostgresSchema,
txLockNonce: cfg.dbTxLockNonce,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't think of anything that allows us to drop this—is it possible we need to bring it back? Or maybe I missed the change!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It got moved to AppContext 👍

services/pds/index.js Outdated Show resolved Hide resolved
packages/pds/src/config/config.ts Show resolved Hide resolved
@dholms dholms merged commit d664b51 into main Oct 2, 2023
10 checks passed
@dholms dholms deleted the simplify-pds branch October 2, 2023 18:27
edavis added a commit to edavis/pds that referenced this pull request Oct 15, 2023
The simplify-pds branch was deleted on 2023-10-02 after it was merged into main.

Refs: <bluesky-social/atproto#1198>
mloar pushed a commit to mloar/atproto that referenced this pull request Nov 15, 2023
* rm tables

* rm event-stream & proxied

* Remove appview services, move label service to pds

* only proxy appview stuff

* delete more tables

* Start removing message dispatched from pds

* more syncing-up removal of message dispatcher in pds

* merged

* remove feedgens from pds, remove getPopular

* remove unused image helper from pds

* fixing compiler errors

* clean up sharp

* rm label service

* first pass on cleaning up tests

* fix up a bunch of tests

* moderation view tests

* last admin tests

* got a lil overzealous in deletes

* clean up unused cfg

* clean up label table

* simplify admin repo search query/logic

* tidy pds entrypoint

* in-progress pds config changes

* cfg fiddling

* finish cleaning up cfg/ctx

* comments

* building

* pds prefix on env

* test env

* collapse pds migrations down into a single migration

* fix up dev-env

* tidy

* cleanup

* fix pds admin tests

* fix handle test

* fix pds proxy tests

* fix subscribe repos test

* fix sqlite config in pds tests

* add sqlite clause in sequencer-leader

* fix actor search w/ sqlite on pds

* fixes

* fix dev env build

* update pds service entrypoint

* simple env example

* make takedown ids opaque identifiers in the pds

* use pds routes for api tests

* update pds dockerfile with volume and correct port env var

* add a couple env vars to example

* add comments to env example

* @atproto/pds 0.2.0-beta.0

* @atproto/aws 0.0.1-beta.0

* appview did

* @atproto/aws 0.0.1

* enable logs by default

* update env example

* bugfixing sandbox issues

* consistency in pds env var name for appview url

* log on pds start and stop, configure version at runtime

* @atproto/pds 0.2.0-beta.1

* fix semver matching for pds beta version

* v0.2.0-beta.2

* default invites to being not required

* fix flaky test

* limit db connections in tests

* publish 0.2.0-beta.d3

* fix invite required parsing

* @atproto/pds 0.2.0-beta.5

* Proxy getPopularFeedGenerators on simplified pds (bluesky-social#1222)

proxy getPopularFeedGenerators on pds

Co-authored-by: dholms <[email protected]>

* tidy migrations

* fix service entry

* bump version

* change auth order

* bump version

* bump version

* add upgradeRepoVersion & fallback url for cdn

* bump version

* merging

* merge pds

* building dev-env

* merging tests

* merge service entry

* test fixing

* tidy

* fix admin search

* tidy

* tidy

* add snap for getListFeed

* add backup nameserver cfg

* tidy + pr feedback

* tidy

* tidy env

* bit more

* re-add dotenv to root package.json

* fix dep

* build branch

* fix tests

* Refactor tests to make better use of dev-env (bluesky-social#1690)

* refactor pds tests to use dev env

* refactor bsky tests

* fix pds test

* tidy bsky tests

* build pds correctly

* fix entry point

* default logging to false (for now)

* format service entry

* Switch takedown ids back to ints on pds distribution (bluesky-social#1694)

* switch takedown ids back to ints, consistent with live pds

* tidy/fix migration

* update migration for sqlite

* export moderation action reversal

* takedown tests

* dont build branch

---------

Co-authored-by: Devin Ivy <[email protected]>
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.

4 participants