Avoid reinstalling env templates if Git source has not changed - #3676
Conversation
| /// Determines if the template was installed from the expected repo and | ||
| /// branch. This does not prove that the template is up to date, as the | ||
| /// tag or branch may have moved in the interim. | ||
| pub fn is_installed_from(&self, expected_repo: &str, expected_tag: Option<&str>) -> bool { |
There was a problem hiding this comment.
| pub fn is_installed_from(&self, expected_repo: &str, expected_tag: Option<&str>) -> bool { | |
| pub fn is_installed_from_git_ref(&self, expected_repo: &str, expected_tag: Option<&str>) -> bool { |
Would help disambiguate from is_from_source_repo above.
| } | ||
|
|
||
| let (expected_repo, expected_tag) = match source { | ||
| TemplateSource::Git(g) => (g.repo(), g.branch()), |
There was a problem hiding this comment.
I think maybe we should bail out here when the source branch is None. Untagged envs will keep today's behavior. This effectively makes the "refs are immutable" an opt-in contract the env author signs by pinning rather than an assumption imposed on people who deliberately didn't pin. The only downside here is that untagged envs get no speedup at all.
|
AFAICT
|
|
Ooh I like |
|
Okay |
Signed-off-by: itowlson <ivan.towlson@fermyon.com>
df92b91 to
15aa23b
Compare
|
Updated with your suggestions @fibonacci1729 - please take a look - thanks! |
|
What about retrofitting this into
Handing off the template management to those commands grouped under Installing templates defined by an environment should IMO be possible through two routes:
ℹ️: 2nd approach is just an idea that came into my mind |
Fixes #3672.
The adopted fix is to record against each template the repo and tag that it was installed from, assume that tags and branches are immutable, and update only if the actual tag or branch listed in the env file has changed from the one used for installation.
But: two considerations:
This will result in missed updates if the env owner moves a tag or branch in their templates repo. For this to work, env owners have to consider refs immutable, and if they want to change their templates, they have to update their env with a new tag. I am not sure if this is a safe assumption. We could have a Plan B to re-fetch periodically, but either this kick in too often (and Thorsten would remain frustrated), or it would be too infrequent to be useful. Feedback welcome.
This does not address the delay to re-snapshot the environment, which happens if the environment is unversioned and our snapshot is more than 1 hour old (basically if no unversioned env has been used in the last hour). This is trickier because we can have absolutely no way to tell if the upstream has changed, without a network round-trip. We could increase the recency window to reduce the incidence of these delays, but again that just makes it more and more likely that a user will hit the window. Although we do have the
spin targets updatecommand to mitigate that, so maybe it would be okay.So: feedback and discussion first, so we don't do the wrong thing; but at the same time, it would be nice to get any fix we are happy with into 4.1. So no mixed messages then.
(cc @ThorstenHans who flagged the original issue)