Closed ikbenale closed 4 years ago
This used to work for us in previous versions. We've established that it breaks from v3.1.0 to v3.2.0, though we're not sure what change made it stop working https://github.com/sous-chefs/consul/compare/v3.1.0..v3.2.0.
We also tried with the latest version (v4.0.3) and we had the same issue. We can make our chef-client runs pass with the following patch, though we're not sure if it's optimal:
diff --git a/libraries/consul_definition.rb b/libraries/consul_definition.rb
index 2eefec6..bb406a7 100644
--- a/libraries/consul_definition.rb
+++ b/libraries/consul_definition.rb
@@ -37,7 +37,7 @@ module ConsulCookbook
def params_to_json
final_parameters = parameters
- final_parameters = final_parameters.merge(name: name) if final_parameters[:name].nil?
+ final_parameters = final_parameters.merge(name: name) if %w(check service).include?(type) && final_parameters[:name].nil?
JSON.pretty_generate(type => final_parameters)
end
More details on this thread https://gitlab.com/gitlab-com/gl-infra/infrastructure/-/issues/9343#note_400279286 /cc @ahanselka
@eReGeBe could you please make a PR which includes this fix so we can see how this goes with tests?
@ramereth sure, created https://github.com/sous-chefs/consul/pull/569
:speaking_head: Foreword
Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.
:ghost: Brief Description
With a service definition like the following one:
We get following error:
(full output at https://gitlab.com/gitlab-cookbooks/gitlab-patroni/-/jobs/698381424#L924)
:pancakes: Cookbook version
3.3.1
:woman_cook: Chef-Infra Version
14.12.3
:tophat: Platform details
Kitchen on Docker image ruby:2.6 on GitLab CI
Steps To Reproduce
Steps to reproduce the behavior:
consul_definition
withservices
, as the one described above:police_car: Expected behavior
A consul definition file with the following contents is created:
:heavy_plus_sign: Additional context
Add any other context about the problem here. e.g. related issues or existing pull requests.