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

Add a system modeler to scheduler #5446

Merged
merged 1 commit into from
Mar 16, 2015
Merged

Add a system modeler to scheduler #5446

merged 1 commit into from
Mar 16, 2015

Conversation

lavalamp
Copy link
Member

So it can try to predict the effect its bindings will have.

Fixes #5336

I'm slightly concerned about the TODO. But hopefully we can fix it in a followup PR as I'm out next week and want to get this in before I go.

@lavalamp
Copy link
Member Author

Updated with one more test and some logging output in case this ever needs to be debugged.

@lavalamp
Copy link
Member Author

...and found a spec.host/status.host bug. OK, this should be ready to go now. Running e2e again but I expect it to pass again.

@lavalamp
Copy link
Member Author

e2e passes. Travis is a flake, rerunning.

@@ -52,6 +52,15 @@ func (s *StoreToPodLister) List(selector labels.Selector) (pods []api.Pod, err e
return pods, nil
}

// Returns true if a pod matching the namespace/name of the given pod exists in the store.
func (s *StoreToPodLister) Exists(pod *api.Pod) bool {
Copy link
Member

Choose a reason for hiding this comment

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

I thought you said the linter barfs if this isn't phrased as "StoreToPodLister returns true if ..." ? (BTW I think that policy is overly verbose and presumably optimizing for the uncommon case, which is that people are reading the godoc-processed code rather than the source code)

On a more concrete note, I'm not sure how I feel about this function converting the error into "false." It would probably be better if you propagated it up to the caller by returning bool, err.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed, and fixed. It's go vet that barfs, and we don't run it on precommit.

@davidopp
Copy link
Member

LGTM

@davidopp davidopp added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 13, 2015
@@ -72,5 +72,13 @@ func TestStoreToPodLister(t *testing.T) {
t.Errorf("Expected %v, got %v", e, a)
continue
}

if !spl.Exists(&api.Pod{ObjectMeta: api.ObjectMeta{Name: id}}) {
t.Errorf("exists returnef false for %v", id)
Copy link
Member

Choose a reason for hiding this comment

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

returned

@satnam6502
Copy link
Contributor

Ready to merge?

@lavalamp
Copy link
Member Author

Yeah if it's OK I'd like to fix these comments in a follow-up?

So it can try to predict the effect its bindings will have.
@lavalamp
Copy link
Member Author

OK actually I've fixed the comments here.

@davidopp
Copy link
Member

LGTM

Oncall, please merge on Monday in case I forget.


// SimpleModeler implements the SystemModeler interface with a timed pod cache.
type SimpleModeler struct {
queuedPods ExtendedPodLister
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi @lavalamp
Sorry for disturbing on this old commit.
I'm wondering why it adds queuePods here? It looks like it's the queue for pods to schedule. But if a pod is assumed, it's already made upon a schedule decision. If it succeed, it will go into scheduledPods; otw, it will still get deleted. Right?

Copy link
Contributor

Choose a reason for hiding this comment

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

To be more specific, I am pointing to this code block:

DeleteFunc: func(obj interface{}) {

c.ScheduledPodLister.Store, c.scheduledPodPopulator = framework.NewInformer(
        c.createAssignedPodLW(),
        ...
            DeleteFunc: func(obj interface{}) {
                c.modeler.LockedAction(func() {
                    switch t := obj.(type) {
                    case *api.Pod:
                        c.modeler.ForgetPod(t)
                    case cache.DeletedFinalStateUnknown:
                        c.modeler.ForgetPodByKey(t.Key)
                    }
                })

If a pod is rejected or removed, it's gonna be deleted and notified with delete event. Right?

Copy link
Member Author

Choose a reason for hiding this comment

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

@hongchaodeng IIRC, at the time there was a race where a rejected pod could show up in the watch before the binding failure propagated back? Note that this code was written before the informer was created. So this race might not be possible any more.

@davidopp
Copy link
Member

@lavalamp is out for a while, but I believe @bprashanth is familiar with this code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm "Looks good to me", indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Scheduler to optimistically use binding info
7 participants