Skip to content

Fixes on webserver diagnostics submodule and setup in dev-mode #1430

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

Merged
merged 4 commits into from
Apr 3, 2020
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
41 changes: 22 additions & 19 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
#
# by sanderegg, pcrespov
.DEFAULT_GOAL := help
SHELL := /bin/bash


# TOOLS --------------------------------------

MAKE_C := $(MAKE) --no-print-directory --directory

# Operating system
ifeq ($(filter Windows_NT,$(OS)),)
IS_WSL := $(if $(findstring Microsoft,$(shell uname -a)),WSL,)
Expand All @@ -20,7 +24,6 @@ endif
IS_WIN := $(strip $(if $(or $(IS_LINUX),$(IS_OSX),$(IS_WSL)),,$(OS)))
$(if $(IS_WIN),$(error Windows is not supported in all recipes. Use WSL instead. Follow instructions in README.md),)

SHELL := /bin/bash

# VARIABLES ----------------------------------------------
# TODO: read from docker-compose file instead $(shell find $(CURDIR)/services -type f -name 'Dockerfile')
Expand Down Expand Up @@ -88,7 +91,7 @@ ifeq ($(target),)
# Compiling front-end

@$(if $(findstring -kit,$@),export DOCKER_BUILDKIT=1;export COMPOSE_DOCKER_CLI_BUILD=1;,) \
$(MAKE) -C services/web/client compile$(if $(findstring -x,$@),-x,)
$(MAKE_C) services/web/client compile$(if $(findstring -x,$@),-x,)

# Building services
@$(if $(findstring -kit,$@),export DOCKER_BUILDKIT=1;export COMPOSE_DOCKER_CLI_BUILD=1;,) \
Expand All @@ -97,7 +100,7 @@ else
ifeq ($(findstring webserver,$(target)),webserver)
# Compiling front-end
@$(if $(findstring -kit,$@),export DOCKER_BUILDKIT=1;export COMPOSE_DOCKER_CLI_BUILD=1;,) \
$(MAKE) -C services/web/client clean compile$(if $(findstring -x,$@),-x,)
$(MAKE_C) services/web/client clean compile$(if $(findstring -x,$@),-x,)
endif
# Building service $(target)
@$(if $(findstring -kit,$@),export DOCKER_BUILDKIT=1;export COMPOSE_DOCKER_CLI_BUILD=1;,) \
Expand All @@ -114,7 +117,7 @@ else
ifeq ($(findstring webserver,$(target)),webserver)
# Compiling front-end
@$(if $(findstring -kit,$@),export DOCKER_BUILDKIT=1;export COMPOSE_DOCKER_CLI_BUILD=1;,) \
$(MAKE) -C services/web/client touch$(if $(findstring -x,$@),-x,) compile-dev
$(MAKE_C) services/web/client touch$(if $(findstring -x,$@),-x,) compile-dev
endif
# Building service $(target)
@$(if $(findstring -kit,$@),export DOCKER_BUILDKIT=1;export COMPOSE_DOCKER_CLI_BUILD=1;,) \
Expand All @@ -127,7 +130,7 @@ build-cache build-cache-nc build-cache-kit build-cache-x: .env ## Build cache im
ifeq ($(target),)
# Compiling front-end
@$(if $(findstring -kit,$@),export DOCKER_BUILDKIT=1;export COMPOSE_DOCKER_CLI_BUILD=1;,)
$(MAKE) -C services/web/client compile$(if $(findstring -x,$@),-x,)
$(MAKE_C) services/web/client compile$(if $(findstring -x,$@),-x,)
# Building cache images
@$(if $(findstring -kit,$@),export DOCKER_BUILDKIT=1;export COMPOSE_DOCKER_CLI_BUILD=1;,)
$(_docker_compose_build)
Expand Down Expand Up @@ -191,7 +194,7 @@ up-devel: .stack-simcore-development.yml .init-swarm $(CLIENT_WEB_OUTPUT) ## Dep
$(MAKE) .deploy-ops
# Start compile+watch front-end container [front-end]
$(if $(IS_WSL),$(warning WINDOWS: Do not forget to run scripts/win-watcher.bat in cmd),)
$(MAKE) -C services/web/client compile-dev flags=--watch
$(MAKE_C) services/web/client compile-dev flags=--watch

up-prod: .stack-simcore-production.yml .init-swarm ## Deploys local production stack and ops stack (pass 'make ops_disabled=1 up-...' to disable)
# Deploy stack $(SWARM_STACK_NAME)
Expand All @@ -215,7 +218,7 @@ down: ## Stops and removes stack
$(shell docker stack ls --format={{.Name}} | tac),\
docker stack rm $(stack);)
# Removing client containers (if any)
-$(MAKE) -C services/web/client down
-$(MAKE_C) services/web/client down
# Removing generated docker compose configurations, i.e. .stack-*
-$(shell rm $(wildcard .stack-*))

