Kenchu123 commented on a change in pull request #719:
URL: https://github.com/apache/submarine/pull/719#discussion_r696298973
##########
File path: submarine-cloud-v2/pkg/controller/controller.go
##########
@@ -531,3 +561,149 @@ func (c *Controller) handleObject(obj interface{}) {
return
}
}
+
+func (c *Controller) getSubmarine(namespace, name string)
(*v1alpha1.Submarine, error) {
+ submarine, err := c.submarinesLister.Submarines(namespace).Get(name)
+ if err != nil {
+ // The Submarine resource may no longer exist, in which case we
stop
+ // processing
+ if errors.IsNotFound(err) {
+ return nil, nil
+ }
+ return nil, err
+ }
+ return submarine, nil
+}
+
+func (c *Controller) getDeployment(namespace, name string)
(*appsv1.Deployment, error) {
+ deployment, err := c.deploymentLister.Deployments(namespace).Get(name)
+ if err != nil {
+ if errors.IsNotFound(err) {
+ return nil, nil
+ }
+ return nil, err
+ }
+ return deployment, nil
+}
+
+func (c *Controller) validateSubmarine(submarine *v1alpha1.Submarine) error {
+
+ // Print out the spec of the Submarine resource
+ b, err := json.MarshalIndent(submarine.Spec, "", " ")
+ fmt.Println(string(b))
+
+ if err != nil {
+ return err
+ }
+
+ // Check storage type
+ storageType := submarine.Spec.Storage.StorageType
+ if storageType != "nfs" && storageType != "host" {
+ utilruntime.HandleError(fmt.Errorf("invalid storageType '%s'
found in submarine spec, nothing will be created. Valid storage types are 'nfs'
and 'host'", storageType))
+ return nil
+ }
+
+ return nil
+}
+
+func (c *Controller) createSubmarine(submarine *v1alpha1.Submarine) error {
+ var err error
+ err = c.createSubmarineServer(submarine)
+ if err != nil {
+ return err
+ }
+
+ err = c.createSubmarineDatabase(submarine)
+ if err != nil {
+ return err
+ }
+
+ err = c.createIngress(submarine)
+ if err != nil {
+ return err
+ }
+
+ err = c.createSubmarineServerRBAC(submarine)
+ if err != nil {
+ return err
+ }
+
+ err = c.createSubmarineTensorboard(submarine)
+ if err != nil {
+ return err
+ }
+
+ err = c.createSubmarineMlflow(submarine)
+ if err != nil {
+ return err
+ }
+
+ err = c.createSubmarineMinio(submarine)
+ if err != nil {
+ return err
+ }
+
+ return nil
+}
+
+func (c *Controller) checkSubmarineDependentsReady(submarine
*v1alpha1.Submarine) (bool, error) {
+ for _, name := range dependents {
+ podList, err :=
c.kubeclientset.CoreV1().Pods(submarine.Namespace).List(context.TODO(),
metav1.ListOptions{LabelSelector: fmt.Sprintf("app=%s", name)})
+ if err != nil {
+ return false, err
+ }
+ for _, pod := range podList.Items {
+ switch pod.Status.Phase {
+ case corev1.PodPending:
+ return false, nil
+ case corev1.PodFailed, corev1.PodSucceeded:
+ return false, fmt.Errorf("pod completed")
+ case corev1.PodRunning:
+ for _, condition := range pod.Status.Conditions
{
+ if condition.Type == corev1.PodReady &&
condition.Status != corev1.ConditionTrue {
+ return false, nil
+ }
+ }
+ }
+ }
+ }
+
+ return true, nil
+}
Review comment:
Thanks. I didn't know about the deployment status before. I will check
it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]