Closed taylordowns2000 closed 10 months ago
Using WorkOrders.update_state requires pubsub. Let's reach one step below this to run setup_demo
via kubectl without needing to start the pubsub registry.
ERROR 2023-11-14T00:00:43.264049788Z [resource.labels.containerName: kubectl] Unable to use a TTY - input is not a terminal or the right kind of file
ERROR 2023-11-14T00:00:49.620545430Z [resource.labels.containerName: kubectl] ** (ArgumentError) unknown registry: Lightning.PubSub. Either the registry name is invalid or the registry is not running, possibly because its application isn't started
ERROR 2023-11-14T00:00:49.620630478Z [resource.labels.containerName: kubectl] (elixir 1.15.4) lib/registry.ex:1086: Registry.meta/2
ERROR 2023-11-14T00:00:49.620639746Z [resource.labels.containerName: kubectl] lib/phoenix/pubsub.ex:148: Phoenix.PubSub.broadcast/4
ERROR 2023-11-14T00:00:49.620645718Z [resource.labels.containerName: kubectl] (lightning 0.10.0-pre8) lib/lightning/work_orders.ex:368: anonymous fn/1 in Lightning.WorkOrders.update_state/1
ERROR 2023-11-14T00:00:49.620651688Z [resource.labels.containerName: kubectl] (lightning 0.10.0-pre8) lib/lightning/setup_utils.ex:976: Lightning.SetupUtils.create_workorder/4
ERROR 2023-11-14T00:00:49.620656501Z [resource.labels.containerName: kubectl] (lightning 0.10.0-pre8) lib/lightning/setup_utils.ex:664: Lightning.SetupUtils.create_openhie_project/1
ERROR 2023-11-14T00:00:49.620661766Z [resource.labels.containerName: kubectl] (lightning 0.10.0-pre8) lib/lightning/setup_utils.ex:44: Lightning.SetupUtils.setup_demo/1
ERROR 2023-11-14T00:00:49.620686977Z [resource.labels.containerName: kubectl] (ecto_sql 3.10.2) lib/ecto/migrator.ex:170: Ecto.Migrator.with_repo/3
ERROR 2023-11-14T00:00:49.620693164Z [resource.labels.containerName: kubectl] nofile:1: (file)
ERROR 2023-11-14T00:00:49.631601397Z [resource.labels.containerName: kubectl] command terminated with exit code 1
https://github.com/OpenFn/Lightning/blob/main/lib/lightning/work_orders.ex#L366-L370
def update_state(%Attempt{} = attempt) do
state_query = Query.state_for(attempt)
from(wo in WorkOrder,
where: wo.id == ^attempt.work_order_id,
join: s in subquery(state_query),
on: true,
select: wo,
update: [set: [state: s.state, last_activity: ^DateTime.utc_now()]]
)
|> Repo.update_all([], returning: true)
# TODO - split this next bit out into another function???
|> then(fn {_, [wo]} ->
updated_wo = Repo.preload(wo, :workflow)
Events.work_order_updated(updated_wo.workflow.project_id, updated_wo)
{:ok, wo}
end)
end
We should also fix version reporting via
Application.spec()
- looks like:application.get_key(:lightning, :vsn),
no longer works in Erlang26