pact-foundation/pact_broker-client

Do not retry when --dry-run (or PACT_BROKER_CAN_I_DEPLOY_DRY_RUN) is provided

Closed this issue · 5 comments

If you run can-i-deploy in dry-run mode but provide --retry-while-unknown value, the command would retry on the unknown verification results, same as without --dry-run.

I'd argue that if you're running in dry-run, you're not interested in the results anyway, so there's no point waiting for the verification results to become published.
Moreover, if you're running in dry run, there's a high chance that the verification result will never become available, since dry-run use cases include "break glass" situations (where you don't care and just want to deploy) or onboarding your systems to pact, where some services might delay the onboarding for whatever reason, so they won't upload any verifications.

So my suggestion would be to ignore --retry-while-unknown and --retry-interval flags if --dry-run is provided.

In fact, that's how --ignore/PACT_BROKER_CAN_I_DEPLOY_IGNORE already is, if you run can-i-deploy with both --ignore and --retry.. flags provided, it won't retry.

Alternatively, if you folks want to keep dry run as a true dry run, how about providing a way to ignore all pacts?
Either --ignore-all/PACT_BROKER_CAN_I_DEPLOY_IGNORE_ALL or --ignore="*" or something?

Thanks! I'd be happy to contribute, but have zero ruby knowledge.

friendly ping on this one :)

Thanks for the suggestion. I can see the logic of your proposal. For now, can you please handle this in the script that calls the can-i-deploy, as I will not get to this issue any time soon unfortunately.

Released in 1.76.0

Will be propagating through to the standalone and docker image shortly

Thanks for fixing this! Is it possible to do the same for can-i-merge please?

It should work for can-i-merge as it calls CanIDeploy

def can_i_merge(*ignored_but_necessary)
require "pact_broker/client/cli/version_selector_options_parser"
require "pact_broker/client/can_i_deploy"
validate_credentials
selectors = VersionSelectorOptionsParser.call(ARGV)
validate_can_i_deploy_selectors(selectors)
dry_run = options.dry_run || ENV["PACT_BROKER_CAN_I_MERGE_DRY_RUN"] == "true"
can_i_merge_options = { output: options.output, retry_while_unknown: options.retry_while_unknown, retry_interval: options.retry_interval, dry_run: dry_run, verbose: options.verbose }
result = CanIDeploy.call(selectors, { with_main_branches: true }, can_i_merge_options, pact_broker_client_options)
$stdout.puts result.message
$stdout.flush
exit(1) unless result.success
end