Skip to content

Commit

Permalink
User server supported microversion when nova list services (#160)
Browse files Browse the repository at this point in the history
* User server supported microversion when nova list services

When nova cell enabled, we have two nova-conductor service, one is
nova-conductor and another is super nova-super-conductor, they have same
name in different databases (nova_cell0 & nova_cell1).
The only difference for the agent_state metrics is the service ID, but
service ID is actually a db seqNo, they can be same in different
tables. In our cases, we met two nova-conductors have the same label,
that will cause metrics failed to store.
For nova apiversion bigger than 2.53, it will return uuid for service
id, so add microversion for nova client.

* User server supported microversion when nova list services

When nova cell enabled, we have two nova-conductor service, one is
nova-conductor and another is super nova-super-conductor, they have same
name in different databases (nova_cell0 & nova_cell1).
The only difference for the agent_state metrics is the service ID, but
service ID is actually a db seqNo, they can be same in different
tables. In our cases, we met two nova-conductors have the same label,
that will cause metrics failed to store.
For nova apiversion bigger than 2.53, it will return uuid for service
id, so add microversion for nova client.

* User server supported microversion when nova list services

When nova cell enabled, we have two nova-conductor service, one is
nova-conductor and another is super nova-super-conductor, they have same
name in different databases (nova_cell0 & nova_cell1).
The only difference for the agent_state metrics is the service ID, but
service ID is actually a db seqNo, they can be same in different
tables. In our cases, we met two nova-conductors have the same label,
that will cause metrics failed to store.
For nova apiversion bigger than 2.53, it will return uuid for service
id, so add microversion for nova client.

* Use server supported microversion when nova list services

When nova cell enabled, we have two nova-conductor service, one is
nova-conductor and another is super nova-super-conductor, they have same
name in different databases (nova_cell0 & nova_cell1).
The only difference for the agent_state metrics is the service ID, but
service ID is actually a db seqNo, they can be same in different
tables. In our cases, we met two nova-conductors have the same label,
that will cause metrics failed to store.
For nova apiversion bigger than 2.53, it will return uuid for service
id, so add microversion for nova client.

* Use server supported microversion when nova list services

When nova cell enabled, we have two nova-conductor service, one is
nova-conductor and another is super nova-super-conductor, they have same
name in different databases (nova_cell0 & nova_cell1).
The only difference for the agent_state metrics is the service ID, but
service ID is actually a db seqNo, they can be same in different
tables. In our cases, we met two nova-conductors have the same label,
that will cause metrics failed to store.
For nova apiversion bigger than 2.53, it will return uuid for service
id, so add microversion for nova client.

* Update exporter_test.go

* Update exporter_test.go

Co-authored-by: minsu <minsu@cisco.com>
Co-authored-by: Jorge Niedbalski <jnr@metaklass.org>
  • Loading branch information
3 people committed Feb 14, 2021
1 parent de1b6c2 commit 02d0671
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
17 changes: 9 additions & 8 deletions exporters/exporter_test.go
Expand Up @@ -51,14 +51,15 @@ func (suite *BaseOpenStackTestSuite) FixturePath(name string) string {
}

var fixtures map[string]string = map[string]string{
"/container-infra/clusters": "container_infra_clusters",
"/compute/": "nova_api_discovery",
"/compute/os-services": "nova_os_services",
"/compute/os-hypervisors/detail": "nova_os_hypervisors",
"/compute/flavors/detail": "nova_os_flavors",
"/compute/os-availability-zone": "nova_os_availability_zones",
"/compute/os-security-groups": "nova_os_security_groups",
"/compute/os-aggregates": "nova_os_aggregates",
"/container-infra/clusters": "container_infra_clusters",
"/compute/": "nova_api_discovery",
"/compute/v2.1/": "nova_api_v2.1",
"/compute/os-services": "nova_os_services",
"/compute/os-hypervisors/detail": "nova_os_hypervisors",
"/compute/flavors/detail": "nova_os_flavors",
"/compute/os-availability-zone": "nova_os_availability_zones",
"/compute/os-security-groups": "nova_os_security_groups",
"/compute/os-aggregates": "nova_os_aggregates",
"/compute/limits?tenant_id=0c4e939acacf4376bdcd1129f1a054ad": "nova_os_limits",
"/compute/limits?tenant_id=0cbd49cbf76d405d9c86562e1d579bd3": "nova_os_limits",
"/compute/limits?tenant_id=2db68fed84324f29bb73130c6c2094fb": "nova_os_limits",
Expand Down
27 changes: 27 additions & 0 deletions exporters/fixtures/nova_api_v2.1.json
@@ -0,0 +1,27 @@
{
"versions":
{
"id": "v2.1",
"status": "CURRENT",
"version": "2.87",
"min_version": "2.1",
"updated": "2013-07-23T11:33:21Z",
"links": [
{
"rel": "self",
"href": "http://test.cloud:8774/v2.1/"
},
{
"rel": "describedby",
"type": "text/html",
"href": "http://docs.openstack.org/"
}
],
"media-types": [
{
"base": "application/json",
"type": "application/vnd.openstack.compute+json;version=2.1"
}
]
}
}
5 changes: 5 additions & 0 deletions exporters/nova.go
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack"
"github.com/gophercloud/gophercloud/openstack/compute/apiversions"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/aggregates"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/availabilityzones"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/extendedserverattributes"
Expand Down Expand Up @@ -96,6 +97,10 @@ func NewNovaExporter(config *ExporterConfig) (*NovaExporter, error) {
exporter.AddMetric(metric.Name, metric.Fn, metric.Labels, nil)
}
}
microversion, err := apiversions.Get(config.Client, "v2.1").Extract()
if err == nil {
exporter.Client.Microversion = microversion.Version
}

return &exporter, nil
}
Expand Down

0 comments on commit 02d0671

Please sign in to comment.