-
Improvement
-
Resolution: Fixed
-
Major
-
None
Plugin generate suffix for instance name randomly. At first glance, this is a good solution, but in the process of exploitation there are some shortcomings.
1. If monitoring is used, for example, influxdb, then a huge number of unique hostnames accumulate and this greatly complicates monitoring.
2. Monitoring in GCE is tied to the name of the instance, and by opening the monitoring tab you can see all the data of the instance with the same name for previous periods.
3. You can use Commitments and discounts. It count instances with the same name like one and apply discounts.
I suggest not to use a random name, but to use predefined names, to check whether such a name exists, and if not, to use it.
Example of code:
def nodes_list_to_add = []
int i = 0
int n = 0
while ( i < number_of_nodes_to_add ) {
n++
node_name = node_name_template + '-' + sprintf('%03d', n)
if (! nodes_map.containsKey(node_name)){
nodes_list_to_add.add(node_name)
i++
}
}
I think its much easier to debug things when names are random (cause you should never have same twice in any place)
But if 3rd point is valid (Im not sure about that, and after reading Google docs it seems its not..) then it would be great..
The code you have added for getting next ID is rather waaay to simple.. inside many strange things happens and most of them is asynchronous..
So it would have to involve a lot of locking and checking GCE to see if instance we want to create don't exists or previous one is already dead.