wu-sheng commented on a change in pull request #59:
URL: 
https://github.com/apache/skywalking-infra-e2e/pull/59#discussion_r735335073



##########
File path: internal/components/setup/kind.go
##########
@@ -140,23 +141,42 @@ func KindShouldWaitSignal() bool {
 // KindCleanNotify notify when clean up
 func KindCleanNotify() {
        if portForwardContext != nil {
-               portForwardContext.stopChannel <- struct{}{}
+               close(portForwardContext.stopChannel)
                // wait all stopped
                for i := 0; i < portForwardContext.resourceCount; i++ {
-                       <-portForwardContext.resourceFinishedChannel
+                       // add timeout prevent port already close
+                       select {
+                       case <-portForwardContext.resourceFinishedChannel:
+                       case <-time.After(time.Second * 2):
+                       }
                }
        }
 }
 
 func createKindCluster(kindConfigPath string) error {
        // the config file name of the k8s cluster that kind create
        kubeConfigPath = constant.K8sClusterConfigFilePath
-       args := []string{"create", "cluster", "--config", kindConfigPath, 
"--kubeconfig", kubeConfigPath}
 
        logger.Log.Info("creating kind cluster...")
-       logger.Log.Debugf("cluster create commands: %s %s", 
constant.KindCommand, strings.Join(args, " "))
-       if err := kind.Run(kindcmd.NewLogger(), kindcmd.StandardIOStreams(), 
args); err != nil {
-               return err
+       _, findKindErr := exec.LookPath("kind")
+       args := []string{"create", "cluster", "--config", kindConfigPath, 
"--kubeconfig", kubeConfigPath}
+       if findKindErr != nil {
+               logger.Log.Debugf("using internal kind cluster create commands: 
%s %s", constant.KindCommand, strings.Join(args, " "))
+               if err := kind.Run(kindcmd.NewLogger(), 
kindcmd.StandardIOStreams(), args); err != nil {
+                       return err
+               }
+       } else {
+               logger.Log.Debugf("using command kind cluster create commands: 
%s %s", constant.KindCommand, strings.Join(args, " "))

Review comment:
       Could you be more clear about these 2 cases? The words seem confusing.




-- 
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: notifications-unsubscr...@skywalking.apache.org

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


Reply via email to