Skip to content

Commit

Permalink
Merge pull request #6 from jorgemarey/f-name-attribute
Browse files Browse the repository at this point in the history
Add name_attribute config option
  • Loading branch information
jorgemarey committed Jul 14, 2024
2 parents 9f5b0de + 99ea947 commit fd339f6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
## 0.4.2 (Jul 15, 2024)

FEATURES:
* Add `name_attribute` to specify the attribute to use when selecting the instance name to
search for the instance to downscale

## 0.4.1 (Jun 27, 2024)

FEATURES:
* Updated golang to 1.22.4
* Updated autoscaler dependendy to 0.4.4
* floatingip_pool_name can now be specified to attach a floating ip for created instances
* `floatingip_pool_name` can now be specified to attach a floating ip for created instances
* fix cache data being renoved after reload

## 0.4.0 (Nov 23, 2023)
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ target "os-nova" {
* `cacert_file` `(string: "")` - Location of the certificate to use for OS APIs verification
* `insecure_skip_verify` `(string: "")` - Skip TLS certificate verification

* `id_attribute` `(string: "")` - The nomad attribute to use that maps the nomad client to an OS Compute instance. By default `unique.platform.aws.hostname` is used and a previous search is needed
to get the instance id using the instance name
* `name_attribute` `(string: "unique.platform.aws.hostname")` - The nomad attribute that reflects the instance name. This needs to be used for searching the instance ID in the proccess of downscaling
* `id_attribute` `(string: "")` - The nomad attribute to use that maps the nomad client to an OS Compute instance. If not specified then a previous search is needed to get the instance id using the instance name using `name_attribute`. If this is specified it takes priority over `name_attribute`
* `action_timeout` `(string: "")` - The timeout to use when performing create and delete actions over servers. This should be specified as a duration. The default vaule is 90s
* `ignored_states` `(string: "")` - A comma-separated list of server states to be ignored. The complete list can be seen [here](https://docs.openstack.org/api-guide/compute/server_concepts.html)

Expand Down
13 changes: 9 additions & 4 deletions plugin/openstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@ import (
)

const (
version = "v0.4.1"
version = "v0.4.2"
)

const (
defaultActionTimeout = 120 * time.Second
defaultStatusTImeout = 5 * time.Minute
defaultScaleTimeout = 2 * time.Hour
defaultNameProperty = "unique.platform.aws.hostname"
poolTag = "na_pool:%s"
defaultConfigValueSeparator = ","
configKVSeparator = "="
Expand Down Expand Up @@ -742,10 +743,14 @@ func (t *TargetPlugin) getInstancePortID(id string) (string, error) {

// osNovaNodeIDMapBuilder is used to identify the Opensack Nova ID of a Nomad node using
// the relevant attribute value.
func osNovaNodeIDMapBuilder(property string) scaleutils.ClusterNodeIDLookupFunc {
func osNovaNodeIDMapBuilder(nameProperty, idProperty string) scaleutils.ClusterNodeIDLookupFunc {
var isMeta bool
if property == "" {
property = "unique.platform.aws.hostname"
property := defaultNameProperty
if nameProperty != "" {
property = nameProperty
}
if idProperty != "" {
property = idProperty
}
if strings.HasPrefix(property, "meta.") {
isMeta = true
Expand Down
5 changes: 3 additions & 2 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const (
configKeyCACertFile = "cacert_file"
configKeyInsecure = "insecure_skip_verify"

configKeyNodeIDAttr = "id_attribute"
configKeyNodeIDAttr = "id_attribute"
configKeyNodeNameAttr = "name_attribute"

configKeyName = "name"
configKeyNamePrefix = "name_prefix"
Expand Down Expand Up @@ -120,7 +121,7 @@ func (t *TargetPlugin) SetConfig(config map[string]string) error {

// Store and set the remote ID callback function.
t.clusterUtils = clusterUtils
t.clusterUtils.ClusterNodeIDLookupFunc = osNovaNodeIDMapBuilder(config[configKeyNodeIDAttr])
t.clusterUtils.ClusterNodeIDLookupFunc = osNovaNodeIDMapBuilder(config[configKeyNodeNameAttr], config[configKeyNodeIDAttr])
t.idMapper = config[configKeyNodeIDAttr] != ""

return nil
Expand Down

0 comments on commit fd339f6

Please sign in to comment.