-
Notifications
You must be signed in to change notification settings - Fork 71
error messages #1106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
error messages #1106
Conversation
76fa824 to
ad7bfb1
Compare
lib/cog/command/pipeline/executor.ex
Outdated
| relays = Map.delete(relays, bundle_name) | ||
| assign_relay(relays, bundle_name, bundle_version) | ||
| end | ||
| # If the bundle is assigned to a relay group carry on, otherwise bail |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flipping the logic will reduce the number of DB queries issued to execute a pipeline:
case Map.get(relays, bundle_name) do
# No assignment so let's pick one
nil ->
case Relays.pick_one(bundle_name, bundle_version) do
# No relays available
{:error, :no_relays} ->
{nil, relays}
# relays exist, but are disabled
{:error, :no_enabled_relays} ->
# Query database to clarify error condition before reporting to user
if Cog.Repository.Bundles.assigned_to_group?(bundle_name) do
{:no_enabled_relays, relays}
else
{:no_relay_group, relays}
end
# Store the selected relay in the relay cache
{:ok, relay} ->
{relay, Map.put(relays, bundle_name, relay)}
end
# Relay was previously assigned
relay ->
# Is the bundle still available on the relay? If not, remove the current assignment from the cache
# and select a new relay
if Relays.relay_available?(relay, bundle_name, bundle_version) do
{relay, relays}
else
relays = Map.delete(relays, bundle_name)
assign_relay(relays, bundle_name, bundle_version)
end
end
lib/cog/relay/tracker.ex
Outdated
| relays = Map.get(tracker.map, {bundle_name, bundle_version}, MapSet.new) | ||
| enabled_relays = MapSet.difference(relays, tracker.disabled) | ||
|
|
||
| {MapSet.to_list(relays), MapSet.to_list(enabled_relays)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think returning descriptive atoms instead of sets of relays would be more intention revealing.
{[], []} becomes :no_relays
{[...], []} becomes :no_enabled_relays
{[...], [...]} becomes [...]
where [...] indicates a non-empty list.
9ffe784 to
33b3681
Compare
lib/cog/relay/tracker.ex
Outdated
| @spec is_bundle_available?(t, relay_id, bundle_name, version) :: boolean() | ||
| def is_bundle_available?(tracker, relay, bundle_name, bundle_version) do | ||
| available_relays = relays(tracker, bundle_name, bundle_version) | ||
| {_all_relays, available_relays} = relays(tracker, bundle_name, bundle_version) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work if relays/3 returns one of the error tuples?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nope, that's a bug. Missed that bit from the previous function return.
68a5b82 to
24397bb
Compare
This adds/updates a number of error messages to make it easier for users to troubleshoot issues.
resolves #1092
Bundle 'test' is not assigned to a relay group. Assign the bundle to a relay group and try again.No Cog Relays supporting thetestbundle are currently available. There are one or more relays serving the bundle, but they are disabled. Enable an appropriate relay and try again.No Cog Relays supporting thetestbundle are currently online. If you just assigned the bundle to a relay group you will need to wait for the relay refresh interval to pick up the new bundle.Provided by piper:
Bundle 'mybundle' is disabled. Please enable it and try running the command again.Bundle '#{bundle}' doesn't contain a command named '#{text}'.