You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/12/15 08:24:12 UTC

[GitHub] [apisix-ingress-controller] tokers opened a new pull request #98: chore: all modules use new config

tokers opened a new pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98


   


----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#issuecomment-745221295


   > > > @gxthrj After this PR is merged, the dev docker image should be updated, also, docs and samples should be changed, since the way we configure ingress apisix is changed.
   > > 
   > > 
   > > Should we update the docs in this PR?
   > 
   > That's OK.
   
   @gxthrj Added.


----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on a change in pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#discussion_r543162142



##########
File path: pkg/ingress/controller/apisix_upstream.go
##########
@@ -16,9 +16,8 @@ package controller
 
 import (
 	"fmt"
-	"github.com/api7/ingress-controller/pkg/ingress/apisix"
-	"github.com/api7/ingress-controller/pkg/ingress/endpoint"
-	"github.com/golang/glog"
+	"time"

Review comment:
       It's used here
   ![image](https://user-images.githubusercontent.com/10428333/102193375-fba98580-3ef6-11eb-928e-5dc8be53e2e8.png)
   




----------------------------------------------------------------
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] [apisix-ingress-controller] tokers edited a comment on pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers edited a comment on pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#issuecomment-745133787


   Test case for `kube. BuildRestConfig` will be added after we use terratest.
   
   I addressed it in https://github.com/apache/apisix-ingress-controller/issues/99.


----------------------------------------------------------------
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] [apisix-ingress-controller] gxthrj merged pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
gxthrj merged pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98


   


----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on a change in pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#discussion_r543163433



##########
File path: pkg/kube/init.go
##########
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package kube
+
+import (
+	clientSet "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned"
+	"k8s.io/client-go/informers"
+	coreinformers "k8s.io/client-go/informers/core/v1"
+	"k8s.io/client-go/kubernetes"
+
+	"github.com/api7/ingress-controller/pkg/config"
+)
+
+var (
+	EndpointsInformer         coreinformers.EndpointsInformer
+	kubeClient                kubernetes.Interface
+	apisixKubeClient          *clientSet.Clientset
+	CoreSharedInformerFactory informers.SharedInformerFactory
+)
+
+func GetKubeClient() kubernetes.Interface {
+	return kubeClient
+}
+
+func GetApisixClient() clientSet.Interface {
+	return apisixKubeClient
+}
+
+// initInformer initializes all related shared informers.
+// Deprecate: will be refactored in the future without notification.
+func InitInformer(cfg *config.Config) error {
+	var err error
+	restConfig, err := BuildRestConfig(cfg.Kubernetes.Kubeconfig, "")
+	if err != nil {
+		return err
+	}
+	kubeClient, err = kubernetes.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+
+	apisixKubeClient, err = clientSet.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+	CoreSharedInformerFactory = informers.NewSharedInformerFactory(kubeClient, 0)
+
+	return nil
+}

Review comment:
       Well, it's not easy to write unit test cases now, i will run them in my local minikube.




----------------------------------------------------------------
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] [apisix-ingress-controller] codecov-io commented on pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
codecov-io commented on pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#issuecomment-745223483


   # [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98?src=pr&el=h1) Report
   > Merging [#98](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98?src=pr&el=desc) (d9f5234) into [master](https://codecov.io/gh/apache/apisix-ingress-controller/commit/6eb76b51447d078a06a26d1a02f4447f9ac88c54?el=desc) (6eb76b5) will **decrease** coverage by `0.23%`.
   > The diff coverage is `66.66%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98/graphs/tree.svg?width=650&height=150&src=pr&token=WPLQXPY3V0)](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98?src=pr&el=tree)
   
   ```diff
   @@            Coverage Diff             @@
   ##           master      #98      +/-   ##
   ==========================================
   - Coverage   58.43%   58.20%   -0.24%     
   ==========================================
     Files          15       15              
     Lines         498      500       +2     
   ==========================================
     Hits          291      291              
   - Misses        184      185       +1     
   - Partials       23       24       +1     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98?src=pr&el=tree) | Coverage Δ | |
   |---|---|---|
   | [cmd/ingress/ingress.go](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98/diff?src=pr&el=tree#diff-Y21kL2luZ3Jlc3MvaW5ncmVzcy5nbw==) | `73.97% <66.66%> (-2.09%)` | :arrow_down: |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98?src=pr&el=continue).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98?src=pr&el=footer). Last update [6eb76b5...d9f5234](https://codecov.io/gh/apache/apisix-ingress-controller/pull/98?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
   


----------------------------------------------------------------
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] [apisix-ingress-controller] gxthrj commented on a change in pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
gxthrj commented on a change in pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#discussion_r543179055



