From 30c598b16106443d05f72a7bbf4d75b661c10a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Meny?= Date: Wed, 26 Jan 2022 15:55:20 +0000 Subject: [PATCH] Adjust script to break on instance index missing --- lib/tasks/cf.rake | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/tasks/cf.rake b/lib/tasks/cf.rake index ad7dc0c6d..111ea7395 100644 --- a/lib/tasks/cf.rake +++ b/lib/tasks/cf.rake @@ -1,12 +1,8 @@ namespace :cf do desc "Only run on the first application instance" task on_first_instance: :environment do - instance_index = -1 - begin - instance_index = JSON.parse(ENV["VCAP_APPLICATION"])["instance_index"] - rescue StandardError - nil - end + # We expect this information to be always available or break otherwise + instance_index = JSON.parse(ENV["VCAP_APPLICATION"])["instance_index"] exit(0) unless instance_index.zero? end end