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

Feature/Admin CLI enhancements #210

Merged
merged 46 commits into from
Apr 5, 2022

Conversation

kikkomep
Copy link
Member

This PR introduces a basic manage.py script which acts as entrypoint for the back-end CLI.

The available commands are:

Usage: manage.py [OPTIONS] COMMAND [ARGS]...

Options:
  --help  Show this message and exit.

Commands:
  api-key     Manage admin API keys
  cache       Manage cache
  db          Manage database
  oauth       Manage credentials for OAuth2 clients
  registry    Manage workflow registries
  task-queue  Manage task queue

The current version of the db command includes all the relevant subcommands to:

  • perform the database initialisation;
  • manage database migrations;
  • make backup/restore of the database

Finally, the k8s chart includes a configurable CronJob to perform automatic backups on a user-defined cluster volume and, optionally, to sync that volume with a remote site via SFTP.

@simleo
Copy link
Member

simleo commented Mar 25, 2022

We could just call it lm or lmadmin

@ilveroluca
Copy link
Member

I like lmadmin too. Seems intuitive and easy to remember.

imagePullPolicy: {{ .Values.lifemonitor.imagePullPolicy }}
command: ["/bin/sh","-c"]
args:
- base_path="/var/data/backup" ;
Copy link
Member

Choose a reason for hiding this comment

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

perhaps this code would be easier to maintain if placed in a script in the lifemonitor image that is used to execute this job.

Copy link
Member Author

Choose a reason for hiding this comment

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

Script replaced by lm-admin backup command (ee8401a)

file = f"{datetime.now().strftime('%Y%m%d_%H%M%S')}.tar"
target_path = os.path.join(directory, file)
cmd = f"PGPASSWORD={params['password']} pg_dump -h {params['host']} -U {params['user']} -F t {params['dbname']} > {target_path}"
os.system(cmd)
Copy link
Member

Choose a reason for hiding this comment

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

The code is not checking the exit code from the called process. Rather than os.system, we'd be better off just using subprocess.check_call.

Copy link
Member Author

Choose a reason for hiding this comment

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

addressed in 3a72fa2

@simleo
Copy link
Member

simleo commented Mar 25, 2022

https://crs4.github.io/life_monitor/lm_admin_guide needs to be updated accordingly

@kikkomep kikkomep merged commit a847e90 into crs4:develop Apr 5, 2022
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