Skip to content

Commit

Permalink
🐛 v1.6.14 Fix --no-auth and tweak mrsm stack. (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmeares authored Jun 5, 2023
2 parents a12dd66 + 2cc5c60 commit 38cf2c0
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

This is the current release cycle, so stay tuned for future releases!

### v1.6.14

- **Added healthchecks to `mrsm stack up`.**
The internal Docker Compose file for `mrsm stack` was bumped to version 3.9, and secrets were replaced with environment variable references.

- **Fixed `--no-auth` when starting the API.**
The command `mrsm start api --no-auth` now correctly handles sessions.

### v1.6.13

- **Remove `\\u0000` from strings when inserting into PostgreSQL.**
Expand Down
8 changes: 8 additions & 0 deletions docs/mkdocs/news/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

This is the current release cycle, so stay tuned for future releases!

### v1.6.14

- **Added healthchecks to `mrsm stack up`.**
The internal Docker Compose file for `mrsm stack` was bumped to version 3.9, and secrets were replaced with environment variable references.

- **Fixed `--no-auth` when starting the API.**
The command `mrsm start api --no-auth` now correctly handles sessions.

### v1.6.13

- **Remove `\\u0000` from strings when inserting into PostgreSQL.**
Expand Down
12 changes: 11 additions & 1 deletion meerschaum/actions/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@ def stack(
from meerschaum.utils.warnings import warn
from meerschaum.utils.formatting import ANSI
from meerschaum.utils.misc import is_docker_available
from meerschaum.config._read_config import search_and_substitute_config

stack_env_dict = {
var: val
for var, val in search_and_substitute_config(
meerschaum.config.stack.env_dict
).items()
if isinstance(val, str)
}

if action is None:
action = []
Expand Down Expand Up @@ -139,14 +148,15 @@ def stack(
cwd = STACK_COMPOSE_PATH.parent,
stdout = stdout,
stderr = stderr,
env = os.environ,
env = stack_env_dict,
) if (has_builtin_compose or has_binary_compose) else run_python_package(
'compose',
args = cmd_list,
cwd = STACK_COMPOSE_PATH.parent,
venv = _compose_venv,
capture_output = _capture_output,
as_proc = True,
env = stack_env_dict,
)
try:
rc = proc.wait() if proc is not None else 1
Expand Down
23 changes: 15 additions & 8 deletions meerschaum/api/dash/callbacks/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,23 @@ def update_page_layout_div(pathname: str, session_store_data: Dict[str, Any]):
session_id = session_store_data.get('session-id', None)
except AttributeError:
session_id = None

### Bypass login if `--no-auth` is specified.
if session_id is None and no_auth:
if session_id not in active_sessions and no_auth:
session_store_data['session-id'] = str(uuid.uuid4())
active_sessions[session_store_data['session-id']] = {'username': 'no-auth'}
session_store_to_return = session_data
session_store_to_return = session_store_data
else:
session_store_to_return = dash.no_update

_path = (pathname.rstrip('/') + '/').replace((dash_endpoint + '/'), '').rstrip('/')
path = _path if no_auth or _path not in _required_login else (
_path if session_id in active_sessions else 'login'
path = (
_path
if no_auth or _path not in _required_login else (
_path
if session_id in active_sessions
else 'login'
)
)
layout = _paths.get(path, pages.error.layout)
return layout, session_store_to_return
Expand Down Expand Up @@ -447,21 +453,22 @@ def show_arguments_collapse(n_clicks : int, is_open : bool):
Output('ws', 'send'),
Input('test-button', 'n_clicks'),
Input('ws', 'url'),
Input('session-store', 'data'),
State('ws', 'state'),
State('ws', 'message'),
State('ws', 'error'),
State('ws', 'protocols'),
State('session-store', 'data'),
# prevent_initial_call = True,
)
def ws_send(n_clicks: int, url, *states):
def ws_send(n_clicks: int, url, session_store_data: Dict[str, Any], *states):
"""
Send an initial connection message over the websocket.
"""
ctx = dash.callback_context
if not url:
raise PreventUpdate
session_id = ctx.states['session-store.data']['session-id']
session_id = session_store_data.get('session-id', None)
if session_id is None:
raise PreventUpdate
return json.dumps({
'connect-time': json_serialize_datetime(datetime.datetime.utcnow()),
'session-id': session_id,
Expand Down
2 changes: 1 addition & 1 deletion meerschaum/config/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Specify the Meerschaum release version.
"""

__version__ = "1.6.13"
__version__ = "1.6.14"
36 changes: 24 additions & 12 deletions meerschaum/config/stack/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
'meerschaum' : 'MRSM{!meerschaum}',
'system' : 'MRSM{!system}',
},
# separators = (',', ':'),
indent = 4,
).replace(
'"MRSM{!system}"', 'MRSM{!system}'
Expand Down Expand Up @@ -94,17 +93,26 @@
}

default_docker_compose_config = {
'version': '3.2',
'version': '3.9',
'services': {
'db': {
'environment': {
'TIMESCALEDB_TELEMETRY': 'off',
'POSTGRES_USER': env_dict['POSTGRES_USER'],
'POSTGRES_DB': env_dict['POSTGRES_DB'],
'POSTGRES_PASSWORD': env_dict['POSTGRES_PASSWORD'],
'POSTGRES_USER': '$POSTGRES_USER',
'POSTGRES_DB': '$POSTGRES_DB',
'POSTGRES_PASSWORD': '$POSTGRES_PASSWORD',
'ALLOW_IP_RANGE': env_dict['ALLOW_IP_RANGE'],
},
'command': 'postgres -c max_connections=1000 -c shared_buffers=1024MB',
'healthcheck': {
'test': [
'CMD-SHELL', 'pg_isready',
'-U', '$POSTGRES_USER', '-d', '$POSTGRES_DB',
],
'interval': '5s',
'timeout': '3s',
'retries': 3
},
'restart': 'always',
'image' : 'timescale/timescaledb:' + env_dict['TIMESCALEDB_VERSION'],
'ports' : [
Expand Down Expand Up @@ -132,11 +140,13 @@
'MRSM_CONFIG': env_dict['MEERSCHAUM_API_CONFIG'],
'MRSM_PATCH': env_dict['MEERSCHAUM_API_PATCH'],
},
'restart' : 'always',
'restart': 'always',
'init': True,
'depends_on' : [
'db',
],
'depends_on': {
'db': {
'condition': 'service_healthy',
},
},
'volumes' : [
'api_root:' + volumes['api_root'],
],
Expand All @@ -151,9 +161,11 @@
'backend',
],
'restart': 'always',
'depends_on': [
'db',
],
'depends_on': {
'db': {
'condition': 'service_healthy',
},
},
'volumes': [
'grafana_storage' + ':' + volumes['grafana_storage'],
### NOTE: Mount with the 'z' option for SELinux.
Expand Down

0 comments on commit 38cf2c0

Please sign in to comment.