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

fix: use ipfs peerId as pin location #966

Merged
merged 4 commits into from
Feb 24, 2022
Merged

Conversation

olizilla
Copy link
Contributor

@olizilla olizilla commented Feb 8, 2022

Cluster now provides the peerId for the underlying ipfs node in pin status response, so we fix things to use that as our pin location peer id. Previously we used the cluster peerId which should only be used for internal cluster admin. With this change users will be able to use the peerId in the /status response to connect to the ipfs node that has their stuff via
ipfs swarm connect <peerId>

  • Fix toPin to use ipfsPeerId
  • Update tests to verify that status response for new content has a peerId of the ipfs node for one of the cluster nodes.
  • Update ipfs-cluster client to 4.0.0
  • Update ipfs-cluster in docker-compose to 0.14.5-rc1
  • Tweak test hooks to not wait for things to shut down before printing the test results overview, to reduce debugging friction.

Fixes: #414

TODO:

  • db migration script to update PinLocation peerIds
  • verify cluster infra is updated to ipfs-cluster >= 0.14.5-rc1
  • schedule read-only maintenance

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans oli@tableflip.io

Cluster now provides the peerId for the underlying ipfs node in pin status response, so we fix things to use that as our pin location peer id. Previously we used the cluster peerId which should only be used for internal cluster admin. With this change users will be able to use the peerId in the /status response to connect to the ipfs node that has their stuff via `ipfs swarm connect <peerId>`

