Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

server/agent: fix local sid generation

+28 -10
-1
apps/sower/lib/sower_web/agent_channel.ex
··· 124 124 subscription = 125 125 SowerClient.Schemas.Orchestration.Subscription.cast(%{ 126 126 sid: subscription.sid, 127 - local_sid: req_sub.local_sid, 128 127 seed_sid: seed.sid, 129 128 name: seed.name, 130 129 seed_type: seed.seed_type
+17 -1
apps/sower_agent/lib/sower_agent/socket_client.ex
··· 40 40 41 41 def handle_call({:subscription_upgrade, sid}, _from, socket) do 42 42 with {:ok, upgrade_request} <- 43 - SowerClient.Schemas.Orchestration.UpgradeRequest.cast(%{ 43 + SowerClient.Schemas.Orchestration.UpgradeRequest.new(%{ 44 44 subscription_sids: [sid] 45 45 }), 46 46 {:ok, ref} <- ··· 57 57 ) 58 58 59 59 {:reply, {:error, error}, socket} 60 + 61 + :error -> 62 + Logger.error( 63 + msg: "Failed to request subscription upgrade with unknown error", 64 + sid: sid 65 + ) 66 + 67 + {:reply, :error, socket} 60 68 end 61 69 end 62 70 ··· 88 96 else 89 97 {:error, error} -> 90 98 Logger.error(msg: "Failed to register subscription", error: error, subscription: sub) 99 + nil 100 + 101 + :error -> 102 + Logger.error( 103 + msg: "Failed to register subscription with unknown error", 104 + subscription: sub 105 + ) 106 + 91 107 nil 92 108 end 93 109 end)
-5
apps/sower_client/lib/schemas/orchestration/subscription.ex
··· 11 11 readOnly: true, 12 12 nullable: true 13 13 }, 14 - local_sid: %Schema{ 15 - type: :string, 16 - description: "sid allocated locally", 17 - default: "lsid_#{Cuid2Ex.create()}" 18 - }, 19 14 name: %Schema{ 20 15 type: :string, 21 16 description: "Name of the seed"
+10 -2
apps/sower_client/lib/schemas/orchestration/upgrade_request.ex
··· 8 8 request_id: %Schema{ 9 9 type: :string, 10 10 description: "request sid, autogenerated", 11 - readOnly: true, 12 - default: "req_#{Cuid2Ex.create()}" 11 + readOnly: true 13 12 }, 14 13 subscription_sids: %Schema{ 15 14 type: :array, ··· 22 21 }, 23 22 required: ~w(subscription_sids)a 24 23 }) 24 + 25 + @doc """ 26 + Wrapper around cast() for generating ids 27 + """ 28 + def new(map) do 29 + map 30 + |> Map.put_new_lazy(:request_id, fn -> "req_#{Cuid2Ex.create()}" end) 31 + |> cast() 32 + end 25 33 end
+1 -1
config/runtime.exs
··· 6 6 endpoint: "http://localhost:7150", 7 7 state_directory: Path.expand("../_build", __DIR__), 8 8 subscriptions: [ 9 - %{name: "test1", seed_type: "nixos"}, 9 + %{name: "deck", seed_type: "nixos"}, 10 10 %{name: "deck", seed_type: "home-manager"} 11 11 ] 12 12 })