func (mpa *MasterProvisionerAliyun) DeleteVirtualCluster(vc *tenancyv1alpha1.Virtualcluster) error {
	log.Info("deleting the ASK of the virtualcluster", "vc-name", vc.Name)
	aliyunAKID, aliyunAKSrt, err := aliyunutil.GetAliyunAKPair(mpa, log)
	if err != nil {
		return err
	}
	askCfg, err := aliyunutil.GetASKConfigs(mpa, log)
	if err != nil {
		return err
	}

	cli, err := sdk.NewClientWithAccessKey(askCfg.RegionID, aliyunAKID, aliyunAKSrt)
	if err != nil {
		return err
	}

	clusterID, err := aliyunutil.GetClusterIDByName(cli, vc.Name, askCfg.RegionID)
	if err != nil {
		return err
	}

	err = aliyunutil.SendDeletionRequest(cli, clusterID, askCfg.RegionID)
	if err != nil {
		return err
	}

	// block until the ASK is deleted or timeout after 120 seconds
	deletionTimeout := time.After(100 * time.Second)
OuterLoop:
	for {
		select {
		case <-time.After(2 * time.Second):
			_, state, err := aliyunutil.GetASKStateAndSlbID(cli, clusterID, askCfg.RegionID)
			if err != nil {
				if aliyunutil.IsSDKErr(err) {
					if aliyunutil.GetSDKErrCode(err) == aliyunutil.ClusterNotFound {
						log.Info("corresponding ASK cluster is not found", "vc-name", vc.Name)
						break OuterLoop
					}
				}
				return err
			}
			if state == "deleting" {
				// once the ASK cluster enter the 'deleting' state, the cloud
				// provider will delete the cluster
				log.Info("ASK cluster is being deleted")
				break OuterLoop
			}
		case <-deletionTimeout:
			return fmt.Errorf("Delete ASK(%s) timeout", vc.Name)
		}
	}

	return nil
}
// DeleteVirtualCluster deletes the ASK cluster corresponding to the given Virtualcluster
// NOTE DeleteVirtualCluster only sends the deletion request to Aliyun and do not promise
// the ASK will be deleted
DeleteVirtualCluster deletes the ASK cluster corresponding to the given Virtualcluster
NOTE DeleteVirtualCluster only sends the deletion request to Aliyun and do not promise
the ASK will be deleted
// DeleteVirtualCluster deletes the ASK cluster corresponding to the given Virtualcluster // NOTE DeleteVirtualCluster only sends the deletion request to Aliyun and do not promise // the ASK will be deleted
func (mpa *MasterProvisionerAliyun) DeleteVirtualCluster(vc *tenancyv1alpha1.Virtualcluster) error {
	log.Info("deleting the ASK of the virtualcluster", "vc-name", vc.Name)
	aliyunAKID, aliyunAKSrt, err := aliyunutil.GetAliyunAKPair(mpa, log)
	if err != nil {
		return err
	}
	askCfg, err := aliyunutil.GetASKConfigs(mpa, log)
	if err != nil {
		return err
	}
	cli, err := sdk.NewClientWithAccessKey(askCfg.RegionID, aliyunAKID, aliyunAKSrt)
	if err != nil {
		return err
	}
	clusterID, err := aliyunutil.GetClusterIDByName(cli, vc.Name, askCfg.RegionID)
	if err != nil {
		return err
	}
	err = aliyunutil.SendDeletionRequest(cli, clusterID, askCfg.RegionID)
	if err != nil {
		return err
	}
	deletionTimeout := time.After(100 * time.Second)
OuterLoop:
	for {
		select {
		case <-time.After(2 * time.Second):
			_, state, err := aliyunutil.GetASKStateAndSlbID(cli, clusterID, askCfg.RegionID)
			if err != nil {
				if aliyunutil.IsSDKErr(err) {
					if aliyunutil.GetSDKErrCode(err) == aliyunutil.ClusterNotFound {
						log.Info("corresponding ASK cluster is not found", "vc-name", vc.Name)
						break OuterLoop
					}
				}
				return err
			}
			if state == "deleting" {
				log.Info("ASK cluster is being deleted")
				break OuterLoop
			}
		case <-deletionTimeout:
			return fmt.Errorf("Delete ASK(%s) timeout", vc.Name)
		}
	}
	return nil
}
func ( mpa * MasterProvisionerAliyun ) DeleteVirtualCluster ( vc * tenancyv1alpha1 . Virtualcluster ) error { log . Info ( " " , " " , vc . Name ) aliyunAKID , aliyunAKSrt , err := aliyunutil . GetAliyunAKPair ( mpa , log ) if err != nil { return err } askCfg , err := aliyunutil . GetASKConfigs ( mpa , log ) if err != nil { return err } cli , err := sdk . NewClientWithAccessKey ( askCfg . RegionID , aliyunAKID , aliyunAKSrt ) if err != nil { return err } clusterID , err := aliyunutil . GetClusterIDByName ( cli , vc . Name , askCfg . RegionID ) if err != nil { return err } err = aliyunutil . SendDeletionRequest ( cli , clusterID , askCfg . RegionID ) if err != nil { return err } deletionTimeout := time . After ( 100 * time . Second ) OuterLoop : for { select { case <- time . After ( 2 * time . Second ) : _ , state , err := aliyunutil . GetASKStateAndSlbID ( cli , clusterID , askCfg . RegionID ) if err != nil { if aliyunutil . IsSDKErr ( err ) { if aliyunutil . GetSDKErrCode ( err ) == aliyunutil . ClusterNotFound { log . Info ( " " , " " , vc . Name ) break OuterLoop } } return err } if state == " " { log . Info ( " " ) break OuterLoop } case <- deletionTimeout : return fmt . Errorf ( " " , vc . Name ) } } return nil }
DeleteVirtualCluster deletes the ASK cluster corresponding to the given Virtualcluster
NOTE DeleteVirtualCluster only sends the deletion request to Aliyun and do not promise
the ASK will be deleted
DeleteVirtualCluster deletes the ASK cluster corresponding to the given Virtualcluster NOTE DeleteVirtualCluster only sends the deletion request to Aliyun and do not promise the ASK will be deleted
// block until the ASK is deleted or timeout after 120 seconds // once the ASK cluster enter the 'deleting' state, the cloud // provider will delete the cluster