naf 2.1.5 → 2.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,34 @@
1
1
  = Release Notes
2
2
 
3
+ === Version 2.1.6
4
+ Bug fixes:
5
+ * Historical jobs application_schedule_id was not getting set, causing the runner to constantly queue applications.
6
+ * Pagination of application schedules on the index page was not properly working.
7
+ * When mouse hovered over the application schedule on the applicaiton show page, it did not show a detailed information about the schedule.
8
+
9
+ Changes:
10
+ * Included application name when editing an application schedule
11
+
12
+ === Version 2.1.5
13
+ Bug fix:
14
+ * The code to manually add jobs/applications/schedules to the queue (::Logical::Naf::ConstructionZone::Boss) had an unecessary parameter that got passed into a call to create a job, thus raising an exception.
15
+
16
+ === Version 2.1.4
17
+ Bug fix:
18
+ * The Runner was using ruby Threads to write the logs of each running script. There was a specific script that caused write blocks and raised an EPIPE exception. The code is no longer using ruby Threads.
19
+
20
+ === Version 2.1.3
21
+ Bug fix:
22
+ * Migrations would fail if run all at once, because it did not consider the existence of the Janitor's Application Schedule. It would then fail, because run_interval is null, run_start_minute is dropped, and a not null constraint is set on run_interval.
23
+
24
+ === Version 2.1.2
25
+ Bug fix:
26
+ * Rescue EAGAIN and EWOULDBLOCK exceptions and log them.
27
+
28
+ === Version 2.1.1
29
+ Bug fix:
30
+ * When marking a machine down, it logs the id of the machine doing the action. But if this machine does not have an associated row in naf.machines, it raises an exception.
31
+
3
32
  === Version 2.1.0
4
33
 
5
34
  Featurs/Changes:
@@ -11,7 +40,7 @@ Featurs/Changes:
11
40
 
12
41
  === Version 2.0.0
13
42
 
14
- Featurs/Changes:
43
+ Features/Changes:
15
44
  * New logging system
16
45
  * Removed compatibility with Papertrail
17
46
  * UI changes
@@ -1,10 +1,14 @@
1
1
  module Naf
2
2
  class ApplicationSchedulesController < Naf::ApplicationController
3
3
 
4
+ before_filter :set_rows_per_page
5
+
4
6
  def index
5
7
  respond_to do |format|
6
8
  format.html
7
9
  format.json do
10
+ set_page
11
+
8
12
  application_schedules = []
9
13
  application_schedule = []
10
14
  @total_records = Naf::ApplicationSchedule.count(:all)
@@ -130,7 +130,7 @@ module Logical
130
130
  if schedule.run_interval_style.name == 'at beginning of day'
131
131
  output = exact_time_of_day(time)
132
132
  else
133
- output = interval_time2(time)
133
+ output = interval_time(time)
134
134
  end
135
135
 
136
136
  output
@@ -147,7 +147,7 @@ module Logical
147
147
  return output
148
148
  end
149
149
 
150
- def interval_time2(time)
150
+ def interval_time(time)
151
151
  if time < 9
152
152
  ":0#{time}"
153
153
  else
@@ -155,16 +155,6 @@ module Logical
155
155
  end
156
156
  end
157
157
 
158
- def interval_time(time)
159
- if time < 60
160
- pluralize(time, 'minute')
161
- elsif time % 60 == 0
162
- pluralize(time / 60, 'hour')
163
- else
164
- pluralize(time / 60, 'hour') + ', ' + pluralize(time % 60, 'minute')
165
- end
166
- end
167
-
168
158
  def application_run_group_name
169
159
  if schedule.application_run_group_name.present?
170
160
  schedule.application_run_group_name
@@ -27,6 +27,7 @@ module Logical::Naf::ConstructionZone
27
27
 
28
28
  def create_queued_job(historical_job)
29
29
  queued_job = ::Naf::QueuedJob.new(application_id: historical_job.application_id,
30
+ application_schedule_id: historical_job.application_schedule_id,
30
31
  application_type_id: historical_job.application_type_id,
31
32
  command: historical_job.command,
32
33
  application_run_group_restriction_id: historical_job.application_run_group_restriction_id,
@@ -49,6 +49,7 @@ module Logical::Naf::ConstructionZone
49
49
  application_run_group_limit: application_run_group_limit,
50
50
  priority: priority,
51
51
  application_id: application.try(:id),
52
+ application_schedule_id: application_schedule.try(:id)
52
53
  }
53
54
  end
54
55
 
@@ -57,26 +58,25 @@ module Logical::Naf::ConstructionZone
57
58
  if affinity.is_a? Symbol
58
59
  # short_name of affinity
