Skip to content

Commit

Permalink
Merge pull request #150 from FREVA-CLINT/bug-fix
Browse files Browse the repository at this point in the history
Do not cache prep calls.
  • Loading branch information
antarcticrainforest authored Aug 30, 2024
2 parents f885747 + 8f03620 commit c700600
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
17 changes: 16 additions & 1 deletion assets/share/freva/deployment/playbooks/db-server-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
data_path: '{{db_data_path|regex_replace("^~", ansible_env.HOME)}}/{{ project_name }}/db_service'
continer_name: "{{ db_name }}"
vault_name: "{{project_name}}-vault"
vault_token_path: "{{db_data_path|regex_replace('^~', ansible_env.HOME)}}/{{ project_name }}/vault_service/files/keys"
adminer_name: "{{project_name}}-adminer"
tasks:
- name: Get UID
Expand All @@ -45,7 +46,7 @@
stat:
path: /etc/cron.daily
register: cron
- name: Registering vault volume path
- name: Registering vault service path
stat:
path: /etc/systemd/system/{{vault_name}}.service
register: vault_service
Expand Down Expand Up @@ -95,6 +96,20 @@
stat:
path: '{{db_data_path|regex_replace("^~", ansible_env.HOME)}}/{{ project_name }}/db_service'
register: db_service
- name: Register path to vault keys
stat:
path: "{{vault_token_path}}"
register: token_path
- name: Check vault keys
block:
- name: Base64 decode vault key path
command: base64 -d "{{vault_token_path}}"
rescue:
- name: Delete vault dir because its content is not valid
file:
state: absent
path: "{{db_data_path|regex_replace('^~', ansible_env.HOME)}}/{{ project_name }}/vault_service"
when: token_path.stat.exists
- name: Set db_service path exist facts
set_fact:
db_service_exist: "{{ db_service.stat.exists }}"
Expand Down
5 changes: 5 additions & 0 deletions docs/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ What's new
:maxdepth: 0
:titlesonly:

v2408.0.1
~~~~~~~~
* Some bug-fixes.


v2408.0.0
~~~~~~~~
* Add zarr-streaming deployment.
Expand Down
2 changes: 1 addition & 1 deletion src/freva_deployment/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import argparse
from urllib.request import urlretrieve

__version__ = "2408.0.0"
__version__ = "2408.0.1"

FREVA_PYTHON_VERSION = "3.12"
AVAILABLE_PYTHON_VERSIONS = ["3.8", "3.9", "3.10", "3.11", "3.12"]
Expand Down
13 changes: 2 additions & 11 deletions src/freva_deployment/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
import string
import sys
import time
from base64 import b64decode, b64encode
from base64 import b64encode
from copy import deepcopy
from functools import lru_cache
from getpass import getuser
from pathlib import Path
from socket import gethostbyname, gethostname
Expand All @@ -38,7 +37,6 @@
config_dir,
get_cache_information,
get_passwd,
is_bundeled,
load_config,
)
from .versions import get_steps_from_versions
Expand Down Expand Up @@ -206,7 +204,6 @@ def private_key_file(self) -> str:
"You must give a valid path to a private key file."
) from None

@lru_cache()
def _prep_vault(self) -> None:
"""Prepare the vault."""
self.cfg["vault"]["config"].setdefault("ansible_become_user", "root")
Expand All @@ -227,7 +224,6 @@ def _prep_vault(self) -> None:
"host", self.cfg["db"]["hosts"]
)

@lru_cache()
def _prep_db(self) -> None:
"""prepare the mariadb service."""
self._config_keys.append("db")
Expand Down Expand Up @@ -256,7 +252,6 @@ def _prep_db(self) -> None:
self._prep_vault()
self._prep_web(False)

@lru_cache()
def _prep_data_loader(self, password: Optional[str] = None) -> None:
"""Prepare the data-loader."""
self._prep_freva_rest()
Expand Down Expand Up @@ -373,7 +368,6 @@ def _prep_data_loader(self, password: Optional[str] = None) -> None:
},
}

@lru_cache()
def _prep_freva_rest(self, prep_web=True) -> None:
"""prepare the freva_rest service."""
self._config_keys.append("freva_rest")
Expand Down Expand Up @@ -410,7 +404,6 @@ def _prep_freva_rest(self, prep_web=True) -> None:
if prep_web:
self._prep_web(False)

@lru_cache()
def _prep_core(self) -> None:
"""prepare the core deployment."""
self._config_keys.append("core")
Expand Down Expand Up @@ -575,12 +568,10 @@ def _prep_web(self, ask_pass: bool = True) -> None:
if ask_pass:
self._prep_apache_config()

@lru_cache()
def _prep_apache_config(self):
with open(self.apache_config, "w") as f_obj:
f_obj.write((Path(asset_dir) / "web" / "freva_web.conf").read_text())

@lru_cache()
def _prep_local_debug(self) -> None:
"""Prepare the system for a potential local debug."""
default_ports = {"db": 3306, "freva_rest": 7777}
Expand Down Expand Up @@ -1072,7 +1063,7 @@ def _play(
cowpath=os.getenv("ANSIBLE_COW_PATH", shutil.which("cowsay") or ""),
cow_selection="random",
interpreter_python="auto_silent",
timeout="5",
timeout="15",
)
logger.debug("CONFIG\n%s", self._td.ansible_config_file.read_text())
extravars: dict[str, str] = {
Expand Down

0 comments on commit c700600

Please sign in to comment.