Skip to content

[ENG-2247] Creates a Node quota_status v1 endpoint for WB to enforce storage limits#9494

Open
UdayVarkhedkar wants to merge 34 commits intoCenterForOpenScience:developfrom
UdayVarkhedkar:feature/wb-node-storage-endpoint
Open

[ENG-2247] Creates a Node quota_status v1 endpoint for WB to enforce storage limits#9494
UdayVarkhedkar wants to merge 34 commits intoCenterForOpenScience:developfrom
UdayVarkhedkar:feature/wb-node-storage-endpoint

Conversation

@UdayVarkhedkar
Copy link
Copy Markdown
Contributor

Purpose

Provides Waterbutler with an endpoint to check if a node has exceeded storage limits prior to conducting file operations

Changes

  • Adds an endpoint (api/v1/<guid>/osfstorage/quota_status/) for WB to check the over_quota status of a node
  • Adds tests for the new endpoint

QA Notes

Dev Tested (Endpoint can only be accessed by WB)

Documentation

N/A

Side Effects

N/A

Ticket

JIRA Ticket

Copy link
Copy Markdown
Contributor

@Johnetordoff Johnetordoff left a comment

Choose a reason for hiding this comment

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

Nothing that's really a blocker, but a few questions here and there, still some WB work to be done, but fundamentally a good implementation, might want to include a few more docs about what WB is doing. Kind of curious why this is getting it's own callback and not just piggybacking on get_auth.

Comment thread addons/osfstorage/views.py Outdated
'over_quota': False
}
# Storage calculation for the target has been accepted and will run asynchronously
if target.storage_usage is None:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What does WB do if it gets a 202? Do we assume it's under quota?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think it should be retried. @felliott is working on the logic responding to this endpoint. What do you think, Fitz?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That makes sense, we can't always guarantee the calculation will be done before WB retries, but it usually only takes a few ms to do, so it's a safe bet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmmm, I hadn't considered this, but it should be doable. If I don't get an answer, though, we might need to let it go through.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That should be fine. We're trying to stop continued abuse, and the occasional file to get through shouldn't be a problem. If we have to, we'll eventually modify our caching invalidation strategy to make this less of a problem.

Comment thread api/nodes/views.py
return self.get_node()

def retrieve(self, request, *args, **kwargs):
instance = self.get_object()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can we just call get_node here and cut out the get_object definition?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It ends up breaking the NodeStorage embed which relies on the get_object definition. This change would be viable if we didn't need to embed it though!

Comment thread osf/models/node.py Outdated
Comment thread osf/models/node.py Outdated
Comment thread addons/osfstorage/routes.py
@brianjgeiger
Copy link
Copy Markdown
Collaborator

Drive-by: Did you mean to include your other API PR in with this one?

@UdayVarkhedkar
Copy link
Copy Markdown
Contributor Author

I rebased this PR upon the other API PR because of some of the None storage_usage handling and re-numbering of the StorageEnum.

@UdayVarkhedkar
Copy link
Copy Markdown
Contributor Author

@Johnetordoff Some of your feedback is actually for #9483 (which this PR is based upon). I'll incorporate those changes there.

We'll talk about why a distinct endpoint is necessary for WB tomorrow and I can write up a Notion doc detailing why - the gist is that get_auth is sent on an operation basis rather than a user intent basis (i.e. A user-facing move is two file operations, an upload and delete). For certain moves/copies within the same OSFStorage instance, they should be allowed regardless of storage caps because they are internal and not increasing the storage used. Permitting these operations through get_auth is difficult because the get_auth calls for the underlying file operations are independent. I believe we identified a way it could be managed but it was ultimately decided that the additional flexibility of a distinct endpoint would be better.

Comment thread addons/osfstorage/views.py
@Johnetordoff
Copy link
Copy Markdown
Contributor

Excellent work! just address Fitz's comments and we good.

Copy link
Copy Markdown
Collaborator

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

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

Handle quickfiles, plus Fitz's comments. Otherwise looks great.

Comment thread addons/osfstorage/views.py
@UdayVarkhedkar UdayVarkhedkar force-pushed the feature/wb-node-storage-endpoint branch from 93ce1da to 187eecd Compare October 1, 2020 15:29
Copy link
Copy Markdown
Collaborator

@brianjgeiger brianjgeiger left a comment

Choose a reason for hiding this comment

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

🎉 🐧 🎉

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.

5 participants