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 some locking to prevent go data race logic from tripping. #4200

Merged
merged 1 commit into from
Feb 6, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions pkg/registry/registrytest/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,14 @@ func (r *ControllerRegistry) SetError(err error) {
}

func (r *ControllerRegistry) ListControllers(ctx api.Context) (*api.ReplicationControllerList, error) {
r.Lock()
defer r.Unlock()
return r.Controllers, r.Err
}

func (r *ControllerRegistry) GetController(ctx api.Context, ID string) (*api.ReplicationController, error) {
r.Lock()
defer r.Unlock()
return &api.ReplicationController{}, r.Err
}

Expand All @@ -52,13 +56,19 @@ func (r *ControllerRegistry) CreateController(ctx api.Context, controller *api.R
}

func (r *ControllerRegistry) UpdateController(ctx api.Context, controller *api.ReplicationController) error {
r.Lock()
defer r.Unlock()
return r.Err
}

func (r *ControllerRegistry) DeleteController(ctx api.Context, ID string) error {
r.Lock()
defer r.Unlock()
return r.Err
}

func (r *ControllerRegistry) WatchControllers(ctx api.Context, label, field labels.Selector, resourceVersion string) (watch.Interface, error) {
r.Lock()
defer r.Unlock()
return nil, r.Err
}