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

Failed to deregister the service when the service ID contains a URL string #20883

Open
Tobewont opened this issue Mar 20, 2024 · 0 comments
Open

Comments

@Tobewont
Copy link

Overview of the Issue

I registered service to consul. When the service ID contains a URL string, I found it can't be deregistered.


Reproduction Steps

Steps to reproduce this issue:

  1. Create a consul service json file,eg:
{
	"id": "xxxx_xxx_https://xxx.xxx.com",
	"name": "xxx-xxx-xxx",
	"address": "xxx.xxx.xxx.xxx",
	"port": 123,
	"meta": {
		"area": "xxx",
		"datacenter": "xxx",
		"department": "xxx",
		"department_id": "xxx-xxx-xxx-xxx",
		"project": "xxx_xxx_xxx_xxx",
		"url_name": "xxx-xxx-xxx"
	},
	"tags": [
		"xxx1",
		"xxx2"
	],
	"check": {
	},
	"weights": {
		"passing": 10,
		"warning": 1
	}
}
  1. Run curl -X PUT --data @xxx.json http://xxx.xxx.xxx.xxx:8500/v1/agent/service/register register the service.
  2. The UI interface can immediately see the registered service.
  3. Run curl -X PUT http://xxx.xxx.xxx.xxx:8500/v1/agent/service/deregister/xxxx_xxx_https://xxx.xxx.com deregister the service failed.
  4. Run curl -X PUT http://xxx.xxx.xxx.xxx:8500/v1/agent/service/deregister/xxxx_xxx_https%3A%2F%2Fxxx.xxx.com deregister the service failed.
  5. Run curl -X PUT --data @xxx.json http://xxx.xxx.xxx.xxx:8500/v1/agent/service/deregister deregister the service failed.
  6. Run consul services deregister -http-addr=http://xxx.xxx.xxx.xxx:8500 -id=xxxx_xxx_https://xxx.xxx.com deregister the service failed. Error: Error registering service "": Unexpected response code: 405 (method GET not allowed). I don't know why, but the official example is consul services deregister-id =web, consul services deregister web.json is also useless.
  7. You can still see the registered service on the UI interface, and the information about this service through /v1/agent/services.

Consul info for both Client and Server

Client info
agent:
	check_monitors = 0
	check_ttls = 0
	checks = 0
	services = 1
build:
	prerelease = 
	revision = 349cec17
	version = 1.18.0
	version_metadata = 
consul:
	acl = disabled
	bootstrap = true
	known_datacenters = 1
	leader = true
	leader_addr = xxx.xxx.xxx.xxx:8300
	server = true
raft:
	applied_index = 172
	commit_index = 172
	fsm_pending = 0
	last_contact = 0
	last_log_index = 172
	last_log_term = 2
	last_snapshot_index = 0
	last_snapshot_term = 0
	latest_configuration = [{Suffrage:Voter ID:2f5546fe-21c5-0a38-d3b9-ffa5ee4fc412 Address:xxx.xxx.xxx.xxx:8300}]
	latest_configuration_index = 0
	num_peers = 0
	protocol_version = 3
	protocol_version_max = 3
	protocol_version_min = 0
	snapshot_version_max = 1
	snapshot_version_min = 0
	state = Leader
	term = 2
runtime:
	arch = amd64
	cpu_count = 4
	goroutines = 227
	max_procs = 4
	os = linux
	version = go1.21.7
serf_lan:
	coordinate_resets = 0
	encrypted = false
	event_queue = 1
	event_time = 2
	failed = 0
	health_score = 0
	intent_queue = 0
	left = 0
	member_time = 1
	members = 1
	query_queue = 0
	query_time = 1
serf_wan:
	coordinate_resets = 0
	encrypted = false
	event_queue = 0
	event_time = 1
	failed = 0
	health_score = 0
	intent_queue = 0
	left = 0
	member_time = 1
	members = 1
	query_queue = 0
	query_time = 1

Consul Version

Prod Environment: v1.11.1 (k8s)
Test Environment: v1.15.4 (container), v1.18.0 (host)

Whether deployed in k8s mode, or container or host mode, the above three versions have no way to deregister the service through the service ID contains a URL string.

https://github.com/hashicorp/consul/issues/13913
https://github.com/hashicorp/consul/pull/14031

There are many similar issues, and fixes, but it has not been resolved in the latest version.

consul

Operating system and Environment details

OS: CentOS Linux release 7.9.2009 (Core)
Kernel: Linux 3.10.0-1160.45.1.el7.x86_64

Log Fragments

None.

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

No branches or pull requests

1 participant