hashicorp / consul

Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
https://www.consul.io
Other
28.4k stars 4.43k forks source link

Unable to delete intention: Sources[0].LegacyMeta must be omitted #9818

Open dekimsey opened 3 years ago

dekimsey commented 3 years ago

Overview of the Issue

I am trying to delete an intention, but I'm receiving an error message a 500 response with the error message, Sources[0].LegacyMeta must be omitted.

Additionally it seems that if an intention has any metadata assigned, it may not be updated by the UI returning the message, error="Meta must not be specified, or should be unchanged during an update."

Reproduction Steps

Steps to reproduce this issue, eg:

Unsure, it may be because this intention was defined when the cluster was 1.6.2 or so.

  1. Have a legacy intention defined
  2. Upgrade to 1.9.3
  3. Attempt to edit or delete the intention

Consul info for both Client and Server

Server info ``` agent: check_monitors = 0 check_ttls = 0 checks = 0 services = 0 build: prerelease = revision = f55da930 version = 1.9.3 consul: acl = enabled bootstrap = false known_datacenters = 3 leader = true leader_addr = 10.70.253.191:8300 server = true raft: applied_index = 115592433 commit_index = 115592433 fsm_pending = 0 last_contact = 0 last_log_index = 115592433 last_log_term = 12000 last_snapshot_index = 115582181 last_snapshot_term = 12000 latest_configuration = [{Suffrage:Voter ID:ea967cb2-b51d-2f71-0125-46c36f76a31b Address:10.70.253.191:8300} {Suffrage:Voter ID:e506af7d-2919-d83c-610f-18f9e3992bf7 Address:10.70.252.184:8300} {Suffrage:Voter ID:404b58d0-ddfd-9aaf-d082-c0d84676f9 e6 Address:10.70.253.208:8300}] latest_configuration_index = 0 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 = 12000 runtime: arch = amd64 cpu_count = 2 goroutines = 1105 max_procs = 2 os = linux version = go1.15.6 serf_lan: coordinate_resets = 0 encrypted = true event_queue = 0 event_time = 2151 failed = 0 health_score = 0 intent_queue = 0 left = 2 member_time = 29313 members = 146 query_queue = 0 query_time = 4 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 = 6205 members = 9 query_queue = 0 query_time = 1 ```

Operating system and Environment details

CentOS 7 x86_64

Log Fragments

Feb 23 16:38:48 qachi-inf-001.tw-test.net consul[47687]: 2021-02-23T16:38:48.898-0600 [ERROR] agent.http: Request error: method=DELETE url=/v1/connect/intentions/exact?source=default%2Freporting-service&destination=default%2Fportal-stats-service&dc=qachi from=127.0.0.1:43782 error="Sources[0].LegacyMeta must be omitted"
Feb 23 16:38:48 qachi-inf-001.tw-test.net consul[47687]: 2021-02-23T16:38:48.898-0600 [DEBUG] agent.http: Request finished: method=DELETE url=/v1/connect/intentions/exact?source=default%2Freporting-service&destination=default%2Fportal-stats-service&dc=qachi from=127.0.0.1:43782 latency=10.176312ms

Intention information:

{
  "CreatedAt": "2020-12-03T19:25:08.604552657Z",
  "UpdatedAt": "2020-12-03T19:25:08.604552657Z",
  "ID": "adca4769-879b-c047-335f-765a552ecbd4",
  "SourceNS": "default",
  "SourceName": "reporting-service",
  "DestinationNS": "default",
  "DestinationName": "portal-stats-service",
  "SourceType": "consul",
  "Action": "allow",
  "Precedence": 9,
  "Hash": "AhONHPeHzoKaT0/Rz8qb+IED+Cn+nFG9QLw1tJm/Bx0=",
  "CreateIndex": 115235406,
  "ModifyIndex": 115585886
}
dekimsey commented 3 years ago

This issue(if it is one) can be bypassed by deleting the malformed intention by ID. But getting by name works fine, so I guess it's a bug?

$ consul intention get reporting-service portal-stats-service
Source:       reporting-service
Destination:  portal-stats-service
Action:       allow
ID:           adca4769-879b-c047-335f-765a552ecbd4
Created At:   Thursday, 03-Dec-20 13:25:08 CST
$ consul intention get adca4769-879b-c047-335f-765a552ecbd4
Source:       reporting-service
Destination:  portal-stats-service
Action:       allow
ID:           adca4769-879b-c047-335f-765a552ecbd4
Created At:   Thursday, 03-Dec-20 13:25:08 CST

Where as with DELETE:

$ consul intention delete reporting-service portal-stats-service
Error deleting the intention: Unexpected response code: 500 (rpc error making call: Sources[0].LegacyMeta must be omitted)
$ consul intention delete adca4769-879b-c047-335f-765a552ecbd4
Intention deleted.
dominikbraun commented 3 years ago

~I cannot reproduce this bug with Consul v1.9.3, Revision f55da9306.~ Edit: I noticed that my Intention wasn't a legacy Intention.