Skip to content

Commit a10f7ae

Browse files
committed
Show dependencies in execution plan details
1 parent e33bde2 commit a10f7ae

File tree

4 files changed

+57
-3
lines changed

4 files changed

+57
-3
lines changed

lib/dynflow/persistence.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,14 @@ def find_old_execution_plans(age)
9797
end
9898
end
9999

100+
def find_execution_plan_dependencies(execution_plan_id)
101+
adapter.find_execution_plan_dependencies(execution_plan_id)
102+
end
103+
104+
def find_blocked_execution_plans(execution_plan_id)
105+
adapter.find_blocked_execution_plans(execution_plan_id)
106+
end
107+
100108
def find_ready_delayed_plans(time)
101109
adapter.find_ready_delayed_plans(time).map do |plan|
102110
DelayedPlan.new_from_hash(@world, plan)

lib/dynflow/persistence_adapters/abstract.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ def save_execution_plan(execution_plan_id, value)
6868
raise NotImplementedError
6969
end
7070

71+
def find_execution_plan_dependencies(execution_plan_id)
72+
raise NotImplementedError
73+
end
74+
75+
def find_blocked_execution_plans(execution_plan_id)
76+
raise NotImplementedError
77+
end
78+
7179
def find_ready_delayed_plans(options = {})
7280
raise NotImplementedError
7381
end

lib/dynflow/persistence_adapters/sequel.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,13 +140,25 @@ def find_old_execution_plans(age)
140140
.all.map { |plan| execution_plan_column_map(load_data plan, table_name) }
141141
end
142142

143+
def find_execution_plan_dependencies(execution_plan_id)
144+
table(:execution_plan_dependency)
145+
.where(execution_plan_uuid: execution_plan_id)
146+
.select_map(:blocked_by_uuid)
147+
end
148+
149+
def find_blocked_execution_plans(execution_plan_id)
150+
table(:execution_plan_dependency)
151+
.where(blocked_by_uuid: execution_plan_id)
152+
.select_map(:execution_plan_uuid)
153+
end
154+
143155
def find_ready_delayed_plans(time)
144156
table_name = :delayed
145157
# Subquery to find delayed plans that have at least one non-stopped dependency
146158
plans_with_unfinished_deps = table(:execution_plan_dependency)
147-
.join(TABLES[:execution_plan], uuid: :blocked_by_uuid)
148-
.where(::Sequel.~(state: 'stopped'))
149-
.select(:execution_plan_uuid)
159+
.join(TABLES[:execution_plan], uuid: :blocked_by_uuid)
160+
.where(::Sequel.~(state: 'stopped'))
161+
.select(:execution_plan_uuid)
150162

151163
table(table_name)
152164
.where(::Sequel.lit('start_at IS NULL OR (start_at <= ? OR (start_before IS NOT NULL AND start_before <= ?))', time, time))

web/views/show.erb

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,32 @@
4343
<%= h(@plan.ended_at) %>
4444
</p>
4545

46+
<% if @plan.state == :scheduled && @plan.delay_record %>
47+
<% dependencies = @plan.world.persistence.find_execution_plan_dependencies(@plan.id) %>
48+
<% if dependencies.any? %>
49+
<p>
50+
<b>Waiting for execution plans:</b>
51+
<ul>
52+
<% dependencies.each do |dep_id| %>
53+
<li><a href="<%= url("/#{dep_id}") %>"><%= h(dep_id) %></a></li>
54+
<% end %>
55+
</ul>
56+
</p>
57+
<% end %>
58+
<% end %>
59+
60+
<% blocked_plans = @plan.world.persistence.find_blocked_execution_plans(@plan.id) %>
61+
<% if blocked_plans.any? %>
62+
<p>
63+
<b>Blocks execution plans:</b>
64+
<ul>
65+
<% blocked_plans.each do |dep_id| %>
66+
<li><a href="<%= url("/#{dep_id}") %>"><%= h(dep_id) %></a></li>
67+
<% end %>
68+
</ul>
69+
</p>
70+
<% end %>
71+
4672
<ul class="phases nav nav-tabs" id="myTab">
4773
<li><a href="#plan">Plan</a></li>
4874
<li class="active"><a href="#run">Run</a></li>

0 commit comments

Comments
 (0)