Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wackxu committed May 28, 2019
1 parent 8982423 commit 84eff1b
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 2 deletions.
58 changes: 58 additions & 0 deletions manifests/crd-v1.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: mxjobs.kubeflow.org
spec:
group: kubeflow.org
version: v1
scope: Namespaced
names:
kind: MXJob
singular: mxjob
plural: mxjobs
subresources:
status: {}
validation:
openAPIV3Schema:
properties:
spec:
properties:
mxReplicaSpecs:
properties:
# The validation works when the configuration contains
# `Worker`, `Server`, `Scheduler`,
# `TunerTracker`, `TunerServer`, `Tuner`,
# Otherwise it will not be validated.
Scheduler:
properties:
replicas:
type: integer
minimum: 1
maximum: 1
Worker:
properties:
replicas:
type: integer
minimum: 1
Server:
properties:
replicas:
type: integer
minimum: 1
TunerTracker:
properties:
replicas:
type: integer
minimum: 1
maximum: 1
TunerServer:
properties:
replicas:
type: integer
minimum: 1
Tuner:
properties:
replicas:
type: integer
minimum: 1
maximum: 1
2 changes: 1 addition & 1 deletion pkg/controller.v1/mxnet/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (tc *MXController) addMXJob(obj interface{}) {
logger.Errorf("Could not set nested field: %v", err1)
}
logger.Infof("Updating the job to; %+v", un.Object)
err = client.Update(un, mxv1.Plural)
err = client.UpdateStatus(un, mxv1.Plural)
if err != nil {
logger.Errorf("Could not update the MXJob; %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller.v1/mxnet/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func updateStatusSingle(mxjob *mxv1.MXJob, rtype mxv1.MXReplicaType, replicas in

// updateMXJobStatus updates the status of the given MXJob.
func (tc *MXController) updateMXJobStatus(mxjob *mxv1.MXJob) error {
_, err := tc.mxJobClientSet.KubeflowV1().MXJobs(mxjob.Namespace).Update(mxjob)
_, err := tc.mxJobClientSet.KubeflowV1().MXJobs(mxjob.Namespace).UpdateStatus(mxjob)
return err
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/util/k8sutil/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,17 @@ func (c *CRDRestClient) Update(obj *metav1unstructured.Unstructured, plural stri
}
return err
}

func (c *CRDRestClient) UpdateStatus(obj *metav1unstructured.Unstructured, plural string) error {
logger := mxlogger.LoggerForUnstructured(obj, obj.GetKind())
if plural == "" {
logger.Errorf("Could not issue update because plural not set.")
return fmt.Errorf("plural must be set")
}
r := c.restcli.Put().Resource(plural).Namespace(obj.GetNamespace()).Name(obj.GetName()).SubResource("status").Body(obj)
_, err := r.DoRaw()
if err != nil {
logger.Errorf("Could not issue update using URL: %v; error; %v", r.URL().String(), err)
}
return err
}

0 comments on commit 84eff1b

Please sign in to comment.