##########
File path: pkg/kube/init.go
##########
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package kube
+
+import (
+	clientSet "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned"
+	"k8s.io/client-go/informers"
+	coreinformers "k8s.io/client-go/informers/core/v1"
+	"k8s.io/client-go/kubernetes"
+
+	"github.com/api7/ingress-controller/pkg/config"
+)
+
+var (
+	EndpointsInformer         coreinformers.EndpointsInformer
+	kubeClient                kubernetes.Interface
+	apisixKubeClient          *clientSet.Clientset
+	CoreSharedInformerFactory informers.SharedInformerFactory
+)
+
+func GetKubeClient() kubernetes.Interface {
+	return kubeClient
+}
+
+func GetApisixClient() clientSet.Interface {
+	return apisixKubeClient
+}
+
+// initInformer initializes all related shared informers.
+// Deprecate: will be refactored in the future without notification.
+func InitInformer(cfg *config.Config) error {
+	var err error
+	restConfig, err := BuildRestConfig(cfg.Kubernetes.Kubeconfig, "")
+	if err != nil {
+		return err
+	}
+	kubeClient, err = kubernetes.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+
+	apisixKubeClient, err = clientSet.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+	CoreSharedInformerFactory = informers.NewSharedInformerFactory(kubeClient, 0)
+
+	return nil
+}

Review comment:
       ok




----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#issuecomment-745178553


   @gxthrj After this PR is merged, the dev docker image should be updated, also, docs and samples should be changed, since the way we configure ingress apisix is changed.


----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on a change in pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#discussion_r543163433



##########
File path: pkg/kube/init.go
##########
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package kube
+
+import (
+	clientSet "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned"
+	"k8s.io/client-go/informers"
+	coreinformers "k8s.io/client-go/informers/core/v1"
+	"k8s.io/client-go/kubernetes"
+
+	"github.com/api7/ingress-controller/pkg/config"
+)
+
+var (
+	EndpointsInformer         coreinformers.EndpointsInformer
+	kubeClient                kubernetes.Interface
+	apisixKubeClient          *clientSet.Clientset
+	CoreSharedInformerFactory informers.SharedInformerFactory
+)
+
+func GetKubeClient() kubernetes.Interface {
+	return kubeClient
+}
+
+func GetApisixClient() clientSet.Interface {
+	return apisixKubeClient
+}
+
+// initInformer initializes all related shared informers.
+// Deprecate: will be refactored in the future without notification.
+func InitInformer(cfg *config.Config) error {
+	var err error
+	restConfig, err := BuildRestConfig(cfg.Kubernetes.Kubeconfig, "")
+	if err != nil {
+		return err
+	}
+	kubeClient, err = kubernetes.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+
+	apisixKubeClient, err = clientSet.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+	CoreSharedInformerFactory = informers.NewSharedInformerFactory(kubeClient, 0)
+
+	return nil
+}

Review comment:
       Well, all logics are just moved from there to here. It's not easy to write unit test cases now, i will run them in my local minikube.




----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#issuecomment-745133787


   Test case for `kube. BuildRestConfig` will be added after we use terratest.


----------------------------------------------------------------
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] [apisix-ingress-controller] gxthrj commented on pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
gxthrj commented on pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#issuecomment-745181052


   > @gxthrj After this PR is merged, the dev docker image should be updated, also, docs and samples should be changed, since the way we configure ingress apisix is changed.
   
   Should we update the docs in this PR?


----------------------------------------------------------------
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] [apisix-ingress-controller] gxthrj commented on a change in pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
gxthrj commented on a change in pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#discussion_r543150346



