Skip to content

Commit

Permalink
Use external http saver service directly
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed May 22, 2021
1 parent 10aa4c8 commit eb6617e
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .circleci/k8s-general-values.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,5 @@ containers:
env:
CYBER_DOJO_PROMETHEUS: "true"
CYBER_DOJO_DIFFER_PORT: "4567"
CYBER_DOJO_MODEL_PORT: "4528"
CYBER_DOJO_SAVER_PORT: "4537"
# CYBER_DOJO_K8S_PORT: "19661"
1 change: 0 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ CYBER_DOJO_LANGUAGES_START_POINTS_PORT=4524
CYBER_DOJO_CREATOR_PORT=4523
CYBER_DOJO_DASHBOARD_PORT=4527
CYBER_DOJO_DIFFER_PORT=4567
CYBER_DOJO_MODEL_PORT=4528
CYBER_DOJO_NGINX_PORT=80
CYBER_DOJO_REPLER_PORT=4657
CYBER_DOJO_RUNNER_PORT=4597
Expand Down
4 changes: 2 additions & 2 deletions app/external/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module External
class Model

def initialize(externals)
hostname = 'model'
hostname = 'saver'
@port = ENV[port_env_var].to_i
@http = HttpJsonHash::service(self.class.name, externals.model_http, hostname, port)
end
Expand Down Expand Up @@ -42,7 +42,7 @@ def k8s_port_env_var
=end

def docker_port_env_var
'CYBER_DOJO_MODEL_PORT'
'CYBER_DOJO_SAVER_PORT'
end

end
Expand Down
6 changes: 3 additions & 3 deletions client/app/model_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module External
class ModelService

def initialize
hostname = 'model'
port = ENV['CYBER_DOJO_MODEL_PORT'].to_i
@http = HttpJsonHash::service('model', hostname, port)
hostname = 'saver'
port = ENV['CYBER_DOJO_SAVER_PORT'].to_i
@http = HttpJsonHash::service('saver', hostname, port)
end

# - - - - - - - - - - - - - - - - - - -
Expand Down
3 changes: 1 addition & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ services:
user: ${CYBER_DOJO_DIFFER_CLIENT_USER}
depends_on:
- differ_server
- model
env_file: [ .env ]
ports: [ "${CYBER_DOJO_DIFFER_CLIENT_PORT}:${CYBER_DOJO_DIFFER_CLIENT_PORT}" ]
read_only: true
Expand All @@ -29,7 +28,7 @@ services:
container_name: ${CYBER_DOJO_DIFFER_SERVER_CONTAINER_NAME}
user: ${CYBER_DOJO_DIFFER_SERVER_USER}
depends_on:
- model
- saver
env_file: [ .env ]
ports: [ "${CYBER_DOJO_DIFFER_PORT}:${CYBER_DOJO_DIFFER_PORT}" ]
read_only: true
Expand Down
1 change: 0 additions & 1 deletion scripts/augmented_docker_compose.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ augmented_docker_compose()
local -r project_name=cyber_dojo
cd "${ROOT_DIR}" && cat "./docker-compose.yml" \
| docker run --rm --interactive cyberdojo/service-yaml \
model \
saver \
| tee /tmp/augmented-docker-compose.differ.peek.yml \
| docker-compose \
Expand Down
26 changes: 16 additions & 10 deletions scripts/containers_up_healthy_and_clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,29 @@ healthy()
exit_non_zero_unless_started_cleanly()
{
echo
local DOCKER_LOG=$(docker logs "${CONTAINER_NAME}" 2>&1)
local -r log=$(docker logs "${CONTAINER_NAME}" 2>&1)

# Handle known warnings (eg waiting on Gem upgrade)
#local -r SHADOW_WARNING="server.rb:(.*): warning: shadowing outer local variable - filename"
#DOCKER_LOG=$(strip_known_warning "${DOCKER_LOG}" "${SHADOW_WARNING}")


local -r line_count=$(echo -n "${log}" | grep -c '^')
if [ "${CONTAINER_NAME}" == "${CYBER_DOJO_DIFFER_SERVER_CONTAINER_NAME}" ]; then
local -r lines=6
fi
if [ "${CONTAINER_NAME}" == "${CYBER_DOJO_DIFFER_CLIENT_CONTAINER_NAME}" ]; then
local -r lines=6
fi

echo "Checking if ${SERVICE_NAME} started cleanly."
local -r top6=$(echo "${DOCKER_LOG}" | head -6)
if [ "${top6}" == "$(clean_top_6)" ]; then
echo "${SERVICE_NAME} started cleanly."
echo
if [ "${line_count}" == "${lines}" ]; then
echo 'OK'
else
echo "${SERVICE_NAME} did not start cleanly."
echo "First 10 lines of: docker logs ${CONTAINER_NAME}"
echo
echo "${DOCKER_LOG}" | head -10
echo
echo 'FAIL'
echo "Expecting ${lines} lines"
echo " Actual ${line_count} lines"
echo_docker_log
exit 42
fi
}
Expand Down
4 changes: 2 additions & 2 deletions test/model_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ module Test
class ModelService

def initialize
hostname = 'model'
port = ENV['CYBER_DOJO_MODEL_PORT'].to_i
hostname = 'saver'
port = ENV['CYBER_DOJO_SAVER_PORT'].to_i
@http = ::Test::HttpJsonHash::service(hostname, port)
end

Expand Down

0 comments on commit eb6617e

Please sign in to comment.