You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@submarine.apache.org by GitBox <gi...@apache.org> on 2021/05/06 16:58:03 UTC

[GitHub] [submarine] kevin85421 opened a new pull request #580: SUBMARINE-816. Implement Submarine delete event handler

kevin85421 opened a new pull request #580:
URL: https://github.com/apache/submarine/pull/580


   ### What is this PR for?
   This Jira aims to handle the delete events of custom resource "submarine". To elaborate, when the informer of the custom resource "submarine" receives a delete event, the submarine operator needs to delete the resources related to the "submarine" instance.
   
   Reference:
   (1) CRD: https://github.com/apache/submarine/blob/master/submarine-cloud-v2/artifacts/examples/crd.yaml
   (2) CR: https://github.com/apache/submarine/blob/master/submarine-cloud-v2/artifacts/examples/example-submarine.yaml
   ### What type of PR is it?
   [Feature]
   
   ### Todos
   * Create namespace via submarine operator
   
   ### What is the Jira issue?
   https://issues.apache.org/jira/browse/SUBMARINE-816
   
   ### How should this be tested?
   ```
   # Out-of-cluster
   go build -o submarine-operator
   ./submarine-operator
   kubectl create ns submarine-operator-test
   kubectl apply -n submarine-operator-test -f artifacts/examples/example-submarine.yaml
   kubectl delete submarine example-submarine -n submarine-operator-test
   
   kubectl get ns
   kubectl get pv
   ```
   
   ### Screenshots (if appropriate)
   * Step1: Create example-submarine (custom resource) in namespace submarine-operator-test
   * Step2: Delete example-submarine
   
   
   
   https://user-images.githubusercontent.com/20109646/117336563-eeedf400-aece-11eb-8d11-aff3b146de6e.mov
   
   
   
   ### Questions:
   * Do the license files need updating? No
   * Are there breaking changes for older versions? No
   * Does this need new documentation? Yes
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] kevin85421 commented on a change in pull request #580: SUBMARINE-816. Implement Submarine delete event handler

Posted by GitBox <gi...@apache.org>.
kevin85421 commented on a change in pull request #580:
URL: https://github.com/apache/submarine/pull/580#discussion_r628721279



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1035,59 +1049,80 @@ func (c *Controller) syncHandler(key string) error {
 		return nil
 	}
 
-	// Get the Submarine resource with this namespace/name
-	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) {
-			utilruntime.HandleError(fmt.Errorf("submarine '%s' in work queue no longer exists", key))
-			return nil
+	klog.Info("syncHandler: ", key, " / ", action)
+
+	if action != "DELETE" { // Case: ADD & UPDATE

Review comment:
       @xunliu Thank you for your recommendation! I have changed this hardcoded string to constants.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] asfgit closed pull request #580: SUBMARINE-816. Implement Submarine delete event handler

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #580:
URL: https://github.com/apache/submarine/pull/580


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [submarine] xunliu commented on a change in pull request #580: SUBMARINE-816. Implement Submarine delete event handler

Posted by GitBox <gi...@apache.org>.
xunliu commented on a change in pull request #580:
URL: https://github.com/apache/submarine/pull/580#discussion_r628661658



##########
File path: submarine-cloud-v2/controller.go
##########
@@ -1035,59 +1049,80 @@ func (c *Controller) syncHandler(key string) error {
 		return nil
 	}
 
-	// Get the Submarine resource with this namespace/name
-	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) {
-			utilruntime.HandleError(fmt.Errorf("submarine '%s' in work queue no longer exists", key))
-			return nil
+	klog.Info("syncHandler: ", key, " / ", action)
+
+	if action != "DELETE" { // Case: ADD & UPDATE

Review comment:
       Use const variable to replace "DELETE" ?




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org