diff --git a/.github/workflows/kubernetes-auto-support.yaml b/.github/workflows/kubernetes-auto-support.yaml index 95504996d..2c733ba1a 100644 --- a/.github/workflows/kubernetes-auto-support.yaml +++ b/.github/workflows/kubernetes-auto-support.yaml @@ -26,6 +26,7 @@ jobs: wget https://attack-on-titan.gd2.qingstor.com/qsctl/v2.4.3/qsctl_v2.4.3_linux_amd64.tar.gz tar -zxvf qsctl_v2.4.3_linux_amd64.tar.gz mv qsctl_v2.4.3_linux_amd64 /usr/local/bin/qsctl + rm -rf qsctl_v2.4.3_linux_amd64.tar.gz - name: update components.json id: get_new_version diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index a085b6276..fd945beac 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -37,6 +37,7 @@ jobs: rm -rf qsctl_v2.4.3_linux_amd64.tar.gz wget https://attack-on-titan.gd2.qingstor.com/qsctl/v2.4.3/qsctl_v2.4.3_linux_amd64.tar.gz tar -zxvf qsctl_v2.4.3_linux_amd64.tar.gz + rm -rf qsctl_v2.4.3_linux_amd64.tar.gz mv qsctl_v2.4.3_linux_amd64 /usr/local/bin/qsctl echo "access_key_id: ${{secrets.KS_QSCTL_ACCESS_KEY_ID}}" > qsctl-config.yaml echo "secret_access_key: ${{ secrets.KS_QSCTL_SECRET_ACCESS_KEY }}" >> qsctl-config.yaml diff --git a/controllers/kkinstance/kkinstance_controller.go b/controllers/kkinstance/kkinstance_controller.go index 7bfa4a732..9e860d5f7 100644 --- a/controllers/kkinstance/kkinstance_controller.go +++ b/controllers/kkinstance/kkinstance_controller.go @@ -267,6 +267,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re instanceScope, err := scope.NewInstanceScope(scope.InstanceScopeParams{ Client: r.Client, + Logger: &log, Cluster: cluster, Machine: machine, InfraCluster: infraCluster, diff --git a/controllers/kkmachine/helpers.go b/controllers/kkmachine/helpers.go index 9d6cb29a5..c354c0058 100644 --- a/controllers/kkmachine/helpers.go +++ b/controllers/kkmachine/helpers.go @@ -28,7 +28,6 @@ import ( capierrors "sigs.k8s.io/cluster-api/errors" capiutil "sigs.k8s.io/cluster-api/util" "sigs.k8s.io/cluster-api/util/patch" - ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" infrav1 "github.com/kubesphere/kubekey/v3/api/v1beta1" @@ -37,8 +36,7 @@ import ( func (r *Reconciler) createInstance(ctx context.Context, machineScope *scope.MachineScope, kkInstanceScope scope.KKInstanceScope) (*infrav1.KKInstance, error) { - log := ctrl.LoggerFrom(ctx) - log.V(4).Info("Creating KKInstance") + machineScope.Info("Creating KKInstance") if machineScope.Machine.Spec.Version == nil { err := errors.New("Machine's spec.version must be defined") diff --git a/controllers/kkmachine/kkmachine_controller.go b/controllers/kkmachine/kkmachine_controller.go index 8ed3f89c3..a60f43cd4 100644 --- a/controllers/kkmachine/kkmachine_controller.go +++ b/controllers/kkmachine/kkmachine_controller.go @@ -19,6 +19,7 @@ package kkmachine import ( "context" "fmt" + "sync" "time" "github.com/go-logr/logr" @@ -62,6 +63,7 @@ const ( // Reconciler reconciles a KKMachine object type Reconciler struct { client.Client + mutex sync.Mutex Scheme *runtime.Scheme Recorder record.EventRecorder Tracker *remote.ClusterCacheTracker @@ -163,6 +165,7 @@ func (r *Reconciler) Reconcile(ctx context.Context, req ctrl.Request) (_ ctrl.Re // Create the machine scope machineScope, err := scope.NewMachineScope(scope.MachineScopeParams{ Client: r.Client, + Logger: &log, Cluster: cluster, Machine: machine, InfraCluster: infraCluster, @@ -291,7 +294,12 @@ func (r *Reconciler) reconcileNormal(ctx context.Context, machineScope *scope.Ma } } + if !r.mutex.TryLock() { + machineScope.V(4).Info("Waiting for the last KKInstance to be created") + return ctrl.Result{RequeueAfter: 2 * time.Second}, nil + } instance, err = r.createInstance(ctx, machineScope, kkInstanceScope) + r.mutex.Unlock() if err != nil { machineScope.Error(err, "unable to create kkInstance") r.Recorder.Eventf(machineScope.KKMachine, corev1.EventTypeWarning, "FailedCreate", "Failed to create kkInstance: %v", err) @@ -379,7 +387,7 @@ func (r *Reconciler) findInstance(ctx context.Context, machineScope *scope.Machi machineScope.V(4).Info("KKMachine has an instance id", "instance-id", pid.ID()) // If the ProviderID is populated, describe the instance using the ID. - id := pointer.StringPtr(pid.ID()) + id := pointer.String(pid.ID()) obj := client.ObjectKey{ Namespace: machineScope.KKMachine.Namespace, diff --git a/qsctl_v2.4.3_linux_amd64.tar.gz b/qsctl_v2.4.3_linux_amd64.tar.gz deleted file mode 100644 index 76a297646..000000000 Binary files a/qsctl_v2.4.3_linux_amd64.tar.gz and /dev/null differ diff --git a/test/e2e/config/e2e_conf.yaml b/test/e2e/config/e2e_conf.yaml index 16e8bece3..1b824ea9d 100644 --- a/test/e2e/config/e2e_conf.yaml +++ b/test/e2e/config/e2e_conf.yaml @@ -93,7 +93,7 @@ variables: KUBERNETES_VERSION_MANAGEMENT: "v1.24.0" KUBERNETES_VERSION: "v1.24.0" IMAGE_REPOSITORY: "k8s.gcr.io" - CNI: "./data/cni/calico.yaml" + CNI: "../../data/cni/calico.yaml" EVENT_BRIDGE_INSTANCE_STATE: "true" EXP_CLUSTER_RESOURCE_SET: "true" IP_FAMILY: "IPv4"