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

Watch delivers current state for resourceVersion=0 #852

Merged

Conversation

smarterclayton
Copy link
Contributor

Allows clients to get the current state without having to execute
a get followed by a watch. Makes integration with action loops
much cleaner.

Split from #846


// WatchAndTransform begins watching the specified key. Events are decoded into
// API objects and sent down the returned watch.Interface. If the transform
// function is provided, the value decoded from etcd will be passed to the function
Copy link
Member

Choose a reason for hiding this comment

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

just to be a pain - what is the transform function signature, and what is it supposed to do? Maybe a (textual) example?

Copy link
Member

Choose a reason for hiding this comment

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

Woops, signature is just below. Still a bit more on the intended use would help

@thockin
Copy link
Member

thockin commented Aug 11, 2014

LGTM overall - need a second LG

go w.etcdWatch(h.Client, key, resourceVersion)
return w, nil
}

// TransformFunc attempts to convert an object to another object for use with a watcher
type TransformFunc func(interface{}) (interface{}, error)
Copy link
Member

Choose a reason for hiding this comment

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

It occurs to me now that TransformFunc and my own FilterFunc are actually better applied as a separate, layered watch.

e.g., in the watch package, func Filter(w Interface, f FilterFunc) Interface and func Transform(w Interface, f TransformFunc) Interface. Or they could even be combined, with FilterFunc returning the new object and whether to send it.

I can do that in another PR if you don't want to do it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree - maybe follow on pull?

Copy link
Member

Choose a reason for hiding this comment

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

Sure.

@lavalamp
Copy link
Member

I think sendResult is not going to work with a list of nodes, which I think is what a recursive Get will return. Can you test that case, please?

@smarterclayton
Copy link
Contributor Author

Yeah - or just don't offer the functionality on recursive Get?

@lavalamp
Copy link
Member

@smarterclayton: No I think the functionality is extremely important-- imagine a replicationController rebooting. That's broken right now without this.

@smarterclayton
Copy link
Contributor Author

Working on it.

@smarterclayton
Copy link
Contributor Author

ptal

}
copied := *response
copied.Node = node
glog.Infof("queueing change %#v", copied)
Copy link
Member

Choose a reason for hiding this comment

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

Remove or move to a V(x) log?

Allows clients to get the current state without having to execute
a get followed by a watch.  Makes integration with action loops
much cleaner.
@lavalamp
Copy link
Member

LGTM

lavalamp added a commit that referenced this pull request Aug 11, 2014
Watch delivers current state for resourceVersion=0
@lavalamp lavalamp merged commit 5e34a97 into kubernetes:master Aug 11, 2014
@smarterclayton smarterclayton deleted the deliver_state_on_nil_version branch February 11, 2015 02:21
vishh pushed a commit to vishh/kubernetes that referenced this pull request Apr 6, 2016
seans3 pushed a commit to seans3/kubernetes that referenced this pull request Apr 10, 2019
Update node self-labeling implementation timeline
deads2k pushed a commit to deads2k/kubernetes that referenced this pull request Jul 13, 2021
UPSTREAM: <carry>: add a way to inject a vulnerable, legacy service-c…
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.

3 participants