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

Adding support for printing to work with a shared volume (cloud environment) #25

Merged
merged 9 commits into from
Oct 14, 2024

Conversation

tiago-s-vieira-alb
Copy link
Contributor

Before this change, print-lib generates a file into disk, and cache the file pointer into a Java map (in memory).
The problem of this, is after generating a file, the next request to get the file MUST be to the same geoserver instance. Other geoservers, doesn't have any reference to this generated file. In a k8s environment this is a problem.

Before implementation:

  • Not cloud environment and not shared volume, the loadbalancer must have sticky session --> it works
  • Not cloud environment and shared volume, the loadbalancer must have sticky session --> it works
  • Not cloud environment and shared volume, if loadbalancer do not have sticky session --> it will crash when get from a different geoserver then the one that generates the file
  • Cloud environment, the loadbalancer cannot have sticky session --> it will crash when get from a different geoserver then the one that generates the file

To solve it:

  • When in printing phase, instead of java map, we persist the information into a JSON file on disk (next to the PDF file)
  • When requesting the file, the code now reads the JSON file from the disk and always provides the response
  • The purge of old files (more than 10 minutes) was maintained

IN SUMMARY:
What was saved in an instance into an hashmap, now is persisted on disk.

After releasing version with this PR, create a ticket in geoserver like this "https://osgeo-org.atlassian.net/browse/GEOS-11480" to update mapfish-print version.

@tiago-s-vieira-alb
Copy link
Contributor Author

Hi @jodygarnett , can you please review PR?
It will be great it could be integrated into a next minor geoserver version.
Thanks

@jodygarnett
Copy link
Collaborator

Okay! Yeah many other geoserver extensions end up with a shared database (rather than a shared json) to communicate state across instances.

I wish we had a good shared module for that which could use an appropriate storage / communication to avoid all the duplication we are seeing.

@jodygarnett
Copy link
Collaborator

Can I ask you to include a note on the docs about this as it is a pretty important changed :)

@tiago-s-vieira-alb
Copy link
Contributor Author

Can I ask you to include a note on the docs about this as it is a pretty important changed :)

@ritika-t-thakur-alb updated documentation.

@@ -4,7 +4,7 @@ Upgrade
Version 2.3.2
-------------

* Support for printing in a cloud environment and in an environment without sticky sessions : generates a requested printout metadata json file and stores it in the tempDir. With this information peristed, there is no need for sticky sessions and printing module can be used in a cloud environment with shared volume.
* Support for printing in a cloud environment and in an environment without sticky sessions : generates a requested printout metadata json file and stores it in the tempDir. With this information persisted, there is no need for sticky sessions and printing module can be used in a cloud environment with shared volume.
Copy link
Collaborator

Choose a reason for hiding this comment

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

So how does this work in a could environment - don’t they need to share a temp folder or something?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hello @jodygarnett ,
I elaborated my documentation a bit more.
Answering your question: depending on the cloud environment, engineers an pick an option to share a volume between multiple instances and pass the path in the existing MAPFISH_PDF_FOLDER environment variable.
I have already updated installation.rst file with the documentation for MAPFISH_PDF_FOLDER.

I think the steps for creating a shared volume is not related with this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @jodygarnett, i think everything is done from our side.
Do you need more information?

@jodygarnett
Copy link
Collaborator

If you rebase to resolve conflict we should be able to merge?

@tiago-s-vieira-alb
Copy link
Contributor Author

Hi @jodygarnett i think we don't have any conflict.
Can you check please?

@jodygarnett
Copy link
Collaborator

Okay I could not rebase but I can do a squash and merge

@jodygarnett jodygarnett merged commit 55b10e7 into mapfish:main Oct 14, 2024
4 checks passed
@tiago-s-vieira-alb
Copy link
Contributor Author

@jodygarnett when you release print-2.3.2, please update also in geoserver:
https://osgeo-org.atlassian.net/browse/GEOS-11480

Thank you :)

@jodygarnett
Copy link
Collaborator

I think it is all done

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