Skip to content

Commit

Permalink
Merge pull request ManageIQ#74 from Fryguy/github_actions_cron
Browse files Browse the repository at this point in the history
Cron for GitHub Actions
  • Loading branch information
bdunne authored and Fryguy committed Mar 17, 2022
2 parents 1fb0a94 + 7489779 commit 0a0ac62
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 36 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
name: CI

on: [push, pull_request]
on:
push:
pull_request:
schedule:
- cron: '0 0 * * 0'

jobs:
ci:
Expand Down
1 change: 0 additions & 1 deletion amazon_ssa_support.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Gem::Specification.new do |spec|
spec.add_dependency "aws-sdk-sqs", "~> 1.0"
spec.add_dependency "aws-sdk-ec2", "~> 1.0"
spec.add_dependency "aws-sdk-s3", "~> 1.0"
spec.add_dependency "log_decorator", "~> 0.1"
spec.add_dependency "manageiq-gems-pending", "~> 0"
spec.add_dependency "manageiq-smartstate", "~> 0.2"

Expand Down
19 changes: 6 additions & 13 deletions bin/amazon_ssa_agent
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ end
require 'yaml'
aws_args = YAML.load(File.read("#{work_dir}/config.yml"))

# Logging must be set up very early because log_decorator will apply to
# all classes after it's required.
require 'amazon_ssa_support/rolling_s3_logger'
log_filename = File.join(work_dir, "extract.log")
log_max_size = (log_max_size || aws_args[:log_max_size] || 1_048_576).to_i
Expand All @@ -54,11 +52,6 @@ at_exit do
Dir.glob("#{log_filename}*").each { |f| File.delete(f) }
end

require 'log_decorator'
::Module.include(LogDecorator::Logging::ClassMethods)
include LogDecorator::Logging
LogDecorator.logger = $log

require 'aws-sdk-ec2'
require 'aws-sdk-sqs'
require 'aws-sdk-s3'
Expand Down Expand Up @@ -99,7 +92,7 @@ begin
#
eqe = AmazonSsaSupport::SsaQueueExtractor.new(aws_args)

_log.info("Agent starts to process requests ...")
$log.info("Agent starts to process requests ...")

begin
exit_code = eqe.extract_loop(timeout)
Expand All @@ -109,19 +102,19 @@ begin
#
case exit_code
when :exit
_log.info("Exiting")
$log.info("Exiting")
ehb.stop_heartbeat_loop
when :reboot
_log.info("Rebooting")
$log.info("Rebooting")
ehb.stop_heartbeat_loop
aws_args[:ec2].instance(extractor_id).stop
when :shutdown
_log.info("Shutting down")
$log.info("Shutting down")
ehb.stop_heartbeat_loop
aws_args[:ec2].instance(extractor_id).stop
end
rescue => err
_log.error("ERROR: #{err}")
_log.error(err.backtrace.join("\n"))
$log.error("ERROR: #{err}")
$log.error(err.backtrace.join("\n"))
end
end
3 changes: 1 addition & 2 deletions lib/amazon_ssa_support.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require 'manageiq-smartstate'

require 'log_decorator'

require 'amazon_ssa_support/version'
require 'amazon_ssa_support/logging'
require 'amazon_ssa_support/ssa_common'
require 'amazon_ssa_support/instance_metadata'
require 'amazon_ssa_support/ssa_bucket.rb'
Expand Down
2 changes: 1 addition & 1 deletion lib/amazon_ssa_support/instance_metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module AmazonSsaSupport
class InstanceMetadata
include LogDecorator::Logging
include Logging

def initialize(version = 'latest')
@base_url = 'http://169.254.169.254/'
Expand Down
22 changes: 22 additions & 0 deletions lib/amazon_ssa_support/logging.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
module AmazonSsaSupport
class << self
attr_writer :logger
end

def self.logger
@logger ||= $log || begin
require 'logger'
Logger.new(STDOUT)
end
end

module Logging
def self.included(base)
base.extend(self)
end

def _log
AmazonSsaSupport.logger
end
end
end
2 changes: 1 addition & 1 deletion lib/amazon_ssa_support/miq_ec2_vm/miq_ec2_ebs_vmbase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module AmazonSsaSupport
class MiqEC2EbsVmBase < MiqEC2VmBase
include LogDecorator::Logging
include Logging

attr_reader :volumes

Expand Down
2 changes: 1 addition & 1 deletion lib/amazon_ssa_support/ssa_bucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module AmazonSsaSupport
module SsaBucket
include LogDecorator::Logging
include Logging

def self.get(arg_hash)
raise ArgumentError, "Bucket and region must be specified." unless arg_hash[:ssa_bucket] && arg_hash[:region]
Expand Down
3 changes: 1 addition & 2 deletions lib/amazon_ssa_support/ssa_heartbeat.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
require 'yaml'
require 'aws-sdk-s3'

require 'log_decorator'
require_relative 'ssa_common'
require_relative 'ssa_bucket'

module AmazonSsaSupport
class SsaHeartbeat
include LogDecorator::Logging
include Logging

attr_reader :extractor_id, :heartbeat_prefix
attr_reader :heartbeat_thread, :heartbeat_interval
Expand Down
2 changes: 1 addition & 1 deletion lib/amazon_ssa_support/ssa_queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

module AmazonSsaSupport
class SsaQueue
include LogDecorator::Logging
include Logging

attr_reader :ssa_bucket_name, :ssa_region, :request_queue_name, :reply_queue_name, :reply_bucket_name, :extractor_id
attr_reader :request_queue, :reply_queue, :reply_bucket, :reply_prefix, :sqs
Expand Down
2 changes: 1 addition & 1 deletion lib/amazon_ssa_support/ssa_queue_extractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

module AmazonSsaSupport
class SsaQueueExtractor
include LogDecorator::Logging
include Logging

CATEGORIES = %w(accounts services software system).freeze
attr_reader :my_instance, :ssaq
Expand Down
3 changes: 0 additions & 3 deletions spec/miq_ec2_vm/miq_ec2_ebs_instance_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require_relative '../spec_helper'
require_relative '../aws_ssa_commons'

::Module.include(LogDecorator::Logging::ClassMethods)
include LogDecorator::Logging

describe AmazonSsaSupport::MiqEC2EbsInstance do
before :each do
@eb2_obj = mocked_ebs_instance('i-mocked-1')
Expand Down
3 changes: 0 additions & 3 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
SimpleCov.start
end

$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)

require 'bundler/setup'
require 'amazon_ssa_support'

RSpec.configure do |config|
Expand Down
3 changes: 0 additions & 3 deletions spec/ssa_heartbeat_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require_relative 'spec_helper'
require_relative 'aws_ssa_commons'

::Module.include(LogDecorator::Logging::ClassMethods)
include LogDecorator::Logging

describe AmazonSsaSupport::SsaHeartbeat do
before(:each) do
Aws.config[:s3] = {
Expand Down
3 changes: 0 additions & 3 deletions spec/ssa_queue_spec.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
require_relative 'spec_helper'
require_relative 'aws_ssa_commons'

::Module.include(LogDecorator::Logging::ClassMethods)
include LogDecorator::Logging

describe AmazonSsaSupport::SsaQueue do
before(:each) do
config_aws_client_stub
Expand Down

0 comments on commit 0a0ac62

Please sign in to comment.