Skip to content
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

engine: roll forward of https://github.com/tilt-dev/tilt/pull/3362, re-using image builds from other resources #3553

Merged
merged 1 commit into from Jul 7, 2020

Conversation

nicks
Copy link
Member

@nicks nicks commented Jul 6, 2020

Hello @maiamcc, @landism,

Please review the following commits I made in branch nicks/ch6738:

24351f9 (2020-07-06 11:43:41 -0400)
engine: roll forward of #3362, re-using image builds from other resources

Code review reminders, by giving a LGTM you attest that:

  • Commits are adequately tested
  • Code is easy to understand and conforms to style guides
  • Incomplete code is marked with TODOs
  • Code is suitably instrumented with logging and metrics

@nicks nicks requested review from landism and maiamcc July 6, 2020 15:45
@maiamcc
Copy link
Contributor

maiamcc commented Jul 6, 2020

Does this want REVIEW or is it a revert-revert?

@nicks
Copy link
Member Author

nicks commented Jul 6, 2020

review!

  • Most of the tests are from the original PR (with some new tests)
  • Most of the implementation code from the original PR has already been checked in as separate PRs
  • Most of the implementation code in this PR is new

Copy link
Contributor

@maiamcc maiamcc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

//
// 2) If the current manifest build was kicked off by a trigger, we don't
// want to queue manifests with the same image.
if currentMT.NextBuildReason() == model.BuildReasonNone {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nbd, but this might be more readable as a helper function a la if !currentMT.IsQueued() or something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

understand the instinct here, but this particular check on has that particular meaning in this particular context -- it would not be correct if called from anywhere

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair nough!


// Update build statuses for duplicated image targets in other manifests.
// This ensures that those images targets aren't redundantly rebuilt.
for _, currentMT := range engineState.Targets() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nbd but consider a helper function here for readability: for... := range engineState.TargetsBesides(mn)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

// builds.
//
// 2) If the current manifest build was kicked off by a trigger, we don't
// want to queue manifests with the same image.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooh good catch!

// We need to mark imageB as dirty, because it was not built in the manifestA
// build but its dependency was built.
//
// Note that this logic also applies to deploy targets depending on image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌 this is super helpful!

// targets. If we built manifestA, which contains imageX and deploy target
// k8sA, and manifestB contains imageX and deploy target k8sB, we need to mark
// target k8sB as dirty so that Tilt actually deploys the changes to imageX.
rDepsMap := currentMT.Manifest.ReverseDependencyIDs()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is convoluted enough that i might comment every line:

// target k8sB as dirty so that Tilt actually deploys the changes to imageX.
rDepsMap := currentMT.Manifest.ReverseDependencyIDs()
for updatedID := range updatedIDSet {
for _, rDepID := range rDepsMap[updatedID] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// for each target depending on each target we just updated...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

rDepsMap := currentMT.Manifest.ReverseDependencyIDs()
for updatedID := range updatedIDSet {
for _, rDepID := range rDepsMap[updatedID] {
if updatedIDSet[rDepID] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// if that target itself was just updated, nothing to do

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

continue
}

currentMS.MutableBuildStatus(rDepID).PendingDependencyChanges[updatedID] = br.StartTime
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// otherwise, mark that target as dirty so it gets rebuilt

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

state := call.state[m1.ImageTargets[0].ID()]
assert.Equal(t, map[string]bool{aPath: true}, state.FilesChangedSet)

// Make sure that when the second build is triggeredd, we did the bookkeeping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Make sure that when the second build is triggeredd, we did the bookkeeping
// Make sure that when the second build is triggered, we did the bookkeeping

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

state := call.state[m1.ImageTargets[0].ID()]
assert.Equal(t, map[string]bool{aPath: true}, state.FilesChangedSet)

// Make sure that when the second build is trigged, we did the bookkeeping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Make sure that when the second build is trigged, we did the bookkeeping
// Make sure that when the second build is triggered, we did the bookkeeping

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants