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

Introduce filestorage app, support for multiple file backends and store file metadata in the database #1104

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

suricactus
Copy link
Collaborator

This PR introduces a new enhanced way to store filedata. Before just dumped everything to the Object Storage. This made everything clumsy, slow and not flexible.

The plan is to quickly migrate all projects to the new storage and delete the legacy approach.

I have closed #1065, which was the same PR.

@duke-nyuki
Copy link
Collaborator

Copy link
Contributor

@gounux gounux left a comment

Choose a reason for hiding this comment

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

First review focused on docker compose and environment / migrations considerations, trying to set it up on my local.
Did not have a look at the python code that much yet.

docker-app/qfieldcloud/filestorage/models.py Show resolved Hide resolved
.env.example Show resolved Hide resolved
.env.example Show resolved Hide resolved
@suricactus
Copy link
Collaborator Author

@gounux apologies for the force push, I first rebased and then realized I had to force push.

Copy link
Contributor

@gounux gounux left a comment

Choose a reason for hiding this comment

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

2nd review round, diving deeper into it.
Mainly curiosity, sometimes naive questions to understand better.
3rd one will come soon

docker-app/qfieldcloud/core/exceptions.py Show resolved Hide resolved
docker-app/qfieldcloud/core/fields.py Outdated Show resolved Hide resolved
docker-app/qfieldcloud/core/views/package_views.py Outdated Show resolved Hide resolved
docker-app/qfieldcloud/core/views/package_views.py Outdated Show resolved Hide resolved
docker-app/qfieldcloud/core/models.py Show resolved Hide resolved
docker-app/qfieldcloud/filestorage/models.py Show resolved Hide resolved
docker-app/qfieldcloud/filestorage/models.py Outdated Show resolved Hide resolved
docker-app/qfieldcloud/filestorage/models.py Show resolved Hide resolved
docker-app/qfieldcloud/filestorage/models.py Show resolved Hide resolved
Copy link
Contributor

@gounux gounux left a comment

Choose a reason for hiding this comment

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

3rd review round.

I faced an error when creating a project with the basic OSM .qgs file :

  • project exists in the database
  • in the database, the project has file_storage value to default, but the files are stored in the legacy bucket
  • running the migrateprojectstorage command throw this error : Exception: Cannot migrate to storage "default", project is already stored there!

After looking at the Jobs in QFC Admin, the Process QGIS Project File have Failed status with UNKNOWN Error type :

image

The Output pre display the error Local files list for project "UUID": empty! :

image

Feedback pre shows a ProjectFileNotFoundException thrown :

image

def next_version(self) -> "FileVersion | None":
file_version_qs = FileVersion.objects.filter(
file=self.file,
uploaded_at__lt=self.uploaded_at,
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
uploaded_at__lt=self.uploaded_at,
uploaded_at__gt=self.uploaded_at,

Comment on lines +20 to +21
md5sum = serializers.SerializerMethodField()
sha256 = serializers.SerializerMethodField()
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need those ?

name="is_locked",
field=models.BooleanField(
default=False,
help_text="If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechansism related to file storage migration or other file operations.",
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
help_text="If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechansism related to file storage migration or other file operations.",
help_text="If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechanism related to file storage migration or other file operations.",

is_locked = models.BooleanField(
_("Is locked"),
help_text=_(
"If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechansism related to file storage migration or other file operations."
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
"If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechansism related to file storage migration or other file operations."
"If set to true, the project is temporarily locked. Locking is internal QFieldCloud mechanism related to file storage migration or other file operations."

Comment on lines +26 to +35
def whatever(self):
qs = self.annotate(
last_version_pk=(
FileVersion.objects.filter(file=OuterRef("pk"))
.order_by("-uploaded_at")
.values("pk")[:1]
)
)
qs = qs.prefetch_related("versions")
return qs
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this strictly mandatory or did you use this for testing ?

Comment on lines +1151 to +1152
# the s3 storage has 1024 bytes (not chars!) limit: https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html
max_length=1024,
Copy link
Contributor

Choose a reason for hiding this comment

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

Then why use 1024 characters and not the STORAGE_FILENAME_MAX_CHAR_LENGTH settings variable ?

Comment on lines +284 to +293
last_job = project.last_package_job
if last_job.feedback.get("feedback_version") == "2.0":
layers = last_job.feedback["outputs"]["qgis_layers_data"]["layers_by_id"]
else:
steps = last_job.feedback.get("steps", [])
layers = (
steps[1]["outputs"]["layer_checks"]
if len(steps) > 2 and steps[1].get("stage", 1) == 2
else None
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Find it hard to understand what this is supposed to be doing.
Would a comment be welcome ?

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