59
60
  affinity_object = {
60
- :affinity_id => ::Naf::Affinity.find_by_affinity_short_name(affinity).try(:id)
61
+ affinity_id: ::Naf::Affinity.find_by_affinity_short_name(affinity).try(:id)
61
62
  }
62
63
  raise "no affinity provided" if affinity_object[:affinity_id].nil?
63
64
  affinity_object
64
65
  elsif affinity.is_a? ::Naf::Affinity
65
66
  {
66
- :affinity_id => affinity.id
67
+ affinity_id: affinity.id
67
68
  }
68
69
  elsif affinity.is_a? ::Naf::Machine
69
70
  # affinity_for machine
70
71
  {
71
- :affinity_id => affinity.affinity.id
72
+ affinity_id: affinity.affinity.id
72
73
  }
73
74
  elsif affinity.is_a? ::Naf::ApplicationScheduleAffinityTab
74
75
  # affinity_for application_schedule_affinity_tab
75
76
  elsif affinity.is_a? Hash
76
77
  # should have key: :affinity_id or :affinity_short_name or :affinity_name
77
78
  # may have key: :affinity_parameter
78
- affinity_object = {
79
- }
79
+ affinity_object = {}
80
80
  if affinity.has_key?(:affinity_id)
81
81
  affinity_object[:affinity_id] = affinity[:affinity_id]
82
82
  elsif affinity.has_key?(:affinity_name)
@@ -7,6 +7,11 @@
7
7
 
8
8
  <%= f.hidden_field :application_id, value: @application_schedule.application_id %>
9
9
 
10
+ <div class="field">
11
+ <%= f.label "Application" %>
12
+ <p><%= @application_schedule.application.title %></p>
13
+ </div>
14
+
10
15
  <div class="field">
11
16
  <%= f.label :application_run_group_restriction_id, "Application run group restriction*" %>
