client interface change after scope change.

This commit is contained in:
RainbowMango 2020-12-08 11:54:40 +08:00 committed by Kevin Wang
parent ea6215fcf7
commit aa24ea2457
3 changed files with 7 additions and 9 deletions

View File

@ -28,7 +28,6 @@ const (
// ControllerName is the controller name that will be used when reporting events. // ControllerName is the controller name that will be used when reporting events.
ControllerName = "execution-controller" ControllerName = "execution-controller"
finalizer = "karmada.io/execution-controller" finalizer = "karmada.io/execution-controller"
memberClusterNS = "karmada-cluster"
) )
// Controller is to sync PropagationWork. // Controller is to sync PropagationWork.
@ -127,7 +126,7 @@ func (c *Controller) deletePropagationWork(propagationWork *propagationstrategy.
} }
// TODO(RainbowMango): retrieve member cluster from the local cache instead of a real request to API server. // TODO(RainbowMango): retrieve member cluster from the local cache instead of a real request to API server.
memberCluster, err := c.KarmadaClient.MemberclusterV1alpha1().MemberClusters(memberClusterNS).Get(context.TODO(), executionSpace, v1.GetOptions{}) memberCluster, err := c.KarmadaClient.MemberclusterV1alpha1().MemberClusters().Get(context.TODO(), executionSpace, v1.GetOptions{})
if err != nil { if err != nil {
klog.Errorf("Failed to get status of the given member cluster %s", executionSpace) klog.Errorf("Failed to get status of the given member cluster %s", executionSpace)
return err return err
@ -169,7 +168,7 @@ func (c *Controller) dispatchPropagationWork(propagationWork *propagationstrateg
} }
// TODO(RainbowMango): retrieve member cluster from the local cache instead of a real request to API server. // TODO(RainbowMango): retrieve member cluster from the local cache instead of a real request to API server.
memberCluster, err := c.KarmadaClient.MemberclusterV1alpha1().MemberClusters(memberClusterNS).Get(context.TODO(), executionSpace, v1.GetOptions{}) memberCluster, err := c.KarmadaClient.MemberclusterV1alpha1().MemberClusters().Get(context.TODO(), executionSpace, v1.GetOptions{})
if err != nil { if err != nil {
klog.Errorf("Failed to get status of the given member cluster %s", executionSpace) klog.Errorf("Failed to get status of the given member cluster %s", executionSpace)
return err return err

View File

@ -40,7 +40,7 @@ type Controller struct {
// The Controller will requeue the Request to be processed again if an error is non-nil or // The Controller will requeue the Request to be processed again if an error is non-nil or
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue. // Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
func (c *Controller) Reconcile(req controllerruntime.Request) (controllerruntime.Result, error) { func (c *Controller) Reconcile(req controllerruntime.Request) (controllerruntime.Result, error) {
klog.V(4).Infof("Reconciling memberCluster %s", req.NamespacedName.String()) klog.V(4).Infof("Reconciling memberCluster %s", req.NamespacedName.Name)
memberCluster := &v1alpha1.MemberCluster{} memberCluster := &v1alpha1.MemberCluster{}
if err := c.Client.Get(context.TODO(), req.NamespacedName, memberCluster); err != nil { if err := c.Client.Get(context.TODO(), req.NamespacedName, memberCluster); err != nil {

View File

@ -229,7 +229,6 @@ func Run(cmdOut io.Writer, karmadaConfig KarmadaConfig, opts CommandJoinOption)
} }
memberClusterObj := &memberclusterapi.MemberCluster{} memberClusterObj := &memberclusterapi.MemberCluster{}
memberClusterObj.Namespace = opts.ClusterNamespace
memberClusterObj.Name = opts.MemberClusterName memberClusterObj.Name = opts.MemberClusterName
memberClusterObj.Spec.APIEndpoint = memberClusterConfig.Host memberClusterObj.Spec.APIEndpoint = memberClusterConfig.Host
memberClusterObj.Spec.SecretRef = &memberclusterapi.LocalSecretReference{ memberClusterObj.Spec.SecretRef = &memberclusterapi.LocalSecretReference{
@ -380,7 +379,7 @@ func createMemberClusterObject(controlPlaneClient *karmadaclientset.Clientset, m
// IsMemberClusterExist tells if a member cluster (namespace/name) already joined to control plane. // IsMemberClusterExist tells if a member cluster (namespace/name) already joined to control plane.
func IsMemberClusterExist(controlPlaneClient karmadaclientset.Interface, namespace string, name string) (bool, error) { func IsMemberClusterExist(controlPlaneClient karmadaclientset.Interface, namespace string, name string) (bool, error) {
_, err := controlPlaneClient.MemberclusterV1alpha1().MemberClusters(namespace).Get(context.TODO(), name, metav1.GetOptions{}) _, err := controlPlaneClient.MemberclusterV1alpha1().MemberClusters().Get(context.TODO(), name, metav1.GetOptions{})
if err != nil { if err != nil {
if apierrors.IsNotFound(err) { if apierrors.IsNotFound(err) {
return false, nil return false, nil
@ -395,7 +394,7 @@ func IsMemberClusterExist(controlPlaneClient karmadaclientset.Interface, namespa
// CreateMemberCluster creates a new member cluster object in control plane. // CreateMemberCluster creates a new member cluster object in control plane.
func CreateMemberCluster(controlPlaneClient karmadaclientset.Interface, cluster *memberclusterapi.MemberCluster) error { func CreateMemberCluster(controlPlaneClient karmadaclientset.Interface, cluster *memberclusterapi.MemberCluster) error {
_, err := controlPlaneClient.MemberclusterV1alpha1().MemberClusters(cluster.Namespace).Create(context.TODO(), cluster, metav1.CreateOptions{}) _, err := controlPlaneClient.MemberclusterV1alpha1().MemberClusters().Create(context.TODO(), cluster, metav1.CreateOptions{})
if err != nil { if err != nil {
klog.Warningf("failed to create member cluster. member cluster: %s/%s, error: %v", cluster.Namespace, cluster.Name, err) klog.Warningf("failed to create member cluster. member cluster: %s/%s, error: %v", cluster.Namespace, cluster.Name, err)
return err return err