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

tiltrun: use apiserver data model in exit controller #4367

Merged
merged 9 commits into from Apr 7, 2021

Conversation

milas
Copy link
Member

@milas milas commented Mar 25, 2021

This is the first increment towards moving towards a reconciler;
the controller uses the API server TiltRun data model internally
now and updates it, so it can be accessed externally:

KUBECONFIG=$(tilt alpha kubeconfig-path) kubectl describe tiltrun Tiltfile

@milas milas requested review from nicks and maiamcc March 25, 2021 21:06
internal/store/engine_state.go Outdated Show resolved Hide resolved
c.tiltRun.Spec.ExitCondition = tiltruns.ExitConditionFirstFailure
}

if err := c.client.Create(ctx, c.tiltRun); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

i've been wondering if a good rule of thumb is that controllers should be idempotent (so that Create() on a resource that already exists should be OK)

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree (and reconciler pattern helps with that a lot, since you can basically just requeue on a lot of things and take care of it the next pass).

In this case, it'd mean extra logic to handle things (e.g. fetch if already created, similar-ish logic on any conflict on update failure) - unless you feel strongly, I think that since this is the only think writing to it at the moment, it'd be better to just let it always assume these operations shouldn't fail.

(The Create is actually a really weird one - I added a TODO because I think it should get created explicitly as part of Tiltfile/configs reloading rather than implicitly here, and then this can behave much closer to a real reconciler and just always read from cached client, at which point it could trivially handle optimistic concurrency failures during update.)

internal/engine/exit/controller.go Outdated Show resolved Hide resolved
Base automatically changed from milas/exitcontroller-data-model to master March 30, 2021 13:23
@milas milas force-pushed the milas/exitcontroller-apiserver branch from 363adcb to 3e0dcf8 Compare April 2, 2021 19:29
@milas milas marked this pull request as ready for review April 2, 2021 19:29
This is the first increment towards moving towards a reconciler;
the controller uses the API server `TiltRun` data model internally
now and updates it, so it can be accessed externally:
```
KUBECONFIG=$(tilt alpha kubeconfig-path) kubectl describe tiltrun Tiltfile
```
@milas
Copy link
Member Author

milas commented Apr 2, 2021

@maiamcc This should be good for review -- I made various changes based on Nick's initial review and also changes to data model based on our conversation.

@maiamcc
Copy link
Contributor

maiamcc commented Apr 5, 2021

rad, looking now!

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.

...i apologize for the butt-ton of comments, the vast majority are style nits/requests for comments/naming suggestions that you are very free to ignore! the only thing I'm worried about that might behave badly is the "default to pending" behavior of k8sRuntimeTarget

happy for you to go ahead and merge once you've implemented/rejected all the suggestions, or happy to re-review, either way

internal/engine/exit/actions.go Show resolved Hide resolved
internal/engine/exit/controller.go Show resolved Hide resolved
internal/engine/exit/actions.go Show resolved Hide resolved
internal/engine/exit/controller.go Show resolved Hide resolved
internal/engine/exit/controller.go Show resolved Hide resolved
internal/engine/exit/conv.go Show resolved Hide resolved
internal/engine/exit/conv.go Outdated Show resolved Hide resolved
internal/engine/exit/conv.go Outdated Show resolved Hide resolved
internal/engine/exit/conv.go Outdated Show resolved Hide resolved
pkg/apis/core/v1alpha1/tiltrun_types.go Outdated Show resolved Hide resolved
@milas milas merged commit fbb3039 into master Apr 7, 2021
@milas milas deleted the milas/exitcontroller-apiserver branch April 7, 2021 14:08
nicks added a commit to nicks/tilt that referenced this pull request Dec 5, 2023
fixes tilt-dev#6272

History of this change:
- we used to have a very naive definition of "Ready"
- callers of the runtime status API had hacks to look at Job pods to determine completeness (tilt-dev#4367)
- later, we changed it to have a more sophisticated definition, so that
  Jobs only count as 'ready' when they're complete. (tilt-dev#5013)
- we forgot to remove the old caller hacks :grimace:

in any case, i added a bunch of tests, since we need more job integration tests anyway.

Signed-off-by: Nick Santos <nick.santos@docker.com>
nicks added a commit to nicks/tilt that referenced this pull request Dec 5, 2023
fixes tilt-dev#6272

History of this change:
- we used to have a very naive definition of "Ready"
- callers of the runtime status API had hacks to look at Job pods to determine completeness (tilt-dev#4367)
- later, we changed it to have a more sophisticated definition, so that
  Jobs only count as 'ready' when they're complete. (tilt-dev#5013)
- we forgot to remove the old caller hacks :grimace:

in any case, i added a bunch of tests, since we need more job integration tests anyway.

Signed-off-by: Nick Santos <nick.santos@docker.com>
nicks added a commit to nicks/tilt that referenced this pull request Dec 5, 2023
fixes tilt-dev#6272

History of this change:
- we used to have a very naive definition of "Ready"
- callers of the runtime status API had hacks to look at Job pods to determine completeness (tilt-dev#4367)
- later, we changed it to have a more sophisticated definition, so that
  Jobs only count as 'ready' when they're complete. (tilt-dev#5013)
- we forgot to remove the old caller hacks :grimace:

in any case, i added a bunch of tests, since we need more job integration tests anyway.

Signed-off-by: Nick Santos <nick.santos@docker.com>
nicks added a commit that referenced this pull request Dec 8, 2023
)

* Handle jobs with deleted pods

Signed-off-by: Daniel Nephin <dnephin@gmail.com>

* session: ensure 'tilt ci' exits properly when reattaching to jobs

fixes #6272

History of this change:
- we used to have a very naive definition of "Ready"
- callers of the runtime status API had hacks to look at Job pods to determine completeness (#4367)
- later, we changed it to have a more sophisticated definition, so that
  Jobs only count as 'ready' when they're complete. (#5013)
- we forgot to remove the old caller hacks :grimace:

in any case, i added a bunch of tests, since we need more job integration tests anyway.

Signed-off-by: Nick Santos <nick.santos@docker.com>

---------

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
Signed-off-by: Nick Santos <nick.santos@docker.com>
Co-authored-by: Daniel Nephin <dnephin@gmail.com>
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

3 participants