##########
File path: pkg/ingress/controller/apisix_service.go
##########
@@ -16,8 +16,8 @@ package controller
 
 import (
 	"fmt"
-	"github.com/api7/ingress-controller/pkg/ingress/apisix"
-	"github.com/golang/glog"
+	"time"

Review comment:
       The effect of this `time` was not found in this change.

##########
File path: pkg/kube/init.go
##########
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package kube
+
+import (
+	clientSet "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned"
+	"k8s.io/client-go/informers"
+	coreinformers "k8s.io/client-go/informers/core/v1"
+	"k8s.io/client-go/kubernetes"
+
+	"github.com/api7/ingress-controller/pkg/config"
+)
+
+var (
+	EndpointsInformer         coreinformers.EndpointsInformer
+	kubeClient                kubernetes.Interface
+	apisixKubeClient          *clientSet.Clientset
+	CoreSharedInformerFactory informers.SharedInformerFactory
+)
+
+func GetKubeClient() kubernetes.Interface {
+	return kubeClient
+}
+
+func GetApisixClient() clientSet.Interface {
+	return apisixKubeClient
+}
+
+// initInformer initializes all related shared informers.
+// Deprecate: will be refactored in the future without notification.
+func InitInformer(cfg *config.Config) error {
+	var err error
+	restConfig, err := BuildRestConfig(cfg.Kubernetes.Kubeconfig, "")
+	if err != nil {
+		return err
+	}
+	kubeClient, err = kubernetes.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+
+	apisixKubeClient, err = clientSet.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+	CoreSharedInformerFactory = informers.NewSharedInformerFactory(kubeClient, 0)
+
+	return nil
+}

Review comment:
       It is a big change, we need to test if informers can work as before.

##########
File path: pkg/ingress/controller/apisix_upstream.go
##########
@@ -16,9 +16,8 @@ package controller
 
 import (
 	"fmt"
-	"github.com/api7/ingress-controller/pkg/ingress/apisix"
-	"github.com/api7/ingress-controller/pkg/ingress/endpoint"
-	"github.com/golang/glog"
+	"time"

Review comment:
       ditto




----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on a change in pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#discussion_r543203694



##########
File path: pkg/kube/init.go
##########
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package kube
+
+import (
+	clientSet "github.com/gxthrj/apisix-ingress-types/pkg/client/clientset/versioned"
+	"k8s.io/client-go/informers"
+	coreinformers "k8s.io/client-go/informers/core/v1"
+	"k8s.io/client-go/kubernetes"
+
+	"github.com/api7/ingress-controller/pkg/config"
+)
+
+var (
+	EndpointsInformer         coreinformers.EndpointsInformer
+	kubeClient                kubernetes.Interface
+	apisixKubeClient          *clientSet.Clientset
+	CoreSharedInformerFactory informers.SharedInformerFactory
+)
+
+func GetKubeClient() kubernetes.Interface {
+	return kubeClient
+}
+
+func GetApisixClient() clientSet.Interface {
+	return apisixKubeClient
+}
+
+// initInformer initializes all related shared informers.
+// Deprecate: will be refactored in the future without notification.
+func InitInformer(cfg *config.Config) error {
+	var err error
+	restConfig, err := BuildRestConfig(cfg.Kubernetes.Kubeconfig, "")
+	if err != nil {
+		return err
+	}
+	kubeClient, err = kubernetes.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+
+	apisixKubeClient, err = clientSet.NewForConfig(restConfig)
+	if err != nil {
+		return err
+	}
+	CoreSharedInformerFactory = informers.NewSharedInformerFactory(kubeClient, 0)
+
+	return nil
+}

Review comment:
       I have run it in my local minikube, it works well.




----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on a change in pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on a change in pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#discussion_r543161586



##########
File path: pkg/ingress/controller/apisix_service.go
##########
@@ -16,8 +16,8 @@ package controller
 
 import (
 	"fmt"
-	"github.com/api7/ingress-controller/pkg/ingress/apisix"
-	"github.com/golang/glog"
+	"time"

Review comment:
       ![image](https://user-images.githubusercontent.com/10428333/102193292-e16fa780-3ef6-11eb-8ab6-840a9f50b7d6.png)
   
   It's used here.




----------------------------------------------------------------
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] [apisix-ingress-controller] tokers commented on pull request #98: chore: all modules use new config

Posted by GitBox <gi...@apache.org>.
tokers commented on pull request #98:
URL: https://github.com/apache/apisix-ingress-controller/pull/98#issuecomment-745181669


   > > @gxthrj After this PR is merged, the dev docker image should be updated, also, docs and samples should be changed, since the way we configure ingress apisix is changed.
   > 
   > Should we update the docs in this PR?
   
   That's OK.


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