Skip to content

Commit

Permalink
per comment update
Browse files Browse the repository at this point in the history
  • Loading branch information
Natasha Ho committed Jan 5, 2023
1 parent 3e029e3 commit 0ffa993
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,17 @@ def _run_sql_migration(self) -> bool:
Returns True if migration was run successfully, else returns false.
"""
try:
process = self._container.exec(
["kratos", "migrate", "sql", "-e", "--config", self._config_file_path, "--yes"],
)
try:
stdout, _ = process.wait_output()
logger.info(f"Successfully executed automigration: {stdout}")
except ExecError as err:
logger.error(f"Exited with code {err.exit_code}. Stderr: {err.stderr}")
self.unit.status = BlockedStatus("Database migration job failed")
return False

stdout, _ = process.wait_output()
logger.info(f"Successfully executed automigration: {stdout}")
return True

def _on_pebble_ready(self, event) -> None:
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
DB_USERNAME = "fake_relation_id_1"
DB_PASSWORD = "fake-password"
DB_ENDPOINTS = "postgresql-k8s-primary.namespace.svc.cluster.local:5432"
MODEL_NAME = "kratos-model"


def setup_postgres_relation(harness):
Expand Down Expand Up @@ -108,7 +107,7 @@ def test_on_pebble_ready_has_correct_config_when_database_is_created(harness) ->
}
},
},
"dsn": f"postgres://{DB_USERNAME}:{DB_PASSWORD}@{DB_ENDPOINTS}/{MODEL_NAME}_{harness.charm.app.name}",
"dsn": f"postgres://{DB_USERNAME}:{DB_PASSWORD}@{DB_ENDPOINTS}/{harness.model.name}_{harness.charm.app.name}",
"courier": {
"smtp": {"connection_uri": "smtps://test:test@mailslurper:1025/?skip_ssl_verify=true"}
},
Expand Down

0 comments on commit 0ffa993

Please sign in to comment.