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

File persistence system for files outside the repository #31

Closed
apolopena opened this issue Feb 8, 2021 · 0 comments
Closed

File persistence system for files outside the repository #31

apolopena opened this issue Feb 8, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main

Comments

@apolopena
Copy link
Owner

Problem this feature will solve

Any file not written to /workspace or deeper is not persisted between subsequent startups of a workspace.
Because of this, on every subsequent startup of the workspace:

  • ~/.gitconfig has to be re-customized
  • All dynamically created rake tasks have to be re-created
  • /var/log/worspace-init.log gets blasted away.

Background

See bug #30

Proposed Solution

Its hacky but until Gitpod supports file persistence outside of the `/workspace' directory let's do this:

  1. Dynamically create a place to temporarily store persistent files for the project. So for example /workspace/my-project would have a ancillary folder called /workspace/my-project--store.
  2. create a mark-as-inited helper function to be called once from bash/init-complete.sh as the very last line of code. The mark-as-inited function will set an is_inited.lock file (in the ancillary folder) that will serve as a flag for the workspace to know when it has already been started at least once already.
  3. Create ais-inited helper function to use as a hook (that checks for the presence of is_inited.lock) for determining if the workspace has been started before or not.
  4. Create a persist_file helper function that will copy the file passed in to it, to the ancillary project folder mentioned in bullet point 1. That folder will be created on-the-fly if it does not already exist.
  5. Create a restore_persistent_files helper function that will copy all file 'persisted' by the persist_file function from the ancillary project folder to their original locations.
  6. In bash/before-tasks.sh , right before the mark_as_inited function call. Set any persistent file you want by passing them to the persist_file function.
  7. In before-tasks.sh as the very last code block, check if the workspace has been run for the first time and if it has, restore all persistent files by calling restore_persistent_files. The code will look like this:
if [ $(bash bash/helpers.sh is_inited) == 1 ]; then
  bash bash/helpers.sh restore_persistant_files $GITPOD_REPO_ROOT
fi

Constraints and Assumptions

  • File persistence will work with single files but not an entire file tree. Yet...
  • This 'file persistence' system is rigid and somewhat hardcoded but code be made more pliable. Not sure if its worth it right now though.

Alternatives or Workarounds

Unsure.

Additional context

Don't use this system too much because there is a bunch of boilerplate code that goes with it and eventually it will be a depricated system when Gitpod adds a file persistence feature.

@apolopena apolopena added the enhancement New feature or request label Feb 8, 2021
@apolopena apolopena self-assigned this Feb 8, 2021
@apolopena apolopena added the passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main label Feb 8, 2021
@apolopena apolopena changed the title File persistence system for outside the repository File persistence system for files outside the repository Feb 8, 2021
apolopena added a commit that referenced this issue Feb 8, 2021
* 🐛 FIX: persistent rake tasks #30

* 👌 IMPROVE: it all works, commands that log to init log will write in one-time

* 🐛 FIX: mtail_apache function

* 👌 IMPROVE: Pretty results of initialization #32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request passed-dev-qa Optional state. Use this when QAing other peoples fixes in another branch.ready to be merged to main
Projects
None yet
Development

No branches or pull requests

1 participant