12
17
  <%= f.select(:application_run_group_restriction_id,
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
 
12
12
  <div id="record">
13
- <h2>Application</h2>
13
+ <h2>Application Schedule</h2>
14
14
  <%= link_to 'Back to Application Schedules', application_schedules_path %>
15
15
  &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;
16
16
  <%= link_to 'Edit', controller: 'application_schedules',
@@ -102,7 +102,9 @@
102
102
  <% output = '' %>
103
103
  <% @logical_application.application_schedules.each do |schedule|
104
104
  logical_schedule = ::Logical::Naf::ApplicationSchedule.new(schedule)
105
- output << (link_to logical_schedule.display, naf.application_schedule_path(schedule.id))
105
+ output << (link_to logical_schedule.display,
106
+ naf.application_schedule_path(schedule.id),
107
+ title: logical_schedule.help_title)
106
108
  output << ', '
107
109
  end
108
110
  output = output[0..-3] %>
@@ -1,3 +1,3 @@
1
1
  module Naf
2
- VERSION = "2.1.5"
2
+ VERSION = '2.1.6'
3
3
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.name = "naf"
9
9
  s.version = Naf::VERSION
10
10
  s.license = 'New BSD License'
11
- s.date = '2014-02-26'
11
+ s.date = '2014-03-05'
12
12
  s.summary = "Creates infrastructure for a customizable and robust Postgres-backed script scheduling/running"
13
13
  s.description = "A cloud based distributed cron, application framework and operations console. Naf works as a distributed script running " +
14
14
  "system that provides scheduling, logging, alarming, machine redundancy, and the ability to set constraint during script execution"
@@ -34,4 +34,8 @@ Dummy::Application.configure do
34
34
 
35
35
  # Print deprecation notices to the stderr
36
36
  config.active_support.deprecation = :stderr
37
+
38
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
39
+ # the I18n.default_locale when a translation can not be found)
40
+ config.i18n.enforce_available_locales = false
37
41
  end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ module Logical::Naf::ConstructionZone
4
+
5
+ describe WorkOrder do
6
+ let(:command) { '::Process::Naf::Janitor.run' }
7
+ let!(:work_order) {
8
+ ::Logical::Naf::ConstructionZone::WorkOrder.new(command)
9
+ }
10
+
11
+ describe '#historical_job_parameters' do
12
+ let(:params) {
13
+ {
14
+ command: command,
15
+ application_type_id: ::Naf::ApplicationType.rails.id,
16
+ application_run_group_restriction_id: ::Naf::ApplicationRunGroupRestriction.limited_per_all_machines.id,
17
+ application_run_group_name: command,
18
+ application_run_group_limit: 1,
19
+ priority: 0,
20
+ application_id: nil,
21
+ application_schedule_id: nil
22
+ }
23
+ }
24
+ it 'return correct values' do
25
+ work_order.historical_job_parameters.should == params
26
+ end
27
+ end
28
+
29
+ describe '#historical_job_affinity_tab_parameters' do
30
+ it 'return hash with the affinity_id when a symbol is provided' do
31
+ affinity = FactoryGirl.create(:affinity, id: 4, affinity_short_name: :small)
32
+ work_order.instance_variable_set(:@affinities, [:small])
33
+ work_order.historical_job_affinity_tab_parameters.
34
+ should == [{ affinity_id: affinity.id }]
35
+ end
36
+
37
+ it 'raise an exception when there is not an object associated with the symbol' do
38
+ work_order.instance_variable_set(:@affinities, [:small])
39
+ expect { work_order.historical_job_affinity_tab_parameters }.
40
+ to raise_error 'no affinity provided'
41
+ end
42
+
43
+ it 'return hash with the affinity_id when an Affinity object is provided' do
44
+ affinity = ::Naf::Affinity.first
45
+ work_order.instance_variable_set(:@affinities, [affinity])
46
+ work_order.historical_job_affinity_tab_parameters.
47
+ should == [{ affinity_id: affinity.id }]
48
+ end
49
+
50
+ it 'return hash with the affinity_id when a Machine object is provided' do
51
+ machine = FactoryGirl.create(:machine)
52
+ classification = FactoryGirl.create(:location_affinity_classification)
53
+ affinity = FactoryGirl.create(:affinity, id: 4,
54
+ affinity_name: machine.id.to_s,
55
+ affinity_classification: classification)
56
+ work_order.instance_variable_set(:@affinities, [machine])
57
+ work_order.historical_job_affinity_tab_parameters.
58
+ should == [{ affinity_id: affinity.id }]
59
+ end
60
+
61
+ it 'return nil when an ApplicationScheduleAffintyTab object is provided' do
62
+ tab = FactoryGirl.build(:app_schedule_affinity_tab_base)
63
+ work_order.instance_variable_set(:@affinities, [tab])
64
+ work_order.historical_job_affinity_tab_parameters.should == [nil]
65
+ end
66
+
67
+ it 'return hash with the affinity_id when a Hash object is provided' do
68
+ affinity = { affinity_id: 1 }
69
+ work_order.instance_variable_set(:@affinities, [affinity])
70
+ work_order.historical_job_affinity_tab_parameters.should == [affinity]
71
+ end
72
+
73
+ it 'raise an exception when a empty Hash object is provided' do
74
+ work_order.instance_variable_set(:@affinities, [{}])
75
+ expect { work_order.historical_job_affinity_tab_parameters }.
76
+ to raise_error 'no affinity provided'
77
+ end
78
+
79
+ it 'raise an exception when a unknown object is provided' do
80
+ work_order.instance_variable_set(:@affinities, [[]])
81
+ expect { work_order.historical_job_affinity_tab_parameters }.
82
+ to raise_error 'unknown affinity kind: []'
83
+ end
84
+ end
85
+
86
+ describe '#historical_job_parameters' do
87
+ it 'raise an exception when a non historical job is in prerequisites' do
88
+ work_order.instance_variable_set(:@prerequisites, [1])
89
+ expect { work_order.historical_job_prerequisite_historical_jobs }.
90
+ to raise_error "found a non Naf::HistoricalJob in prerequisites: 1"
91
+ end
92
+
93
+ it 'not raise an exception when a historical job is in prerequisites' do
94
+ historical_job = FactoryGirl.build(:job_base)
95
+ work_order.instance_variable_set(:@prerequisites, [historical_job])
96
+ work_order.historical_job_prerequisite_historical_jobs.should == [historical_job]
97
+ end
98
+
99
+ it 'not raise an exception when prerequisites is empty' do
100
+ work_order.historical_job_prerequisite_historical_jobs.should == []
101
+ end
102
+ end
103
+
104
+ end
105
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: naf
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.5
4
+ version: 2.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-02-26 00:00:00.000000000 Z
15
+ date: 2014-03-05 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rails
@@ -485,6 +485,7 @@ files:
485
485
  - spec/factories/naf.rb
486
486
  - spec/helpers/naf/application_helper_spec.rb
487
487
  - spec/models/logical/naf/application_spec.rb
488
+ - spec/models/logical/naf/construction_zone/work_order_spec.rb
488
489
  - spec/models/logical/naf/job_fetcher_spec.rb
489
490
  - spec/models/logical/naf/job_spec.rb
490
491
  - spec/models/logical/naf/log_file_spec.rb
@@ -599,6 +600,7 @@ test_files:
599
600
  - spec/factories/naf.rb
600
601
  - spec/helpers/naf/application_helper_spec.rb
601
602
  - spec/models/logical/naf/application_spec.rb
603
+ - spec/models/logical/naf/construction_zone/work_order_spec.rb
602
604
  - spec/models/logical/naf/job_fetcher_spec.rb
603
605
  - spec/models/logical/naf/job_spec.rb
604
606
  - spec/models/logical/naf/log_file_spec.rb