-
Notifications
You must be signed in to change notification settings - Fork 5
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
Storable scheduler #211
base: master
Are you sure you want to change the base?
Storable scheduler #211
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model/store.go
should not be a part of model class. This should be a private struct of scheduler
or mesos
package.
# Conflicts: # handlers/vm/esxi/esxi_test.go # vendor/vendor.json
handlers/vm/lxc/lxc_test.go
Outdated
@@ -16,7 +16,7 @@ func TestResourceName(t *testing.T) { | |||
|
|||
func TestTypes(t *testing.T) { | |||
assert := assert.New(t) | |||
assert.Implements((*handlers.ResourceHandler)(nil), &LxcHandler{}) | |||
// assert.Implements((*handlers.InstanceResourceHandler)(nil), &LxcHandler{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little time ago, InstanceResourceHandler was registered by each Handler. But now InstanceResourceHandler is not used by any handlers, because each Scheduler registering instanceSchedulerHandler to global variable of scheduler/schedule.go instead of InstanceResourceHandler. So each Hander need not implement InstanceResourceHandler. I deleted this comment.
handlers/vm/null/null_test.go
Outdated
@@ -14,6 +14,6 @@ func TestResourceName(t *testing.T) { | |||
|
|||
func TestTypes(t *testing.T) { | |||
assert := assert.New(t) | |||
assert.Implements((*handlers.ResourceHandler)(nil), &NullHandler{}) | |||
// assert.Implements((*handlers.InstanceResourceHandler)(nil), &NullHandler{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
handlers/vm/qemu/qemu_test.go
Outdated
@@ -16,7 +16,7 @@ func TestResourceName(t *testing.T) { | |||
|
|||
func TestTypes(t *testing.T) { | |||
assert := assert.New(t) | |||
assert.Implements((*handlers.ResourceHandler)(nil), &QemuHandler{}) | |||
// assert.Implements((*handlers.InstanceResourceHandler)(nil), &QemuHandler{}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this commented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
scheduler/mesos_test.go
Outdated
func init() { | ||
mesosOffer = &mesos.Offer{ | ||
Id: &mesos.OfferID{ | ||
Value: sP("d39c0128-4822-49a0-9fab-640fba518d53-O590"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
golang/protobuf
provides conversion utilities.
proto.String("xxxxxx")
https://github.com/golang/protobuf/blob/master/proto/lib.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified to using proto library for convert to pointer.
scheduler/schedule.go
Outdated
} | ||
|
||
type Schedule struct { | ||
*sync.Mutex |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to expose Lock()/Unlock() methods. And also sync.RWMutex
is better .
https://golang.org/pkg/sync/#RWMutex
m sync.RWMutex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified mutex from sync.Mutex to sync.RWMutex and turn to private variable.
scheduler/schedule.go
Outdated
schedule.storedOffers[offer.SlaveID] = offer | ||
} | ||
|
||
func (s *Schedule) Assign(inst *model.Instance) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing to take mutex lock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added RLock/RUnlock next to schedule.storedOffers's "for range" function.
New openvdc scheduler storing offer of mesos slave noticed by mesos master.
When coming request from user, scheduler refer to stored offers and judging whether mesos slave satisfing request is exist.
When exist mesos slave satisfing request, accept the request. If it does not exist, scheduler informs the user that there are no slaves that satisfy the request.