Commit 55ca90f5 authored by Ben Kochie's avatar Ben Kochie

Merge branch 'bjk/thanos_file_sd' into 'master'

Deploy thanos storage discovery

See merge request !438
parents fe41fd75 9fa502af
Pipeline #52697024 passed with stages
in 3 minutes and 31 seconds
......@@ -28,7 +28,7 @@ GRAPH
zypper (>= 0.0.0)
compat_resource (12.19.1)
cpu (2.0.0)
gitlab-prometheus (0.14.11)
gitlab-prometheus (0.14.12)
accumulator (~> 0.2)
ark (~> 3.1)
chef-vault (~> 3.0)
......
......@@ -10,6 +10,8 @@ default["thanos"]["cluster_port"] = "10900"
default["thanos"]["cluster-address"] = "0.0.0.0:#{node['thanos']['cluster_port']}"
default["thanos"]["cluster_search"] = "recipes:gitlab-prometheus\\:\\:thanos"
default["thanos"]["peers"] = []
default["thanos"]["store_inventory"] = "#{default['thanos']['dir']}/thanos_store.yml"
default["thanos"]["thanos_store_search"] = "recipes:gitlab-prometheus\\:\\:thanos AND (thanos-sidecar_enable:true OR thanos-store_enable:true)"
default["thanos"]["gcs-creds"]["backend"] = nil
default["thanos"]["gcs-creds"]["path"] = "thanos"
......
......@@ -4,7 +4,7 @@ maintainer_email "ops-contact@gitlab.com"
license "All rights reserved"
description "Installs/Configures gitlab-monitoring"
long_description IO.read(File.join(File.dirname(__FILE__), "README.md"))
version "0.14.11"
version "0.14.12"
depends "accumulator", "~> 0.2"
depends "ark", "~> 3.1"
......
......@@ -35,6 +35,15 @@ unless node["thanos"]["gcs-creds"]["backend"].nil?
end
end
thanos_store_search = node["thanos"]["thanos_store_search"]
thanos_store_query = search(:node, thanos_store_search).sort! { |a, b| a[:fqdn] <=> b[:fqdn] }
file node["thanos"]["store_inventory"] do
content generate_inventory_file(thanos_store_query, node["thanos"]["cluster_port"], []).to_yaml
owner node["prometheus"]["user"]
group node["prometheus"]["group"]
mode "0644"
end
include_recipe "runit::default"
directory node["thanos-sidecar"]["log_dir"] do
......
......@@ -28,6 +28,16 @@ describe "gitlab-prometheus::prometheus" do
},
]
)
stub_search(:node, "recipes:gitlab-prometheus\\:\\:thanos AND (thanos-sidecar_enable:true OR thanos-store_enable:true)").and_return(
[
{ "fqdn" => "fist_node",
"hostname" => "my.hostname",
"ipaddress" => "10.0.0.1" },
{ "fqdn" => "fist_node",
"hostname" => "labeled.hostname",
"ipaddress" => "10.0.0.2" },
]
)
end
context "with a simple chef execution" do
......@@ -326,6 +336,16 @@ eos
},
]
)
stub_search(:node, "recipes:gitlab-prometheus\\:\\:thanos AND (thanos-sidecar_enable:true OR thanos-store_enable:true)").and_return(
[
{ "fqdn" => "fist_node",
"hostname" => "my.hostname",
"ipaddress" => "10.0.0.1" },
{ "fqdn" => "fist_node",
"hostname" => "labeled.hostname",
"ipaddress" => "10.0.0.2" },
]
)
end
cached(:chef_run) do
ChefSpec::SoloRunner.new { |node|
......
......@@ -24,6 +24,16 @@ describe "gitlab-prometheus::thanos" do
"ipaddress" => "10.0.0.2" },
]
)
stub_search(:node, "recipes:gitlab-prometheus\\:\\:thanos AND (thanos-sidecar_enable:true OR thanos-store_enable:true)").and_return(
[
{ "fqdn" => "fist_node",
"hostname" => "my.hostname",
"ipaddress" => "10.0.0.1" },
{ "fqdn" => "fist_node",
"hostname" => "labeled.hostname",
"ipaddress" => "10.0.0.2" },
]
)
end
cached(:chef_run) do
......@@ -71,6 +81,15 @@ describe "gitlab-prometheus::thanos" do
)
end
it "creates the thanos base directory" do
expect(chef_run).to create_directory("/opt/prometheus/thanos").with(
owner: "prometheus",
group: "prometheus",
mode: "0755",
recursive: true
)
end
it "creates a bucket config" do
expect(chef_run).to render_file("/opt/prometheus/thanos/objstore.yml").with_content(object_storage_config)
end
......@@ -79,6 +98,10 @@ describe "gitlab-prometheus::thanos" do
expect(chef_run).to render_file("/opt/prometheus/thanos/gcs-creds.json")
end
it "creates a bucket config" do
expect(chef_run).to render_file("/opt/prometheus/thanos/thanos_store.yml")
end
let(:node) { chef_run.node }
it "populates a cluster peers list" do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment