saltstack / saltstack/salt

[BUG] Consul agent_service_maintenance using incorrect HTTP method

Open
#60,192 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-testcase severity-medium
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
The agent_service_maintenance function int he consul module uses an HTTP GET call rather than an HTTP PUT call as defined in the API documentation https://www.consul.io/api-docs/agent/service#enable-maintenance-mode.

Setup
Set up a salt minion with the consul agent installed locally and a service running that is registered in consul.

Steps to Reproduce the behavior
Run the consul module using the command

salt '*' consul.agent_service_maintenance consul_url='http://localhost:8500' serviceid='redis' enable='True' reason='Down for upgrade'

Expected behavior
The consul service is set into maintenance mode

Additional context
The relevant context in the source code is here https://github.com/saltstack/salt/blob/f1da86977d0d690c621c33e1c2ca8eecc261c03c/salt/modules/consul.py#L1164 where the method parameter is omitted which makes it default to HTTP GET.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in salt/modules/consul.py around line 1164 and compare the agent_service_maintenance request with Consul's enable-maintenance-mode API documentation. Reproduce it with the provided salt command against a local Consul agent, then verify that the service enters maintenance mode as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
infrastructure
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.