- Fix toPin to use ipfsPeerId
- Update tests to verify that status response for new content has a peerId of the ipfs node for one of the cluster nodes.
- Update ipfs-cluster client to [4.0.0](https://github.com/nftstorage/ipfs-cluster/releases/tag/v4.0.0)
- Update ipfs-cluster in docker-compose to [0.14.5-rc1](https://github.com/ipfs/ipfs-cluster/releases/tag/v0.14.5-rc1)
- Tweak test hooks to not wait for things to shut down before printing the test results overview, to reduce debugging friction.

Fixes: #414

TODO:
- [] db migration script to update PinLocation peerIds
- [] verify cluster infra is updated to >= ipfs-cluster >= 0.14.5-rc1
- [] schedule read-only maintenance

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans <oli@tableflip.io>
@olizilla
Copy link
Contributor Author

olizilla commented Feb 8, 2022

PeerId map

Cluster peer IPFS peer
12D3KooWF6uxxqZf4sXpQEbNE4BfbVJWAKWrFSKamxmWm4E9vyzd 12D3KooWPySxxWQjBgX9Jp6uAHQfVmdq8HG1gVvS1fRawHNSrmqW
12D3KooWFe387JFDpgNEVCP5ARut7gRkX7YuJCXMStpkq714ziK6 12D3KooWR19qPPiZH4khepNjS3CLXiB7AbrbAD4ZcDjN1UjGUNE1
12D3KooWHdBjmicdXu5X57mQ65oBpfy4p3ca5p31kfJT9FSUFu3P 12D3KooWKytRAd2ujxhGzaLHKJuje8sVrHXvjGNvHXovpar5KaKQ
12D3KooWJeRQfPbiv5U2RqQ9yK3qijbNxKarKEGLMkGrfXJuZ2Bo 12D3KooWEDMw7oRqQkdCJbyeqS5mUmWGwTp8JJ2tjCzTkHboF6wK
12D3KooWLWFUri36dmTkki6o9PwfQNwGb2gsHuKD5FdcwzCXYnwc 12D3KooWNuoVEfVLJvU3jWY2zLYjGUaathsecwT19jhByjnbQvkj
12D3KooWMbibcXHwkSjgV7VZ8TMfDKi6pZvmi97P83ZwHm9LEsvV 12D3KooWSnniGsyAF663gvHdqhyfJMCjWJv54cGSzcPiEMAfanvU

extracted from ipfs-cluster-ctl --host /dnsaddr/web3.storage.ipfscluster.io peers ls output

@olizilla
Copy link
Contributor Author

olizilla commented Feb 8, 2022

Looks like the pin_location.peer_name field is not being set correctly in staging and prod. It's currently being set to the peerId. I will fix that as part of this PR.

@olizilla
Copy link
Contributor Author

The thrashing of the peer_name is coming from cluster; it returns either the peer name or the peerId for a node depending on the pin status. see: ipfs-cluster/ipfs-cluster#1569

I think ideally that'd be something we fix on cluster. Either way, it's not really in scope for this PR, so I'll raise a seperate issue to follow it up.

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans <oli@tableflip.io>
@olizilla
Copy link
Contributor Author

olizilla commented Feb 11, 2022

Tested locally. new pin locations created with ipfs peerId. Next steps are

  • verify with hsanjuan what the plan is for rolling out cluster update... will we roll out the rc or wait till the next stable release

once that is done, test it out on staging:

  • deploy to staging with api in read-only mode
  • run sql migration
  • enable write on staging api
  • upload content to staging api
  • verify the Pin Locations table has the expected number of cluster peers in and each one still has the ipfs peer id in the peerId column
  • celebrate then do it again on prod.

Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

Awesome, this is looking good! 👍🏼

We just need to figure out the remaining dependencies to move forward with release + maintenance window

@@ -0,0 +1,6 @@
UPDATE pin_location SET peer_id='12D3KooWPySxxWQjBgX9Jp6uAHQfVmdq8HG1gVvS1fRawHNSrmqW' WHERE peer_id='12D3KooWF6uxxqZf4sXpQEbNE4BfbVJWAKWrFSKamxmWm4E9vyzd';
Copy link
Contributor

Choose a reason for hiding this comment

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

We sadly don't have yet a migration mechanism out of the box. Perhaps, we can just create a migrations folder here, and prepend name of the sql script with date. What do you think?

@@ -53,18 +53,19 @@ export const mochaHooks = () => {
await delay(2000)
},
async afterAll () {
// Note: not awaiting promises here so we see the test results overview sooner.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is fine for me. But one question first. Running consecutively the tests is "safe", or can we easily start the tests while the containers are still being stopped/clenned?

Copy link
Member

Choose a reason for hiding this comment

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

I think no, we might have to revert this if we ever need that.

@olizilla
Copy link
Contributor Author

@hsanjuan do you have a rough estimate for when you'll release v0.14.5 of ipfs-cluster? No rush, it's just to know when we could schedule landing this PR.

@hsanjuan
Copy link

@olizilla today

@olizilla
Copy link
Contributor Author

Verified, cluster is ready for us to roll this out

ipfs-cluster-ctl --host /dnsaddr/web3.storage.ipfscluster.io version
0.14.5

@vasco-santos
Copy link
Contributor

@olizilla let's schedule a maintenance window for next week

@alanshaw
Copy link
Member

@@ -47,7 +47,7 @@ services:

cluster0:
container_name: cluster0
image: ipfs/ipfs-cluster:latest
image: ipfs/ipfs-cluster:v0.14.5-rc1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alanshaw I'm going to revert this change to the docker-compose to as the latest is now v0.14.5 https://github.com/ipfs/ipfs-cluster/releases

License: (Apache-2.0 AND MIT)
Signed-off-by: Oli Evans <oli@tableflip.io>
Copy link
Member

@alanshaw alanshaw left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -53,18 +53,19 @@ export const mochaHooks = () => {
await delay(2000)
},
async afterAll () {
// Note: not awaiting promises here so we see the test results overview sooner.
Copy link
Member

Choose a reason for hiding this comment

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

I think no, we might have to revert this if we ever need that.

@alanshaw alanshaw merged commit 5ae212d into main Feb 24, 2022
@alanshaw alanshaw deleted the use-ipfs-peerid-in-pin-location branch February 24, 2022 13:51
alanshaw pushed a commit that referenced this pull request Mar 10, 2022
Reverts #966 and instead stores the IPFS peer ID in the `pin_location` table.
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.

status api lists undialable peer ids
4 participants