Skip to content

Commit

Permalink
Fixes related to EKS move and sessions table growing
Browse files Browse the repository at this point in the history
  • Loading branch information
yakloinsteak committed Jun 27, 2024
1 parent 4187930 commit 809f42d
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 13 deletions.
5 changes: 5 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ gem 'ajax_modal_rails', '~> 1.0'
gem 'sentry-rails', '~> 5.5'
gem 'warning'

gem 'yabeda-rails'
gem 'yabeda-prometheus'
gem 'yabeda-puma-plugin'
gem 'yabeda-http_requests'

group :development do
# gem 'spring'
gem 'capistrano'
Expand Down
32 changes: 32 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ GEM
rails (>= 4)
amazing_print (1.6.0)
ansi (1.5.0)
anyway_config (2.6.4)
ruby-next-core (~> 1.0)
ast (2.4.2)
attribute_normalizer (1.2.0)
authtrail (0.5.0)
Expand Down Expand Up @@ -300,6 +302,7 @@ GEM
dotenv-rails (3.1.0)
dotenv (= 3.1.0)
railties (>= 6.1)
dry-initializer (3.1.1)
erubi (1.12.0)
erubis (2.7.0)
execjs (2.9.1)
Expand Down Expand Up @@ -470,6 +473,7 @@ GEM
power_assert (2.0.3)
pretender (0.5.0)
actionpack (>= 6.1)
prometheus-client (4.2.2)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -604,6 +608,7 @@ GEM
ruby-filemagic (0.7.3)
ruby-graphviz (1.2.5)
rexml
ruby-next-core (1.0.3)
ruby-prof (1.7.0)
ruby-progressbar (1.13.0)
ruby-vips (2.2.1)
Expand Down Expand Up @@ -641,6 +646,9 @@ GEM
simpleidn (0.2.1)
unf (~> 0.1.4)
slack-notifier (2.4.0)
sniffer (0.5.0)
anyway_config (>= 1.0)
dry-initializer (~> 3)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand Down Expand Up @@ -704,6 +712,26 @@ GEM
zip_tricks (>= 4.5, < 6)
xpath (3.2.0)
nokogiri (~> 1.8)
yabeda (0.12.0)
anyway_config (>= 1.0, < 3)
concurrent-ruby
dry-initializer
yabeda-http_requests (0.2.1)
sniffer
yabeda
yabeda-prometheus (0.9.1)
prometheus-client (>= 3.0, < 5.0)
rack
yabeda (~> 0.10)
yabeda-puma-plugin (0.7.1)
json
puma
yabeda (~> 0.5)
yabeda-rails (0.9.0)
activesupport
anyway_config (>= 1.3, < 3)
railties
yabeda (~> 0.8)
zeitwerk (2.6.15)
zip_tricks (5.6.0)

Expand Down Expand Up @@ -843,6 +871,10 @@ DEPENDENCIES
whenever
with_advisory_lock
xlsxtream
yabeda-http_requests
yabeda-prometheus
yabeda-puma-plugin
yabeda-rails

BUNDLED WITH
2.4.13
9 changes: 1 addition & 8 deletions app/controllers/system_status_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ def ping
# Provide a path for nagios or other system checker to determine if the system is
# operational
def operational
user_count = User.all.count
if user_count.positive?
Rails.logger.info 'Operating system is operational'
render plain: 'OK'
else
Rails.logger.info 'Operating system is not operational'
render status: 500, plain: 'FAIL'
end
render plain: 'OK'
end

def cache_status
Expand Down
4 changes: 4 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@

# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart

activate_control_app
plugin :yabeda
plugin :yabeda_prometheus
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ def manage_matches
get :details
get :ping
end
get "healthz" => "system_status#operational"

resources :deidentified_clients do
resources :non_hmis_assessments do
Expand Down
6 changes: 6 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
frequency: 1.hours,
interruptable: true,
},
{
task: 'db:sesssions:trim',
frequency: 1.day,
at: '1:00 am',
interruptable: true,
},
]

job_type :rake_short, 'cd :path && :environment_variable=:environment bundle exec rake :task --silent #capacity_provider:short-term'
Expand Down
17 changes: 15 additions & 2 deletions config/setup_logging.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@
class SetupLogging
attr_accessor :config

STANDARD_TAGS = {
gr_client: "openpath",

# If there are more apps, these would differ. Some other examples:
# airflow, superset, or other microservices that would conceivably run on
# the same cluster and/or have some close relationship with the main application.
app: "cas",

# Some Green River clients have multiple tenants running the same general
# code (but with different databases or environment variables)
tenant: ENV.fetch('CLIENT', "unknown-client-set-CLIENT-env-var")
}

def initialize(config)
self.config = config
end
Expand Down Expand Up @@ -62,7 +75,7 @@ def call(severity, time, program_name, message)
rails_env: Rails.env,
request_time: time,
application: 'CAS',
}.reverse_merge(@tags).to_json + "\r\n"
}.merge(STANDARD_TAGS).reverse_merge(@tags).to_json + "\r\n"
end
end

Expand All @@ -89,7 +102,7 @@ def _configure_lograge
x_forwarded_for: event.payload[:x_forwarded_for],
rails_env: Rails.env,
exception: event.payload[:exception]&.first,
}
}.merge(STANDARD_TAGS)
end
end

Expand Down
4 changes: 2 additions & 2 deletions docker/app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ RUN gem update --system \
&& echo 'America/New_York' > /etc/timezone \
&& chmod a+w /etc/timezone

USER app-user
USER ${USER_ID}

CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"]

Expand Down Expand Up @@ -122,7 +122,7 @@ RUN git config --global --add safe.directory /app \
zsh \
&& rm -rf /var/cache/apk/*

USER app-user
USER ${USER_ID}

########################################
## Stage/target for use in production ##
Expand Down
2 changes: 1 addition & 1 deletion docker/app/database.open-path-cas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default: &default
username: <%= ENV['DATABASE_USER'] %>
password: <%= ENV['DATABASE_PASS'] %>
host: <%= ENV['DATABASE_HOST'] %>
sslmode: 'verify-full'
sslmode: <%= ENV.fetch('SSLMODE', 'verify-full') %>
sslrootcert: /etc/ssl/certs/us-east-1-bundle.pem

<%= ENV.fetch('RAILS_ENV') { 'unknown' } %>:
Expand Down

0 comments on commit 809f42d

Please sign in to comment.