Skip to content
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

Consul Connect - Configuration works when used in a single service definition but fails when used in case of multiple service definitions #4307

Closed
migibert opened this issue Jun 28, 2018 · 2 comments · Fixed by #4308
Assignees

Comments

@migibert
Copy link

Overview of the Issue

I was trying Consul Connect and adapted my current configuration which uses a single file with multiple services definitions.

The following file gave me this error:

[ERR] proxy config watch upstream listener config couldn't be parsed: '': source data must be an array or slice, got map

{
    "services": [
        {
            "name": "service-A1",
            "port": 80,
            "tags": [],
            "checks": [],
            "connect": {
                "proxy": {
                    "config": {
                        "upstreams": [
                            {
                                "destination_name": "service-B",
                                "local_bind_port": 12000
                            }
                        ]
                    }
                }
            }
        },
        {
            "name": "service-A2",
            "port": 81,
            "tags": [],
            "checks": []
        }
    ]
}  

I then tried to remove the second service definition, using the following file and it worked as expected

{
    "service": {
            "name": "service-A",
            "port": 80,
            "tags": [],
            "checks": [],
            "connect": {
                "proxy": {
                    "config": {
                        "upstreams": [
                            {
                                "destination_name": "service-B",
                                "local_bind_port": 12000
                            }
                        ]
                    }
                }
            }
        }
    ]
}  

Reproduction Steps

  1. Create a cluster with connect enabled
  2. Create a node which registers a service and a proxy (service A) using a single service definition file
  3. Create another node which registers a service (service B) and an upstream to the previous one (service A) using a multiple service definition file
  4. Create another node which registers a service (service C) and an upstream to the first one (service A) using a single service definition file.

Observe that node B is failing and node C is working as expected (you can connect to service A using service C local proxy).

Consul info for both Client and Server

Client

agent:
	check_monitors = 0
	check_ttls = 0
	checks = 1
	services = 2
build:
	prerelease = 
	revision = 28141971
	version = 1.2.0
consul:
	known_servers = 3
	server = false
runtime:
	arch = amd64
	cpu_count = 1
	goroutines = 58
	max_procs = 1
	os = linux
	version = go1.10.1
serf_lan:
	coordinate_resets = 0
	encrypted = true
	event_queue = 0
	event_time = 5
	failed = 0
	health_score = 0
	intent_queue = 0
	left = 0
	member_time = 262
	members = 7
	query_queue = 0
	query_time = 1

Server

agent:
	check_monitors = 0
	check_ttls = 0
	checks = 0
	services = 0
build:
	prerelease = 
	revision = 28141971
	version = 1.2.0
consul:
	bootstrap = false
	known_datacenters = 1
	leader = true
	leader_addr = 10.132.0.3:8300
	server = true
raft:
	applied_index = 5627
	commit_index = 5627
	fsm_pending = 0
	last_contact = 0
	last_log_index = 5627
	last_log_term = 15
	last_snapshot_index = 0
	last_snapshot_term = 0
	latest_configuration = ****
	latest_configuration_index = 2595
	num_peers = 2
	protocol_version = 3
	protocol_version_max = 3
	protocol_version_min = 0
	snapshot_version_max = 1
	snapshot_version_min = 0
	state = Leader
	term = 15
runtime:
	arch = amd64
	cpu_count = 1
	goroutines = 147
	max_procs = 1
	os = linux
	version = go1.10.1
serf_lan:
	coordinate_resets = 0
	encrypted = true
	event_queue = 0
	event_time = 5
	failed = 0
	health_score = 0
	intent_queue = 0
	left = 1
	member_time = 262
	members = 8
	query_queue = 0
	query_time = 1
serf_wan:
	coordinate_resets = 0
	encrypted = true
	event_queue = 0
	event_time = 1
	failed = 0
	health_score = 0
	intent_queue = 0
	left = 0
	member_time = 16
	members = 3
	query_queue = 0
	query_time = 1

Operating system and Environment details

Debian 9 instances on Google Cloud Platform

@migibert
Copy link
Author

migibert commented Jun 28, 2018

In addition, when using a multiple service definition file with multiple upstreams, I have an error but everything is fine is I use the same definition in a single service definition file.

Multiple definition file:

{
  "services": [
    {
      "name": "service-C",
      "port": 80,
      "tags": [],
      "checks": [],
      "connect": {
        "proxy": {
          "config": {
            "upstreams": [
              {
                "destination_name": "service-A",
                "local_bind_port": 10000
              },
              {
                "destination_name": "service-B",
                "local_bind_port": 11000
              }
            ]
          }
        }
      }
    }
  ]
}

Error:

Jun 28 16:06:44 service-3 consul[17876]: #11/go/src/github.com/hashicorp/consul/main.go:19 +0x22
Jun 28 16:06:44 service-3 consul[17884]: panic: services.connect.proxy.config.upstreams: []map[string]interface{} with more than one element not supported: [map[destination_name:service-A local_bin
d_port:%!s(float64=1234)] map[destination_name:service-B local_bind_port:%!s(float64=1235)]]

Single definition file:

{
  "service": {
    "name": "service-C,
    "port": 80,
    "tags": [],
    "checks": [],
    "connect": {
      "proxy": {
        "config": {
          "upstreams": [
            {
              "destination_name": "service-A,
              "local_bind_port": 1234
            },
            {
              "destination_name": "service-B",
              "local_bind_port": 1235
            }
          ]
        }
      }
    }
  }
}

@mitchellh
Copy link
Contributor

mitchellh commented Jun 28, 2018

Thanks! I've got a PR open now to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants