Open r00ta opened 3 weeks ago
can we cache the machines list from the first call for the duration of the run?
the "short circuit" approach for the >40 calls across the provider for that would be something like
diff --git i/maas/resource_maas_machine.go w/maas/resource_maas_machine.go
index fff14e0..da5c63f 100644
--- i/maas/resource_maas_machine.go
+++ w/maas/resource_maas_machine.go
@@ -351,6 +351,10 @@ func waitForMachineStatus(ctx context.Context, client *client.Client, systemID s
}
func getMachine(client *client.Client, identifier string) (*entity.Machine, error) {
+ machine, err := client.Machine.Get(identifier)
+ if err == nil {
+ return machine, nil
+ }
machines, err := client.Machines.Get(&entity.MachinesParams{})
if err != nil {
return nil, err
which should help those lookups a lot if the subordinate resources pass the system.ID to that call (what the gomaas client expects for client.Machine.Get vs Machines.Get)
I found out that in TF there are many calls to
which means that in order to get a single machine the machine listing is called. The machine listing is the most expensive operation and for this reason it should be avoided as much as possible.
Instead, these functions should specify the identifiers in the machine listing so to perform the lookup on the server and improve a lot the server performances. If some identifiers are not supported by the current API, we should improve the API so to make it possible.