From 2215870d5d9a89a77710fa905d3269309ba646af Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Tue, 20 Jun 2023 15:08:08 +0800 Subject: [PATCH] chore: pkg imported more than once Signed-off-by: guoguangwu --- pkg/agent/run.go | 3 +-- pkg/cloudprovider/instances.go | 5 ++--- pkg/daemons/executor/embed.go | 3 +-- pkg/deploy/controller.go | 5 ++--- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/pkg/agent/run.go b/pkg/agent/run.go index 63736483a9..250ba947ba 100644 --- a/pkg/agent/run.go +++ b/pkg/agent/run.go @@ -25,7 +25,6 @@ import ( cp "github.com/k3s-io/k3s/pkg/cloudprovider" "github.com/k3s-io/k3s/pkg/daemons/agent" daemonconfig "github.com/k3s-io/k3s/pkg/daemons/config" - types "github.com/k3s-io/k3s/pkg/daemons/config" "github.com/k3s-io/k3s/pkg/daemons/executor" "github.com/k3s-io/k3s/pkg/nodeconfig" "github.com/k3s-io/k3s/pkg/rootless" @@ -98,7 +97,7 @@ func run(ctx context.Context, cfg cmds.Agent, proxy proxy.Proxy) error { if !nodeConfig.NoFlannel { if (nodeConfig.FlannelExternalIP) && (len(nodeConfig.AgentConfig.NodeExternalIPs) == 0) { logrus.Warnf("Server has flannel-external-ip flag set but this node does not set node-external-ip. Flannel will use internal address when connecting to this node.") - } else if (nodeConfig.FlannelExternalIP) && (nodeConfig.FlannelBackend != types.FlannelBackendWireguardNative) && (nodeConfig.FlannelBackend != types.FlannelBackendIPSEC) { + } else if (nodeConfig.FlannelExternalIP) && (nodeConfig.FlannelBackend != daemonconfig.FlannelBackendWireguardNative) && (nodeConfig.FlannelBackend != daemonconfig.FlannelBackendIPSEC) { logrus.Warnf("Flannel is using external addresses with an insecure backend: %v. Please consider using an encrypting flannel backend.", nodeConfig.FlannelBackend) } if err := flannel.Prepare(ctx, nodeConfig); err != nil { diff --git a/pkg/cloudprovider/instances.go b/pkg/cloudprovider/instances.go index 2a0b31a2c5..2e399ae5c6 100644 --- a/pkg/cloudprovider/instances.go +++ b/pkg/cloudprovider/instances.go @@ -9,7 +9,6 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" - v1 "k8s.io/api/core/v1" cloudprovider "k8s.io/cloud-provider" ) @@ -29,12 +28,12 @@ func (k *k3s) InstanceExists(ctx context.Context, node *corev1.Node) (bool, erro // InstanceShutdown returns true if the instance is shutdown according to the cloud provider. // K3s nodes are never shutdown. -func (k *k3s) InstanceShutdown(ctx context.Context, node *v1.Node) (bool, error) { +func (k *k3s) InstanceShutdown(ctx context.Context, node *corev1.Node) (bool, error) { return false, nil } // InstanceMetadata returns the instance's metadata. -func (k *k3s) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloudprovider.InstanceMetadata, error) { +func (k *k3s) InstanceMetadata(ctx context.Context, node *corev1.Node) (*cloudprovider.InstanceMetadata, error) { if (node.Annotations[InternalIPKey] == "") && (node.Labels[InternalIPKey] == "") { return nil, errors.New("address annotations not yet set") } diff --git a/pkg/daemons/executor/embed.go b/pkg/daemons/executor/embed.go index 265d30ac0e..7e914d3fe9 100644 --- a/pkg/daemons/executor/embed.go +++ b/pkg/daemons/executor/embed.go @@ -27,7 +27,6 @@ import ( "k8s.io/client-go/tools/cache" "k8s.io/client-go/tools/clientcmd" toolswatch "k8s.io/client-go/tools/watch" - ccm "k8s.io/cloud-provider" cloudprovider "k8s.io/cloud-provider" cloudproviderapi "k8s.io/cloud-provider/api" ccmapp "k8s.io/cloud-provider/app" @@ -187,7 +186,7 @@ func (*Embedded) CloudControllerManager(ctx context.Context, ccmRBACReady <-chan } cloudInitializer := func(config *cloudcontrollerconfig.CompletedConfig) cloudprovider.Interface { - cloud, err := ccm.InitCloudProvider(version.Program, config.ComponentConfig.KubeCloudShared.CloudProvider.CloudConfigFile) + cloud, err := cloudprovider.InitCloudProvider(version.Program, config.ComponentConfig.KubeCloudShared.CloudProvider.CloudConfigFile) if err != nil { logrus.Fatalf("Cloud provider could not be initialized: %v", err) } diff --git a/pkg/deploy/controller.go b/pkg/deploy/controller.go index 0b296eaaeb..d26a88906a 100644 --- a/pkg/deploy/controller.go +++ b/pkg/deploy/controller.go @@ -26,7 +26,6 @@ import ( "github.com/rancher/wrangler/pkg/objectset" "github.com/sirupsen/logrus" corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/api/errors" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -287,7 +286,7 @@ func (w *watcher) delete(path string) error { // ensure that the addon is completely removed before deleting the objectSet, // so return when err == nil, otherwise pods may get stuck terminating w.recorder.Eventf(&addon, corev1.EventTypeNormal, "DeletingManifest", "Deleting manifest at %q", path) - if err := w.addons.Delete(addon.Namespace, addon.Name, &metav1.DeleteOptions{}); err == nil || !errors.IsNotFound(err) { + if err := w.addons.Delete(addon.Namespace, addon.Name, &metav1.DeleteOptions{}); err == nil || !apierrors.IsNotFound(err) { return err } @@ -303,7 +302,7 @@ func (w *watcher) delete(path string) error { // if it cannot be found. func (w *watcher) getOrCreateAddon(name string) (apisv1.Addon, error) { addon, err := w.addonCache.Get(metav1.NamespaceSystem, name) - if errors.IsNotFound(err) { + if apierrors.IsNotFound(err) { addon = apisv1.NewAddon(metav1.NamespaceSystem, name, apisv1.Addon{}) } else if err != nil { return apisv1.Addon{}, err