-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Many functions are calling the machine listing to retrieve a single machine, overloading the MAAS regions #239
Comments
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) |
This comment has been minimized.
This comment has been minimized.
This issue is stale because it has been open for 30 days with no activity. |
This issue is stale because it has been open for 30 days with no activity. |
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.
The text was updated successfully, but these errors were encountered: