Merge pull request #23660 from goltermann/vetclean
Automatic merge from submit-queue Additional go vet fixes Mostly: - pass lock by value - bad syntax for struct tag value - example functions not formatted properly
This commit is contained in:
@@ -488,7 +488,7 @@ func (k *Executor) bindAndWatchTask(driver bindings.ExecutorDriver, task *mesos.
|
||||
// within the launch timeout window we should see a pod-task update via the registry.
|
||||
// if we see a Running update then we need to generate a TASK_RUNNING status update for mesos.
|
||||
handlerFinished := false
|
||||
handler := watchHandler{
|
||||
handler := &watchHandler{
|
||||
expiration: watchExpiration{
|
||||
timeout: launchTimer.C,
|
||||
onEvent: func(taskID string) {
|
||||
|
@@ -118,7 +118,7 @@ func NewRegistry(client *clientset.Clientset) Registry {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r registryImpl) watch() <-chan *PodEvent {
|
||||
func (r *registryImpl) watch() <-chan *PodEvent {
|
||||
return r.updates
|
||||
}
|
||||
|
||||
@@ -130,26 +130,26 @@ func taskIDFor(pod *api.Pod) (taskID string, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
func (r registryImpl) shutdown() {
|
||||
func (r *registryImpl) shutdown() {
|
||||
//TODO(jdef) flesh this out
|
||||
r.m.Lock()
|
||||
defer r.m.Unlock()
|
||||
r.boundTasks = map[string]*api.Pod{}
|
||||
}
|
||||
|
||||
func (r registryImpl) empty() bool {
|
||||
func (r *registryImpl) empty() bool {
|
||||
r.m.RLock()
|
||||
defer r.m.RUnlock()
|
||||
return len(r.boundTasks) == 0
|
||||
}
|
||||
|
||||
func (r registryImpl) pod(taskID string) *api.Pod {
|
||||
func (r *registryImpl) pod(taskID string) *api.Pod {
|
||||
r.m.RLock()
|
||||
defer r.m.RUnlock()
|
||||
return r.boundTasks[taskID]
|
||||
}
|
||||
|
||||
func (r registryImpl) Remove(taskID string) error {
|
||||
func (r *registryImpl) Remove(taskID string) error {
|
||||
r.m.Lock()
|
||||
defer r.m.Unlock()
|
||||
pod, ok := r.boundTasks[taskID]
|
||||
@@ -169,7 +169,7 @@ func (r registryImpl) Remove(taskID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r registryImpl) Update(pod *api.Pod) (*PodEvent, error) {
|
||||
func (r *registryImpl) Update(pod *api.Pod) (*PodEvent, error) {
|
||||
// Don't do anything for pods without task anotation which means:
|
||||
// - "pre-scheduled" pods which have a NodeName set to this node without being scheduled already.
|
||||
// - static/mirror pods: they'll never have a TaskID annotation, and we don't expect them to ever change.
|
||||
@@ -254,8 +254,7 @@ func copyPorts(dest, src *api.Pod) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (r registryImpl) bind(taskID string, pod *api.Pod) error {
|
||||
|
||||
func (r *registryImpl) bind(taskID string, pod *api.Pod) error {
|
||||
// validate taskID matches that of the annotation
|
||||
annotatedTaskID, err := taskIDFor(pod)
|
||||
if err != nil {
|
||||
|
@@ -55,7 +55,7 @@ type (
|
||||
watcher struct {
|
||||
updates <-chan *PodEvent
|
||||
rw sync.RWMutex
|
||||
handlers map[string]watchHandler
|
||||
handlers map[string]*watchHandler
|
||||
filters []watchFilter
|
||||
runOnce chan struct{}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ type (
|
||||
func newWatcher(updates <-chan *PodEvent) *watcher {
|
||||
return &watcher{
|
||||
updates: updates,
|
||||
handlers: make(map[string]watchHandler),
|
||||
handlers: make(map[string]*watchHandler),
|
||||
runOnce: make(chan struct{}),
|
||||
}
|
||||
}
|
||||
@@ -86,7 +86,7 @@ updateLoop:
|
||||
}
|
||||
}
|
||||
log.V(1).Info("handling " + u.FormatShort())
|
||||
h, ok := func() (h watchHandler, ok bool) {
|
||||
h, ok := func() (h *watchHandler, ok bool) {
|
||||
pw.rw.RLock()
|
||||
defer pw.rw.RUnlock()
|
||||
h, ok = pw.handlers[u.taskID]
|
||||
@@ -125,7 +125,7 @@ func (pw *watcher) addFilter(f watchFilter) {
|
||||
}
|
||||
|
||||
// forTask associates a handler `h` with the given taskID.
|
||||
func (pw *watcher) forTask(taskID string, h watchHandler) {
|
||||
func (pw *watcher) forTask(taskID string, h *watchHandler) {
|
||||
pw.rw.Lock()
|
||||
pw.handlers[taskID] = h
|
||||
pw.rw.Unlock()
|
||||
|
Reference in New Issue
Block a user