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

Namespace creation in partition change/breakage in 1.12.0+ent #12845

Closed
pglass opened this issue Apr 22, 2022 · 1 comment
Closed

Namespace creation in partition change/breakage in 1.12.0+ent #12845

pglass opened this issue Apr 22, 2022 · 1 comment

Comments

@pglass
Copy link

pglass commented Apr 22, 2022

Overview of the Issue

We had some code using consul/api to create namespaces in a partition, which worked in Consul 1.11.5+ent but does not in 1.12.0+ent.

The following will create ns-1 in partition part-1 in 1.11.5+ent. With 1.12.0+ent, it creates ns-1 in the default partition. Basically, the Partition field is now being ignored, it seems.

// Ignores(?) the Partition field in 1.12.0+ent
ns, _, err := client.Namespaces().Create(&api.Namespace{
    Partition: "part-1",
    Name:      "ns-1",
}, nil)

Note that specifying the partition in query parameters works in both versions, for example:

// Works in both 1.11.5+ent and 1.12.0+ent
ns, _, err := client.Namespaces().Create(&api.Namespace{
    Name: "ns-1",
}, &api.WriteOptions{Partition: "part-1"})

Reproduction Steps

Steps to reproduce this issue:

  1. Run Consul 1.12.0+ent (consul agent -dev ...)
  2. Run the following script which creates a partition and namespace.
Expand for script
package main

import (
	"context"
	"log"

	"github.com/hashicorp/consul/api"
)

func main() {
	cfg := api.DefaultConfig()
	client, err := api.NewClient(cfg)

	part, _, err := client.Partitions().Create(context.Background(), &api.Partition{
		Name: "part-1",
	}, nil)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("created partition %s", part.Name)

	ns, _, err := client.Namespaces().Create(&api.Namespace{
		Partition: part.Name,
		Name:      "ns-1",
	}, nil)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("created namespace %s in %s", ns.Name, ns.Partition)
}

The output will look like, where namespace ns-1 is created in the default partition.

$ go run .
2022/04/22 10:27:35 created partition part-1
2022/04/22 10:27:35 created namespace ns-1 in default

Consul info for both Client and Server

Client info
$ consul-ent info
agent:
	check_monitors = 0
	check_ttls = 0
	checks = 0
	services = 0
build:
	prerelease =
	revision = 7f7df338
	version = 1.12.0
consul:
	acl = enabled
	bootstrap = false
	known_datacenters = 1
	leader = true
	leader_addr = 127.0.0.1:8300
	server = true
license:
	customer = 7c020610-60a2-7ccb-c210-20d899e5f3b4
	expiration_time = 2022-09-13 23:59:59.999 +0000 UTC
	features = Automated Backups, Automated Upgrades, Enhanced Read Scalability, Network Segments, Redundancy Zone, Advanced Network Federation, Namespaces, SSO, Audit Logging, Admin Partitions
	id = 7b3c59fd-2e64-7cf8-5445-5247c0a11ae8
	install_id = *
	issue_time = 2021-09-13 15:25:19.052900132 +0000 UTC
	modules = Global Visibility, Routing and Scale, Governance and Policy
	product = consul
	start_time = 2021-09-13 00:00:00 +0000 UTC
raft:
	applied_index = 19
	commit_index = 19
	fsm_pending = 0
	last_contact = 0
	last_log_index = 19
	last_log_term = 2
	last_snapshot_index = 0
	last_snapshot_term = 0
	latest_configuration = [{Suffrage:Voter ID:516ea538-2bec-a543-0883-7569d49f89e6 Address:127.0.0.1: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 = 16
	goroutines = 128
	max_procs = 16
	os = darwin
	version = go1.18.1
serf_lan:
	coordinate_resets = 0
	encrypted = false
	event_queue = 2
	event_time = 3
	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
Server info
output from server 'consul info' command here

Operating system and Environment details

Log Fragments

@pglass
Copy link
Author

pglass commented Apr 22, 2022

Also, see hashicorp/consul-ecs#72 for reference where we found 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

No branches or pull requests

1 participant