-
Notifications
You must be signed in to change notification settings - Fork 440
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
DB: add studyjob table and extend worker table #362
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: If they are not already assigned, you can assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
4e13574
to
04dc869
Compare
/retest |
04dc869
to
258491a
Compare
258491a
to
b749fde
Compare
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
b749fde
to
04dc869
Compare
CLAs look good, thanks! |
Needs rebase to get gcloud fix |
f8e5fa0
to
819b32f
Compare
CI passed! |
819b32f
to
e66498c
Compare
/retest |
pkg/api/api.proto
Outdated
State status = 5; /// Status of Worker. | ||
string TemplatePath = 6; /// Path for the manufest template of Worker. | ||
repeated Tag tags = 7; /// Tags of Worker. | ||
string manufest = 6; /// A json formatted manufest for Worker. |
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.
manifest?
pkg/api/api.proto
Outdated
string TemplatePath = 6; /// Path for the manufest template of Worker. | ||
repeated Tag tags = 7; /// Tags of Worker. | ||
string manufest = 6; /// A json formatted manufest for Worker. | ||
string metrics_collector_manufest = 7; /// A json formatted manufest for MetricsCollector. |
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.
ditto
@@ -248,7 +244,7 @@ func (r *ReconcileStudyJobController) Reconcile(request reconcile.Request) (reco | |||
default: | |||
now := metav1.Now() | |||
instance.Status.StartTime = &now | |||
err = initializeStudy(instance) | |||
update, err = initializeStudy(instance, request.Namespace) |
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 think maybe it's not your change, just merge by mistake?
pkg/db/db_init.go
Outdated
@@ -53,8 +62,11 @@ func (d *dbConn) DBInit() { | |||
trial_id CHAR(16), | |||
type VARCHAR(255), | |||
status TINYINT, | |||
template_path TEXT, | |||
manufest TEXT, | |||
metrics_collector_manufest TEXT, |
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.
typo err
pkg/db/db_init.go
Outdated
study_id CHAR(16), | ||
job_type TEXT, | ||
worker_template TEXT, | ||
metrics_collector_template TEXT, |
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 think we'd better choose one of manifest and template to name var/column related consistently
@@ -226,11 +227,6 @@ func (r *ReconcileStudyJobController) Reconcile(request reconcile.Request) (reco | |||
if !contains(pendingFinalizers, cleanDataFinalizer) { | |||
return reconcile.Result{}, nil | |||
} | |||
err = deleteStudy(instance) |
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 think maybe we can add a field like "Retain" for studyjob to decide if deleteStudy when delete studyjob
} | ||
defer conn.Close() | ||
c := katibapi.NewManagerClient(conn) | ||
_, err = c.GetStudyJob(context.Background(), &katibapi.GetStudyJobRequest{ | ||
StudyJobUid: string(instance.UID), | ||
}) |
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.
in which case instance.UID can be duplicated?
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.
By CR operator implementation, the reconcile function will be called parallelly. So initializeStudy
is often called two times. I don't know how to avoid it.
if mt, ok := mtl[instance.Spec.MetricsCollectorSpec.GoTemplate.TemplatePath]; ok { | ||
regStudyJobreq.StudyJob.MetricsCollectorTemplate = mt | ||
} | ||
} |
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.
please also handle GoTemplate.TemplatePath == "" && GoTemplate.RawTemplate == ""
case both for worker and metrics.
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.
In that case, the defaultWorkerTemplate.yaml
and defaultMetricsCollectorTemplate.yaml
will be used. It's not an error.
tables studyjobs stores workertemplate/metricscollectortemplate info. @YujiOshima do you plan to support below configuration?
|
@hougangliu Thank you for your review! |
pkg/db/interface_test.go
Outdated
@@ -341,12 +353,35 @@ func TestGetWorkerList(t *testing.T) { | |||
} | |||
|
|||
func TestUpdateWorker(t *testing.T) { | |||
mock.ExpectExec(`UPDATE workers SET status = \? WHERE id = \?`).WithArgs(api.State_COMPLETED, defaultWorkerID).WillReturnResult(sqlmock.NewResult(1, 1)) | |||
err := dbInterface.UpdateWorker(defaultWorkerID, api.State_COMPLETED) | |||
wmanufest := "woker manufest" |
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.
typo: manufest -> manifest, woker ->worker
pkg/db/interface_test.go
Outdated
mock.ExpectExec(`UPDATE workers SET status = \? WHERE id = \?`).WithArgs(api.State_COMPLETED, defaultWorkerID).WillReturnResult(sqlmock.NewResult(1, 1)) | ||
err := dbInterface.UpdateWorker(defaultWorkerID, api.State_COMPLETED) | ||
wmanufest := "woker manufest" | ||
mcmanufest := "metricscollector manufest" |
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. Please correct the other lines too
Do you mean when a new studyjob uses reusestudyid, it will use configuration of row from studys tables and worker/metrics of row from study jobs tables whose studyid == reusestudyid? |
@hougangliu Sorry for confusing.
But I don't have plan to add
Multiple studyjob for a studyid and worker/metrics template do not need to be the same for each studyjobs even they have the same studyid. |
studyjob has been stored in db, why we cannot reuse it? (we create a studyjob crd whose uid is xxx, a studyjob with studyjobid xxx also created in db, when we delete studyjob with uid xx, a studyjob with studyjobid xxx still stored in db.)
I think maybe you plan to use it as below, which can lead to multiple studyjob for a studyid, right?
|
My assumption is below.
|
@YujiOshima I think the change is a little complex. To avoid misunderstanding, I think a detail example can make it clear. |
You have a original studyjob yaml. When you reuse StudyID, you can omit StudyConf but need to write other info e.g. WorkerSpec. When you reuse StudyJobID, you can omit almost all field. |
@YujiOshima it makes sense.
|
No, multi studyjobs can use a studyID and the studyjobs share historical data of Trial and Worker belong to the studyID.
A studyjob has only one WorkerSpec. So it can fill with the WorkerSpec. |
Signed-off-by: YujiOshima <[email protected]>
Signed-off-by: YujiOshima <[email protected]>
4bf8e0d
to
be70b10
Compare
/close We have dropped v1alpha1. Thus I think we cannot merge it into master. |
@gaocegege: Closed this PR. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Related to #352 (comment)
I split changes related to DB scheme from #352 .
In this PR, information of studyjob and worker are stored in DB and users can refer them after the studyjob CR is deleted.
It makes easier to rerun the workers since the manifests of them are stored in DB.
@hougangliu @gaocegege @richardsliu @johnugeorge
Signed-off-by: YujiOshima [email protected]
This change is