-
Notifications
You must be signed in to change notification settings - Fork 994
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 queue controller #128
Add queue controller #128
Conversation
8f8b157
to
d3f2fac
Compare
pkg/apis/helpers/helpers.go
Outdated
@@ -63,7 +63,7 @@ func ControlledBy(obj interface{}, gvk schema.GroupVersionKind) bool { | |||
return false | |||
} | |||
|
|||
func CreateConfigMapIfNotExist(job *vkv1.Job, kubeClients *kubernetes.Clientset, data map[string]string, cmName string) error { | |||
func CreateConfigMapIfNotExist(job *vkv1.Job, kubeClients kubernetes.Interface, data map[string]string, cmName string) 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.
prefer to have seperate PR for such kind of cleanup.
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.
make sense
glog.V(2).Infoln("queue %s has not been seen or deleted") | ||
return nil | ||
} | ||
for pgKey := range c.podGroups[key] { |
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.
prefer to handle this in Cache: Queue -> Job -> PodGroup.
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.
I donot want to overlap with job controller. For queue controller, it just care about the podgroups, not care about Job or anything else.
podGroups is keyed by queue name and value is the podgroups that are using this queue.
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.
pkg/cache
is a common component in controller, and we need to clean up jobs when queue was deleted.
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.
IC, then we need to record jobs too.
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.
But have a doubt: why would user delete their queues before jobs? Is there a use case? If there is a malicious user who does this, we should not delete the running jobs by any reason.
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.
For this, I can think of a more simple way to do this: I remember there will be an admission controller to validate queue existence before create jobs. Then we can also set the job's owner reference. Then when the queue is deleted, k8s garbage collector can reclaim all children resources automatically.
So we have two choice:
-
do it in controller, need to record all dependents relationship.
-
setting ownerreference, do nothing else, leave it to GC.
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.
Personally prefer not adding this into cache even we need considering deleting jobs when queue deleted.
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.
setting ownerreference, do nothing else, leave it to GC.
owerReference should be reserved for JobGroup
:)
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.
OwnerReferences is an array, can be more than one.
owerReference should be reserved for JobGroup :)
Sorry, there is no JobGroup
now.
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.
not sure whether GC will check controlled owner reference.
there is no JobGroup now.
so "reserved" it.
08b043d
to
de3bcf8
Compare
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.
E2E tests are required
@@ -72,10 +76,17 @@ func Run(opt *options.ServerOption) error { | |||
return err | |||
} | |||
|
|||
jobController := job.NewJobController(config) | |||
// TODO: add user agent for different controllers |
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.
What is user agent?
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.
It is just for http server to know the client identity.
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 http header
glog.V(2).Infoln("queue %s has not been seen or deleted") | ||
return nil | ||
} | ||
for pgKey := range c.podGroups[key] { |
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.
Personally prefer not adding this into cache even we need considering deleting jobs when queue deleted.
I am adding e2e |
@hzxuzhonghu please update the cluster role to get appropriate rights to handle queue resource. |
Thanks |
d141e07
to
f5113d1
Compare
f5113d1
to
942f198
Compare
/lgtm |
/approve |
Add queue controller
fixes: #16