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 graph IPFS connection failure due to the unsupported /stat HTTP API #2

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 5 additions & 12 deletions core/src/link_resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,10 @@ impl LinkResolverTrait for LinkResolver {
}
trace!(logger, "IPFS cache miss"; "hash" => &path);

let (size, client) = select_fastest_client_with_stat(
let (_size, client) = select_fastest_client_with_stat(
self.clients.cheap_clone(),
logger.cheap_clone(),
StatApi::Files,
StatApi::Block,
path.clone(),
self.timeout,
self.retry,
Expand All @@ -182,7 +182,6 @@ impl LinkResolverTrait for LinkResolver {

let max_cache_file_size = self.env_vars.mappings.max_ipfs_cache_file_size;
let max_file_size = self.env_vars.mappings.max_ipfs_file_bytes;
restrict_file_size(&path, size, max_file_size)?;

let req_path = path.clone();
let timeout = self.timeout;
Expand Down Expand Up @@ -215,7 +214,7 @@ impl LinkResolverTrait for LinkResolver {

async fn get_block(&self, logger: &Logger, link: &Link) -> Result<Vec<u8>, Error> {
trace!(logger, "IPFS block get"; "hash" => &link.link);
let (size, client) = select_fastest_client_with_stat(
let (_size, client) = select_fastest_client_with_stat(
self.clients.cheap_clone(),
logger.cheap_clone(),
StatApi::Block,
Expand All @@ -225,9 +224,6 @@ impl LinkResolverTrait for LinkResolver {
)
.await?;

let max_file_size = self.env_vars.mappings.max_ipfs_file_bytes;
restrict_file_size(&link.link, size, max_file_size)?;

let link = link.link.clone();
let data = retry_policy(self.retry, "ipfs.getBlock", &logger)
.run(move || {
Expand All @@ -247,19 +243,16 @@ impl LinkResolverTrait for LinkResolver {
// Discard the `/ipfs/` prefix (if present) to get the hash.
let path = link.link.trim_start_matches("/ipfs/");

let (size, client) = select_fastest_client_with_stat(
let (_size, client) = select_fastest_client_with_stat(
self.clients.cheap_clone(),
logger.cheap_clone(),
StatApi::Files,
StatApi::Block,
path.to_string(),
self.timeout,
self.retry,
)
.await?;

let max_file_size = self.env_vars.mappings.max_ipfs_map_file_size;
restrict_file_size(path, size, max_file_size)?;

let mut stream = client.cat(path, None).await?.fuse().boxed().compat();

let mut buf = BytesMut::with_capacity(1024);
Expand Down
7 changes: 4 additions & 3 deletions docker/start
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ save_coredumps() {
wait_for_ipfs() {
# Take the IPFS URL in $1 apart and extract host and port. If no explicit
# host is given, use 443 for https, and 80 otherwise
if [[ "$1" =~ ^((https?)://)?([^:/]+)(:([0-9]+))? ]]
if [[ "$1" =~ ^((https?)://)?(([^@]+)@)?([^:/]+)(:([0-9]+))? ]]
then
proto=${BASH_REMATCH[2]:-http}
host=${BASH_REMATCH[3]}
port=${BASH_REMATCH[5]}
user=${BASH_REMATCH[4]}
host=${BASH_REMATCH[5]}
port=${BASH_REMATCH[7]}
if [ -z "$port" ]
then
[ "$proto" = "https" ] && port=443 || port=80
Expand Down
Loading