Skip to content

Conversation

@yoution
Copy link
Contributor

@yoution yoution commented Feb 3, 2020

No description provided.

…x/m2m_token_caching_fix

Avoid reusing the global variable for client
Copy link
Contributor

@maxceem maxceem left a comment

Choose a reason for hiding this comment

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

In general, works good.

Though there is one performance issue. Before, we use AWS CLI move command which moves the file without downloading it. Now the script first downloads the file and after uploads, for the big files it would be very slow, and most likely request for creating an attachment would fail after reaching the timeout.

  1. To fix it, we can replace get and put operations with one copy operation, so we don't have to download the file and it should work much faster as it would copy the object between the buckets internally by AWS https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#copyObject-property.

  2. Let's catch error during delete operation separately, so it doesn't break the whole s3FileTransfer method. So if we copy file successfully, but couldn't delete it, s3FileTransfer still return success. We still have to log an error if deleting failed for debugging.

@yoution
Copy link
Contributor Author

yoution commented Feb 4, 2020

@maxceem please review again, I use setTimeout to do the delete action, please comment
the code https://github.com/topcoder-platform/tc-project-service/blob/develop/src/routes/attachments/create.js#L73-L78 to validate

Copy link
Contributor

@maxceem maxceem left a comment

Choose a reason for hiding this comment

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

It works great now.

I did a few small improvements, just FYI, don't have to fix it:

image

We should use req.log.error instead of req.log.debug for errors so in the log we can filter records and find all the errors:

image

@maxceem maxceem changed the base branch from master to feature/file-transfer-s3-improvements February 4, 2020 06:03
@maxceem maxceem merged commit 641f8c5 into topcoder-platform:feature/file-transfer-s3-improvements Feb 4, 2020
@yoution
Copy link
Contributor Author

yoution commented Feb 4, 2020

thanks, your method is better then mine, promise is faster then settimeout

@yoution yoution deleted the master branch February 4, 2020 06:10
@vikasrohit
Copy link

Thanks @yoution and @maxceem for the efforts.

@vikasrohit
Copy link

@maxceem can we create hotfix instead of feature fix?

@maxceem
Copy link
Contributor

maxceem commented Feb 4, 2020

@vikasrohit I was thinking that we would make a release this week anyway, so created a feature branch. Also, it's better to test it on DEV a little.

Another thing, it looks like we have a redundant code there and unnecessarily call uploadurl File Service endpoint: https://github.com/topcoder-platform/tc-project-service/blob/feature/file-transfer-s3-improvements/src/routes/attachments/create.js#L73-L90 - I think we can just remove this call.

So after testing this fix, I was going to remove that call and also test without it.

Let me know if you still would like to have a hotfix for this. Should hotfix include the second part with removing unnecessary call or no?

@vikasrohit
Copy link

Makes sense. I was only worried if by any unavoidable reason, we have to push the release. Most probably we should be releasing on Thursday. However, I think we do need some time in dev to test out the changes, so lets keep it feature for now and in case we don't have release this week on Thursday, we would make it hotfix.

@maxceem
Copy link
Contributor

maxceem commented Feb 4, 2020

@vikasrohit it looks like on DEV file uploading is not fully enabled. Files are visually uploaded but I cannot open them after. Could we enable file uploading on DEV for now, so we can fully validate it?

@vikasrohit
Copy link

I think last time we made it enabled. I am not sure why it is not working now. I can check again, it was an env variable which used to prevent the actual file upload in dev.

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.

3 participants