Skip to content

Commit d7eb079

Browse files
committed
fix: always use primary runtime
1 parent 2d74002 commit d7eb079

3 files changed

Lines changed: 10 additions & 31 deletions

File tree

app/grpc/execution_handler.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,7 @@ def handle_execution_result(execution_result, runtime_id)
7474
execution_identifier: execution_result.execution_identifier
7575
)
7676

77-
response = Namespaces::Projects::Flows::PersistExecutionResultService.new(
78-
execution_result,
79-
runtime_id: runtime_id
80-
).execute
77+
response = Namespaces::Projects::Flows::PersistExecutionResultService.new(execution_result).execute
8178
return if response.success?
8279

8380
logger.error(

app/services/namespaces/projects/flows/persist_execution_result_service.rb

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ module Flows
66
class PersistExecutionResultService
77
include Code0::ZeroTrack::Loggable
88

9-
attr_reader :grpc_result, :runtime_id
9+
attr_reader :grpc_result
1010

11-
def initialize(grpc_result, runtime_id: nil)
11+
def initialize(grpc_result)
1212
@grpc_result = grpc_result
13-
@runtime_id = runtime_id
1413
end
1514

1615
def execute
@@ -83,16 +82,7 @@ def node_function_for(node_result)
8382
def function_definition_for(node_result, flow)
8483
return unless node_result.id == :function_identifier
8584

86-
runtime = runtime_for(flow)
87-
return if runtime.nil?
88-
89-
FunctionDefinition.find_by(runtime: runtime, identifier: node_result.function_identifier)
90-
end
91-
92-
def runtime_for(flow)
93-
return Runtime.find_by(id: runtime_id) if runtime_id.present?
94-
95-
flow.project.primary_runtime || flow.flow_type.runtime
85+
FunctionDefinition.find_by(runtime: flow.project.primary_runtime, identifier: node_result.function_identifier)
9686
end
9787

9888
def assign_result(record, grpc_record)

spec/services/namespaces/projects/flows/persist_execution_result_service_spec.rb

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
require 'rails_helper'
44

55
RSpec.describe Namespaces::Projects::Flows::PersistExecutionResultService do
6-
subject(:service_response) { described_class.new(grpc_result, runtime_id: runtime_id).execute }
6+
subject(:service_response) { described_class.new(grpc_result).execute }
77

88
let(:flow) { create(:flow) }
99
let(:node_function) { create(:node_function, flow: flow) }
10-
let(:runtime_id) { nil }
1110
let(:started_at) { 1_780_430_000_000_000 }
1211
let(:finished_at) { 1_780_430_002_000_000 }
1312

@@ -169,9 +168,6 @@
169168

170169
context 'when a node execution result targets a function definition' do
171170
let(:function_definition) { create(:function_definition) }
172-
let!(:other_function_definition) do
173-
create(:function_definition, identifier: function_definition.identifier)
174-
end
175171

176172
let(:grpc_result) do
177173
Tucana::Shared::ExecutionResult.new(
@@ -206,16 +202,12 @@
206202
)
207203
end
208204

209-
context 'when a runtime id is provided' do
210-
let(:runtime_id) { other_function_definition.runtime_id }
211-
212-
it 'looks up the function definition in the connected runtime' do
213-
expect(service_response).to be_success
205+
it 'ignores matching definitions from other runtimes' do
206+
expect(service_response).to be_success
214207

215-
expect(service_response.payload.node_results.sole).to have_attributes(
216-
function_definition: other_function_definition
217-
)
218-
end
208+
expect(service_response.payload.node_results.sole).to have_attributes(
209+
function_definition: function_definition
210+
)
219211
end
220212
end
221213

0 commit comments

Comments
 (0)