Expand Down Expand Up @@ -322,9 +325,9 @@ devenv: .venv ## create a python virtual environment with dev tools (e.g. linter

devenv-all: devenv ## sets up extra development tools (everything else besides python)
# Upgrading client compiler
@$(MAKE) --directory services/web/client upgrade
@$(MAKE_C) services/web/client upgrade
# Building tools
@$(MAKE) --directory scripts/json-schema-to-openapi-schema
@$(MAKE_C) scripts/json-schema-to-openapi-schema


## MISC -------------------------------
Expand All @@ -348,9 +351,9 @@ new-service: .venv ## Bakes a new project from cookiecutter-simcore-pyservice an

.PHONY: openapi-specs
openapi-specs: ## bundles and validates openapi specifications and schemas of ALL service's API
@$(MAKE) --directory services/web/server $@
@$(MAKE) --directory services/storage $@
@$(MAKE) --directory services/director $@
@$(MAKE_C) services/web/server $@
@$(MAKE_C) services/storage $@
@$(MAKE_C) services/director $@


.PHONY: code-analysis
Expand Down Expand Up @@ -397,7 +400,7 @@ ifeq ($(target),)
$(call show-meta,$(service))\
)
## Client images:
@$(MAKE) -C services/web/client info
@$(MAKE_C) services/web/client info
else
## $(target) images:
@$(call show-meta,$(target))
Expand Down Expand Up @@ -437,27 +440,27 @@ clean: .check-clean clean-venv ## cleans all unversioned files in project and te
# Cleaning unversioned
@git clean $(git_clean_args)
# Cleaning web/client
@$(MAKE) -C services/web/client clean
@$(MAKE_C) services/web/client clean
# Cleaning postgres maintenance
@$(MAKE) -C packages/postgres-database/docker clean
@$(MAKE_C) packages/postgres-database/docker clean

clean-images: ## removes all created images
# Cleaning all service images
-$(foreach service,$(SERVICES_LIST)\
,docker image rm -f $(shell docker images */$(service):* -q);)
# Cleaning webclient
@$(MAKE) -C services/web/client clean
@$(MAKE_C) services/web/client clean
# Cleaning postgres maintenance
@$(MAKE) -C packages/postgres-database/docker clean
@$(MAKE_C) packages/postgres-database/docker clean

clean-all: clean clean-images # Deep clean including .venv and produced images
-rm -rf .venv


.PHONY: postgres-upgrade
postgres-upgrade: ## initalize or upgrade postgres db to latest state
@$(MAKE) -C packages/postgres-database/docker build
@$(MAKE) -C packages/postgres-database/docker upgrade
@$(MAKE_C) packages/postgres-database/docker build
@$(MAKE_C) packages/postgres-database/docker upgrade

.PHONY: reset
reset: ## restart docker daemon (LINUX ONLY)
Expand Down
7 changes: 4 additions & 3 deletions services/web/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,10 @@ ENV SC_BUILD_TARGET development
ENV SIMCORE_WEB_OUTDIR /devel/services/web/client

WORKDIR /devel
VOLUME /devel/packages
VOLUME /devel/services/web/server/
VOLUME /devel/services/web/client/

# NOTE: declaring VOLUMEs here makes troubles mounting
# the client's output folder to /devel/services/web/client.
# The latter ls no files

ENTRYPOINT [ "/bin/sh", "services/web/server/docker/entrypoint.sh" ]
CMD ["/bin/sh", "services/web/server/docker/boot.sh"]
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def _middleware_handler(request: web.Request, handler):
resp = await handler(request)
log_exception = None

assert isinstance(resp, web.Response), "Forgot envelope middleware?" # nsec
assert isinstance(resp, web.StreamResponse), "Forgot envelope middleware?" # nsec

except web.HTTPServerError as exc:
# Transforms exception into response object and log exception
Expand All @@ -62,18 +62,17 @@ async def _middleware_handler(request: web.Request, handler):
log_exception = exc

finally:
assert isinstance( # nsec
resp, web.Response # nsec
), "Forgot envelope middleware or transformation?" # nsec

resp_time_secs: float = time.time() - request[kSTART_TIME]

exc_name = ""
if log_exception:
exc_name: str = log_exception.__class__.__name__

# Probes request latency
request.app[kLATENCY_PROBE].observe(resp_time_secs)
# NOTE: sockets connection is long
# FIXME: tmp by hand, add filters directly in probe
if not str(request.path).startswith("/socket.io"):
request.app[kLATENCY_PROBE].observe(resp_time_secs)

# prometheus probes
request.app[kREQUEST_LATENCY].labels(app_name, request.path).observe(
Expand Down