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

Remove duplicate logging #785

Merged
merged 2 commits into from
Jun 27, 2023
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
3 changes: 1 addition & 2 deletions Dockerfile.development
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ WORKDIR $APP_HOME
COPY Gemfile $APP_HOME/
COPY Gemfile.lock $APP_HOME/

RUN bundle config set without 'development test' && \
MAKE="make -j $(nproc)" bundle install -j $(nproc)
RUN MAKE="make -j $(nproc)" bundle install -j $(nproc)

FROM --platform=linux/amd64 ruby:2.7.7

Expand Down
21 changes: 17 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,24 @@ init:
build: init
docker-compose build
setup: build
docker-compose run --rm web bash -c 'export MAKE="make -j `nproc`" && bundle install -j `nproc`'
docker-compose run --rm web bundle exec bin/setup
docker-compose run --rm -e BUNDLE_IGNORE_CONFIG=true test bash -c 'export MAKE="make -j `nproc`" && bundle install -j `nproc`'
docker-compose run --rm test bundle exec bin/setup
docker-compose stop
docker-compose down
up: init
docker-compose up -d
restart:
docker-compose restart web worker
docker-compose restart web worker test
dbreset: down
docker volume rm -f barcelona_pgdata
docker-compose up -d
docker-compose run --rm test bundle exec bin/setup
down:
# make sure e2e process is not attached to this network
docker ps -a | grep barcelona-e2e-e2e | cut -d' ' -f1 | xargs docker rm -f
docker-compose down -t 0
bundle-reset: down
docker volume rm -f barcelona_bundle
docker volume ls
docker-compose run --rm -e BUNDLE_IGNORE_CONFIG=true test bash -c 'export MAKE="make -j `nproc`" && bundle install -j `nproc`'
test:
docker-compose run --rm -e RAILS_ENV=test test bundle exec rspec -f d
20 changes: 13 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.5'
version: '3.8'
services:
web: &app_base
depends_on:
Expand All @@ -9,15 +9,15 @@ services:
dockerfile: Dockerfile
ports:
- "3333:3333"
command: rails s -b 0.0.0.0
command: rails s -b 0.0.0.0 -P /tmp/server.pid
stdin_open: true
tty: true
links:
- db
- vault
volumes:
- bundle:/usr/local/bundle
# - .:/app
- .:/app
environment: &env_base
PORT: 3333
DATABASE_URL: postgres://postgres:@db:5432
Expand All @@ -29,17 +29,23 @@ services:
# Uncomment to use vault auth
# VAULT_URL: http://vault:8200
# VAULT_PATH_PREFIX: degica
worker:
<<: *app_base
ports: []
command: rake jobs:work
volumes:
- bundle:/usr/local/bundle
- .:/app
test:
<<: *app_base
build:
context: .
dockerfile: Dockerfile.development
ports: []
command: sleep infinity
worker:
<<: *app_base
ports: []
command: rake jobs:work
volumes:
- bundle:/usr/local/bundle
- .:/app
db:
image: postgres:11
environment:
Expand Down
12 changes: 0 additions & 12 deletions lib/barcelona/plugins/datadog_logs_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,6 @@ def on_container_instance_user_data(_instance, user_data)
user_data
end

def on_heritage_task_definition(_heritage, task_definition)
task_definition.merge(
log_configuration: {
log_driver: "syslog",
options: {
"syslog-address" => "tcp://127.0.0.1:#{LOCAL_LOGGER_PORT}",
"tag" => "{{.FullID}}_#{task_definition[:name]}"
}
}
)
end

def on_network_stack_template(_stack, template)
bastion_lc = template["BastionLaunchConfiguration"]
return template if bastion_lc.nil?
Expand Down
14 changes: 14 additions & 0 deletions lib/barcelona/plugins/datadog_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,19 @@ def on_container_instance_user_data(_instance, user_data)

private

def on_heritage_task_definition(_heritage, task_definition)
# disable awslogs, but make sure logs do not fill up disk
task_definition.merge(
log_configuration: {
log_driver: "json-file",
options: {
"max-size" => "1m",
"tag" => "{{.FullID}}_#{task_definition[:name]}"
}
}
)
end

def agent_command
[
"DD_AGENT_MAJOR_VERSION=7 DD_API_KEY=#{api_key} bash -c",
Expand All @@ -27,6 +40,7 @@ def api_key
end

def add_files!(user_data)
# this seems to be added to the bastion instance as well. "role:app" should probably be "role:bastion" to be accurate
user_data.add_file("/etc/datadog-agent/datadog.yaml", "root:root", "000755", <<~DATADOG_YAML)
api_key: #{api_key}
logs_enabled: true
Expand Down
48 changes: 25 additions & 23 deletions lib/barcelona/plugins/logentries_plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@ class LogentriesPlugin < Base
"service rsyslog restart"
]

def on_container_instance_user_data(_instance, user_data)
update_user_data(user_data, "app")
user_data
end
# NOTE: disabling this temporarily until we delete the plugin

def on_heritage_task_definition(_heritage, task_definition)
task_definition.merge(
log_configuration: {
log_driver: "syslog",
options: {
"syslog-address" => "tcp://127.0.0.1:#{LOCAL_LOGGER_PORT}",
"tag" => "{{.FullID}}_#{task_definition[:name]}"
}
}
)
end
# def on_container_instance_user_data(_instance, user_data)
# update_user_data(user_data, "app")
# user_data
# end

def on_network_stack_template(_stack, template)
bastion_lc = template["BastionLaunchConfiguration"]
return template if bastion_lc.nil?
# def on_heritage_task_definition(_heritage, task_definition)
# task_definition.merge(
# log_configuration: {
# log_driver: "syslog",
# options: {
# "syslog-address" => "tcp://127.0.0.1:#{LOCAL_LOGGER_PORT}",
# "tag" => "{{.FullID}}_#{task_definition[:name]}"
# }
# }
# )
# end

user_data = InstanceUserData.load_or_initialize(bastion_lc["Properties"]["UserData"])
update_user_data(user_data, "bastion")
bastion_lc["Properties"]["UserData"] = user_data.build
template
end
# def on_network_stack_template(_stack, template)
# bastion_lc = template["BastionLaunchConfiguration"]
# return template if bastion_lc.nil?

# user_data = InstanceUserData.load_or_initialize(bastion_lc["Properties"]["UserData"])
# update_user_data(user_data, "bastion")
# bastion_lc["Properties"]["UserData"] = user_data.build
# template
# end

private

Expand Down
52 changes: 0 additions & 52 deletions spec/lib/barcelona/plugins/logentries_plugin_spec.rb

This file was deleted.