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

Rename #118

Merged
merged 5 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/formatting.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
on:
push:
branches:
branches-ignore:
- main
permissions:
contents: write
Expand Down
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.idea/
ir_api.egg-info/

ir_api/local_scripts/*
!ir_api/local_scripts/.keep

Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ Login using docker login

Then build and push the file-watcher container
```shell
docker build . -f ./container/file_watcher.D -t ghcr.io/interactivereduction/filewatcher
docker push ghcr.io/interactivereduction/filewatcher -a
docker build . -f ./container/file_watcher.D -t ghcr.io/fiaisis/filewatcher
docker push ghcr.io/fiaisis/filewatcher -a
```

Then build and push the file-watcher-operator container

```shell
docker build . -f ./container/file_watcher_operator.D -t ghcr.io/interactivereduction/filewatcher-operator
docker push ghcr.io/interactivereduction/filewatcher-operator -a
docker build . -f ./container/file_watcher_operator.D -t ghcr.io/fiaisis/filewatcher-operator
docker push ghcr.io/fiaisis/filewatcher-operator -a
```

The file-watcher container, when updated needs to be updated in each of the CRDs controlled by the file watcher operator.
Expand Down
2 changes: 1 addition & 1 deletion file_watcher/database/db_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class DBUpdater:
"""

def __init__(self, ip: str, username: str, password: str):
connection_string = f"postgresql+psycopg2://{username}:{password}@{ip}:5432/interactive-reduction"
connection_string = f"postgresql+psycopg2://{username}:{password}@{ip}:5432/fia"
engine = create_engine(connection_string, poolclass=QueuePool, pool_size=20, pool_pre_ping=True)
self.session_maker_func = sessionmaker(bind=engine)

Expand Down
3 changes: 1 addition & 2 deletions file_watcher/lastrun_file_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def __init__(
self.db_updater = DBUpdater(ip=db_ip, username=db_username, password=db_password)
self.latest_known_run_from_db = self.get_latest_run_from_db()
logger.info("Last run in DB is: %s", self.latest_known_run_from_db)
if (self.latest_known_run_from_db is None
or self.latest_known_run_from_db == 'None'):
if self.latest_known_run_from_db is None or self.latest_known_run_from_db == "None":
logger.info("Adding latest run to DB as there is no data: %s", self.last_recorded_run_from_file)
self.update_db_with_latest_run(self.last_recorded_run_from_file)
self.latest_known_run_from_db = self.last_recorded_run_from_file
Expand Down
12 changes: 6 additions & 6 deletions file_watcher_operator/file_watcher_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def generate_deployment_body(
spec:
containers:
- name: {name}-file-watcher
image: ghcr.io/interactivereduction/filewatcher@sha256:{file_watcher_sha}
image: ghcr.io/fiaisis/filewatcher@sha256:{file_watcher_sha}
env:
- name: QUEUE_HOST
value: {queue_host}
Expand Down Expand Up @@ -170,7 +170,7 @@ def deploy_deployment(deployment_spec: Mapping[str, Any], name: str, children: L
"""
app_api = kubernetes.client.AppsV1Api()
logger.info("Starting deployment of: %s filewatcher", name)
namespace = os.environ.get("FILEWATCHER_NAMESPACE", "ir")
namespace = os.environ.get("FILEWATCHER_NAMESPACE", "fia")
depl = app_api.create_namespaced_deployment(namespace=namespace, body=deployment_spec)
children.append(depl.metadata.uid)
logger.info("Deployed: %s filewatcher", name)
Expand All @@ -185,7 +185,7 @@ def deploy_pvc(pvc_spec: Mapping[str, Any], name: str, children: List[Any]) -> N
:param children: The operators children
:return: None
"""
namespace = os.environ.get("FILEWATCHER_NAMESPACE", "ir")
namespace = os.environ.get("FILEWATCHER_NAMESPACE", "fia")
core_api = kubernetes.client.CoreV1Api()
# Check if PVC exists else deploy a new one:
if pvc_spec["metadata"]["name"] not in [
Expand Down Expand Up @@ -216,7 +216,7 @@ def deploy_pv(pv_spec: Mapping[str, Any], name: str, children: List[Any]) -> Non
logger.info("Deployed PV: %s filewatcher", name)


@kopf.on.create("ir.com", "v1", "filewatchers")
@kopf.on.create("fia.com", "v1", "filewatchers")
def create_fn(spec: Any, **kwargs: Any) -> Dict[str, List[Any]]:
"""
Kopf create event handler, generates all 3 specs then creates them in the cluster, while creating the children and
Expand All @@ -241,7 +241,7 @@ def create_fn(spec: Any, **kwargs: Any) -> Dict[str, List[Any]]:
return {"children": children}


@kopf.on.delete("ir.com", "v1", "filewatchers")
@kopf.on.delete("fia.com", "v1", "filewatchers")
def delete_func(**kwargs: Any) -> None:
"""
Kopf delete event handler. This will automatically delete the filewatcher deployment and pvc, and will manually
Expand All @@ -254,7 +254,7 @@ def delete_func(**kwargs: Any) -> None:
client.delete_persistent_volume(name=f"{name}-file-watcher-pv")


@kopf.on.update("ir.com", "v1", "filewatchers")
@kopf.on.update("fia.com", "v1", "filewatchers")
def update_func(spec: Any, **kwargs: Any) -> None:
"""
kopf update event handler. This automatically updates the filewatcher deployment when the CRD changes
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies = [
]

[project.urls]
"Repository" = "https://github.com/interactivereduction/file-watcher"
"Repository" = "https://github.com/fiaisis/file-watcher"

[project.scripts]
file_watcher = "file_watcher.main:main"
Expand Down
Loading