stackhpc / eiffel-ohpc

Example OpenHPC cluster
Apache License 2.0
0 stars 1 forks source link

ohpc_hosts not updated on apply #2

Closed sjpb closed 4 years ago

sjpb commented 4 years ago

The ohpc_hosts file is not updated on apply. Turns out behavior of data resources is very non-obvious in terms of when they get refreshed and is described in TF issue 17034.

The fix is to have:

data  "template_file" "ohpc" {
    ...
    depends_on = [openstack_compute_instance_v2.compute]
}

This forces the template_file data resource to always be updated, and in turn the ohpc_hosts file (local_file.hosts resource) always gets updated as it (implicitly) depends on the template_file data file resource. Note that adding the same depends_on directly to the local_file.hosts resource does not work, as it doesn't think the data its templating out has been changed.

The "always-update" behavior for the data resource with the depends_on is described as somewhat undesirable behavior in the above link but in this case it is what we want.

Fix will be applied in eiffel branch commit 4d052c4ef5c9b946277088f992a371f7aa1acff8 but wanted to have somewhere to discuss this.