【K8S源码之Pod漂移】整体概况分析 controller-manager 中的 nodelifecycle controller(Pod的驱逐)

news2025/1/23 12:57:24

参考

  • k8s 污点驱逐详解-源码分析 - 掘金

  • k8s驱逐篇(5)-kube-controller-manager驱逐 - 良凯尔 - 博客园

  • k8s驱逐篇(6)-kube-controller-manager驱逐-NodeLifecycleController源码分析 - 良凯尔 - 博客园

  • k8s驱逐篇(7)-kube-controller-manager驱逐-taintManager源码分析 - 良凯尔 - 博客园

整体概况分析

  • 基于 k8s 1.19 版本分析

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-h6S3bs1J-1692352728103)(img/nodelifecycle笔记/image-20230818164014721.png)]

TaintManager 与 非TaintManager

  1. TaintManager 模式
    • 发现 Node Unhealthy 后(也就是 Node Ready Condition = False 或 Unknown),会更新 Pod Ready Condition 为 False(表示 Pod 不健康),也会给 Node 打上 NoExecute Effect 的 Taint
    • 之后 TaintManager 根据 Pod 的 Toleration 判断,是否有设置容忍 NoExecute Effect Taint 的 Toleration
      • 没有 Toleration 的话,就立即驱逐
      • 有 Toleration ,会根据 Toleration 设置的时长,定时删除该 Pod
      • 默认情况下,会设置个 5min 的Toleration,也就是 5min 后会删除此 Pod
  2. 非 TaintManager 模式(默认模式)
    • 发现 Node Unhealthy 后,会更新 Pod Ready Condition 为 False(表示 Pod 不健康)
    • 之后会记录该 Node,等待 PodTimeout(5min) - nodegracePeriod(40s) 时间后,驱逐该 Node 上所有 Pod(Node级别驱逐),之后标记该 Node 为 evicted 状态(此处是代码中标记,资源上没有此状态)
    • 之后便只考虑单 Pod 的驱逐(可能考虑部分 Pod 失败等)
      • 若 Node 已经被标记为 evicted 状态,那么可以进行单 Pod 的驱逐
      • 若 Node 没有被标记为 evicted 状态,那将 Node 标记为 tobeevicted 状态,等待上面 Node 级别的驱逐

代码中的几个存储结构

nodeEvictionMap *nodeEvictionMap// nodeEvictionMap stores evictionStatus *data for each node.
*type nodeEvictionMap struct {
lock sync.Mutex
nodeEvictions map[string]evictionStatus
}
记录所有 node 的状态
1. 健康 unmarked
2. 等待驱逐 tobeevicted
3. 驱逐完成 evicted
zoneStates map[string]ZoneStatetype ZoneState string记录 zone 的健康状态
1. 新zone Initial
2. 健康的zone Normal
3. 部分健康zone PartialDisruption
4. 完全不健康 FullDisruption
这个是用于设置该zone 的驱逐速率
zonePodEvictor map[string]*scheduler.RateLimitedTimedQueue失联(不健康)的 Node 会放入此结构中,等待被驱逐,之后nodeEvictionMap 对应的状态记录会被设置为 evicted
1. 该结构,key 为zone,value 为限速队列处理(也就是上面驱逐效率起作用的地方)
2. 当一个 node 不健康,首先会计算出该 node 对应的zone
3. 然后放入该结构中
nodeHealthMap *nodeHealthMaptype nodeHealthMap struct {
lock sync.RWMutex
nodeHealths map[string]*nodeHealthData
}
type nodeHealthData struct {
probeTimestamp metav1.Time
readyTransitionTimestamp metav1.Time
status *v1.NodeStatus
lease *coordv1.Lease
}
记录每个node的健康状态,主要在 monitorHealth 函数中使用
1. 其中 probeTimestamp 最关键,该参数记录该 Node 最后一次健康的时间,也就是失联前最后一个 lease 的时间
2. 之后根据 probeTimestamp 和宽限时间 gracePeriod,判断该 node 是否真正失联,并设置为 unknown 状态

整体代码流程分析

// Run starts an asynchronous loop that monitors the status of cluster nodes.
func (nc *Controller) Run(stopCh <-chan struct{}) {
  defer utilruntime.HandleCrash()
​
  klog.Infof("Starting node controller")
  defer klog.Infof("Shutting down node controller")
  
  // 1.等待leaseInformer、nodeInformer、podInformerSynced、daemonSetInformerSynced同步完成。
  if !cache.WaitForNamedCacheSync("taint", stopCh, nc.leaseInformerSynced, nc.nodeInformerSynced, nc.podInformerSynced, nc.daemonSetInformerSynced) {
    return
  }
  
  // 2.如果enable-taint-manager=true,开启nc.taintManager.Run
  if nc.runTaintManager {
    go nc.taintManager.Run(stopCh)
  }
  
  // Close node update queue to cleanup go routine.
  defer nc.nodeUpdateQueue.ShutDown()
  defer nc.podUpdateQueue.ShutDown()
  
  // 3.执行doNodeProcessingPassWorker,这个是处理nodeUpdateQueue队列的node
  // Start workers to reconcile labels and/or update NoSchedule taint for nodes.
  for i := 0; i < scheduler.UpdateWorkerSize; i++ {
    // Thanks to "workqueue", each worker just need to get item from queue, because
    // the item is flagged when got from queue: if new event come, the new item will
    // be re-queued until "Done", so no more than one worker handle the same item and
    // no event missed.
    go wait.Until(nc.doNodeProcessingPassWorker, time.Second, stopCh)
  }
  
// 4.doPodProcessingWorker,这个是处理podUpdateQueue队列的pod
  for i := 0; i < podUpdateWorkerSize; i++ {
    go wait.Until(nc.doPodProcessingWorker, time.Second, stopCh)
  }
  
  // 5. 如果开启了feature-gates=TaintBasedEvictions=true,执行doNoExecuteTaintingPass函数。否则执行doEvictionPass函数
  if nc.useTaintBasedEvictions {
    // Handling taint based evictions. Because we don't want a dedicated logic in TaintManager for NC-originated
    // taints and we normally don't rate limit evictions caused by taints, we need to rate limit adding taints.
    go wait.Until(nc.doNoExecuteTaintingPass, scheduler.NodeEvictionPeriod, stopCh)
  } else {
    // Managing eviction of nodes:
    // When we delete pods off a node, if the node was not empty at the time we then
    // queue an eviction watcher. If we hit an error, retry deletion.
    go wait.Until(nc.doEvictionPass, scheduler.NodeEvictionPeriod, stopCh)
  }
  
  
  // 6.一直监听node状态是否健康
  // Incorporate the results of node health signal pushed from kubelet to master.
  go wait.Until(func() {
    if err := nc.monitorNodeHealth(); err != nil {
      klog.Errorf("Error monitoring node health: %v", err)
    }
  }, nc.nodeMonitorPeriod, stopCh)

  <-stopCh
}

MonitorNodeHealth

在这里插入图片描述

此部分有如下几个作用

  1. 读取 Node 的 Label,用于确定 Node 属于哪个 zone;若该 zone 是新增的,就注册到 zonePodEvictor 或 zoneNoExecuteTainter (TaintManager 模式)

    • zonePodEvictor 后续用于该 zone 中失联的 Node,用于 Node 级别驱逐(就是驱逐 Node 上所有 Pod,并设置为 evicted 状态,此部分参见)

    • // pkg/controller/nodelifecycle/node_lifecycle_controller.go
      // addPodEvictorForNewZone checks if new zone appeared, and if so add new evictor.
      // dfy: 若出现新的 zone ,初始化 zonePodEvictor 或 zoneNoExecuteTainter
      func (nc *Controller) addPodEvictorForNewZone(node *v1.Node) {
      	nc.evictorLock.Lock()
      	defer nc.evictorLock.Unlock()
      	zone := utilnode.GetZoneKey(node)
      	// dfy: 若出现新的 zone ,初始化 zonePodEvictor 或 zoneNoExecuteTainter
      	if _, found := nc.zoneStates[zone]; !found {
      		// dfy: 没有找到 zone value,设置为 Initial
      		nc.zoneStates[zone] = stateInitial
      		// dfy: 没有 TaintManager,创建一个 限速队列,不太清楚有什么作用???
      		if !nc.runTaintManager {
      			// dfy: zonePodEvictor 负责将 pod 从无响应的节点驱逐出去
      			nc.zonePodEvictor[zone] =
      				scheduler.NewRateLimitedTimedQueue(
      					flowcontrol.NewTokenBucketRateLimiter(nc.evictionLimiterQPS, scheduler.EvictionRateLimiterBurst))
      		} else {
      			// dfy: zoneNoExecuteTainter 负责为 node 打上污点 taint
      			nc.zoneNoExecuteTainter[zone] =
      				scheduler.NewRateLimitedTimedQueue(
      					flowcontrol.NewTokenBucketRateLimiter(nc.evictionLimiterQPS, scheduler.EvictionRateLimiterBurst))
      		}
      		// Init the metric for the new zone.
      		klog.Infof("Initializing eviction metric for zone: %v", zone)
      		evictionsNumber.WithLabelValues(zone).Add(0)
      	}
      }
      
      func (nc *Controller) doEvictionPass() {
      	nc.evictorLock.Lock()
      	defer nc.evictorLock.Unlock()
      	for k := range nc.zonePodEvictor {
      		// Function should return 'false' and a time after which it should be retried, or 'true' if it shouldn't (it succeeded).
      		nc.zonePodEvictor[k].Try(func(value scheduler.TimedValue) (bool, time.Duration) {
      			// dfy: 此处 value.Value 存储的是 Cluster Name
      			node, err := nc.nodeLister.Get(value.Value)
      			if apierrors.IsNotFound(err) {
      				klog.Warningf("Node %v no longer present in nodeLister!", value.Value)
      			} else if err != nil {
      				klog.Warningf("Failed to get Node %v from the nodeLister: %v", value.Value, err)
      			}
      			nodeUID, _ := value.UID.(string)
      			// dfy: 获得分配到该节点上的 Pod
      			pods, err := nc.getPodsAssignedToNode(value.Value)
      			if err != nil {
      				utilruntime.HandleError(fmt.Errorf("unable to list pods from node %q: %v", value.Value, err))
      				return false, 0
      			}
      			// dfy: 删除 Pod
      			remaining, err := nodeutil.DeletePods(nc.kubeClient, pods, nc.recorder, value.Value, nodeUID, nc.daemonSetStore)
      			if err != nil {
      				// We are not setting eviction status here.
      				// New pods will be handled by zonePodEvictor retry
      				// instead of immediate pod eviction.
      				utilruntime.HandleError(fmt.Errorf("unable to evict node %q: %v", value.Value, err))
      				return false, 0
      			}
      			// dfy: 在nodeEvictionMap设置node的状态为evicted
      			if !nc.nodeEvictionMap.setStatus(value.Value, evicted) {
      				klog.V(2).Infof("node %v was unregistered in the meantime - skipping setting status", value.Value)
      			}
      			if remaining {
      				klog.Infof("Pods awaiting deletion due to Controller eviction")
      			}
      
      			if node != nil {
      				zone := utilnode.GetZoneKey(node)
      				evictionsNumber.WithLabelValues(zone).Inc()
      			}
      
      			return true, 0
      		})
      	}
      }
      
  2. 监听 Node 健康状态(通过监听 Node Lease 进行判别)

    • 若 Lease 不更新,且超过了容忍时间 gracePeriod,认为该 Node 失联(更新 Status Ready Condition 为 Unknown)

    • // tryUpdateNodeHealth checks a given node's conditions and tries to update it. Returns grace period to
      // which given node is entitled, state of current and last observed Ready Condition, and an error if it occurred.
      func (nc *Controller) tryUpdateNodeHealth(node *v1.Node) (time.Duration, v1.NodeCondition, *v1.NodeCondition, error) {
        // 省略一大部分 probeTimestamp 更新逻辑
        // dfy: 通过 lease 更新,来更新 probeTimestamp
        	observedLease, _ := nc.leaseLister.Leases(v1.NamespaceNodeLease).Get(node.Name)
      	if observedLease != nil && (savedLease == nil || savedLease.Spec.RenewTime.Before(observedLease.Spec.RenewTime)) {
      		nodeHealth.lease = observedLease
      		nodeHealth.probeTimestamp = nc.now()
      	}
        
      	// dfy: 注意此处, Lease 没更新,导致 probeTimestamp 没变动,因此 现在时间超过了容忍时间,将此 Node 视作失联 Node
      	if nc.now().After(nodeHealth.probeTimestamp.Add(gracePeriod)) {
      		// NodeReady condition or lease was last set longer ago than gracePeriod, so
      		// update it to Unknown (regardless of its current value) in the master.
      
      		nodeConditionTypes := []v1.NodeConditionType{
      			v1.NodeReady,
      			v1.NodeMemoryPressure,
      			v1.NodeDiskPressure,
      			v1.NodePIDPressure,
      			// We don't change 'NodeNetworkUnavailable' condition, as it's managed on a control plane level.
      			// v1.NodeNetworkUnavailable,
      		}
      
      		nowTimestamp := nc.now()
      		// dfy: 寻找 node 是否有上面几个异常状态
      		for _, nodeConditionType := range nodeConditionTypes {
      			// dfy: 具有异常状态,就进行记录
      			_, currentCondition := nodeutil.GetNodeCondition(&node.Status, nodeConditionType)
      			if currentCondition == nil {
      				klog.V(2).Infof("Condition %v of node %v was never updated by kubelet", nodeConditionType, node.Name)
      				node.Status.Conditions = append(node.Status.Conditions, v1.NodeCondition{
      					Type:               nodeConditionType,
      					Status:             v1.ConditionUnknown,
      					Reason:             "NodeStatusNeverUpdated",
      					Message:            "Kubelet never posted node status.",
      					LastHeartbeatTime:  node.CreationTimestamp,
      					LastTransitionTime: nowTimestamp,
      				})
      			} else {
      				klog.V(2).Infof("node %v hasn't been updated for %+v. Last %v is: %+v",
      					node.Name, nc.now().Time.Sub(nodeHealth.probeTimestamp.Time), nodeConditionType, currentCondition)
      				if currentCondition.Status != v1.ConditionUnknown {
      					currentCondition.Status = v1.ConditionUnknown
      					currentCondition.Reason = "NodeStatusUnknown"
      					currentCondition.Message = "Kubelet stopped posting node status."
      					currentCondition.LastTransitionTime = nowTimestamp
      				}
      			}
      		}
      		// We need to update currentReadyCondition due to its value potentially changed.
      		_, currentReadyCondition = nodeutil.GetNodeCondition(&node.Status, v1.NodeReady)
      
      		if !apiequality.Semantic.DeepEqual(currentReadyCondition, &observedReadyCondition) {
      			if _, err := nc.kubeClient.CoreV1().Nodes().UpdateStatus(context.TODO(), node, metav1.UpdateOptions{}); err != nil {
      				klog.Errorf("Error updating node %s: %v", node.Name, err)
      				return gracePeriod, observedReadyCondition, currentReadyCondition, err
      			}
      			nodeHealth = &nodeHealthData{
      				status:                   &node.Status,
      				probeTimestamp:           nodeHealth.probeTimestamp,
      				readyTransitionTimestamp: nc.now(),
      				lease:                    observedLease,
      			}
      			return gracePeriod, observedReadyCondition, currentReadyCondition, nil
      		}
      	}
      
      	return gracePeriod, observedReadyCondition, currentReadyCondition, nil
      }
      
  3. 根据 zone 设置驱逐速率

    • 每个 zone 有不同数量的 Node,根据该 zone 中 Node 失联数量的占比,设置不同的驱逐速率

    • // dfy: 1. 计算 zone 不健康程度; 2. 根据 zone 不健康程度设置不同的驱逐速率
      func (nc *Controller) handleDisruption(zoneToNodeConditions map[string][]*v1.NodeCondition, nodes []*v1.Node) {
      	newZoneStates := map[string]ZoneState{}
      	allAreFullyDisrupted := true
      	for k, v := range zoneToNodeConditions {
      		zoneSize.WithLabelValues(k).Set(float64(len(v)))
      		// dfy: 计算该 zone 的不健康程度(就是失联 node 的占比)
          // nc.computeZoneStateFunc = nc.ComputeZoneState
      		unhealthy, newState := nc.computeZoneStateFunc(v)
      		zoneHealth.WithLabelValues(k).Set(float64(100*(len(v)-unhealthy)) / float64(len(v)))
      		unhealthyNodes.WithLabelValues(k).Set(float64(unhealthy))
      		if newState != stateFullDisruption {
      			allAreFullyDisrupted = false
      		}
      		newZoneStates[k] = newState
      		if _, had := nc.zoneStates[k]; !had {
      			klog.Errorf("Setting initial state for unseen zone: %v", k)
      			nc.zoneStates[k] = stateInitial
      		}
      	}
      
      	allWasFullyDisrupted := true
      	for k, v := range nc.zoneStates {
      		if _, have := zoneToNodeConditions[k]; !have {
      			zoneSize.WithLabelValues(k).Set(0)
      			zoneHealth.WithLabelValues(k).Set(100)
      			unhealthyNodes.WithLabelValues(k).Set(0)
      			delete(nc.zoneStates, k)
      			continue
      		}
      		if v != stateFullDisruption {
      			allWasFullyDisrupted = false
      			break
      		}
      	}
      
      	// At least one node was responding in previous pass or in the current pass. Semantics is as follows:
      	// - if the new state is "partialDisruption" we call a user defined function that returns a new limiter to use,
      	// - if the new state is "normal" we resume normal operation (go back to default limiter settings),
      	// - if new state is "fullDisruption" we restore normal eviction rate,
      	//   - unless all zones in the cluster are in "fullDisruption" - in that case we stop all evictions.
      	if !allAreFullyDisrupted || !allWasFullyDisrupted {
      		// We're switching to full disruption mode
      		if allAreFullyDisrupted {
      			klog.V(0).Info("Controller detected that all Nodes are not-Ready. Entering master disruption mode.")
      			for i := range nodes {
      				if nc.runTaintManager {
      					_, err := nc.markNodeAsReachable(nodes[i])
      					if err != nil {
      						klog.Errorf("Failed to remove taints from Node %v", nodes[i].Name)
      					}
      				} else {
      					nc.cancelPodEviction(nodes[i])
      				}
      			}
      			// We stop all evictions.
      			for k := range nc.zoneStates {
      				if nc.runTaintManager {
      					nc.zoneNoExecuteTainter[k].SwapLimiter(0)
      				} else {
      					nc.zonePodEvictor[k].SwapLimiter(0)
      				}
      			}
      			for k := range nc.zoneStates {
      				nc.zoneStates[k] = stateFullDisruption
      			}
      			// All rate limiters are updated, so we can return early here.
      			return
      		}
      		// We're exiting full disruption mode
      		if allWasFullyDisrupted {
      			klog.V(0).Info("Controller detected that some Nodes are Ready. Exiting master disruption mode.")
      			// When exiting disruption mode update probe timestamps on all Nodes.
      			now := nc.now()
      			for i := range nodes {
      				v := nc.nodeHealthMap.getDeepCopy(nodes[i].Name)
      				v.probeTimestamp = now
      				v.readyTransitionTimestamp = now
      				nc.nodeHealthMap.set(nodes[i].Name, v)
      			}
      			// We reset all rate limiters to settings appropriate for the given state.
      			for k := range nc.zoneStates {
      				// dfy: 设置 zone 的驱逐速率
      				nc.setLimiterInZone(k, len(zoneToNodeConditions[k]), newZoneStates[k])
      				nc.zoneStates[k] = newZoneStates[k]
      			}
      			return
      		}
      		// We know that there's at least one not-fully disrupted so,
      		// we can use default behavior for rate limiters
      		for k, v := range nc.zoneStates {
      			newState := newZoneStates[k]
      			if v == newState {
      				continue
      			}
      			klog.V(0).Infof("Controller detected that zone %v is now in state %v.", k, newState
      			// dfy: 设置 zone 的驱逐速率
      			nc.setLimiterInZone(k, len(zoneToNodeConditions[k]), newState)
      			nc.zoneStates[k] = newState
      		}
      	}
      }
                            
      // ComputeZoneState returns a slice of NodeReadyConditions for all Nodes in a given zone.
      // The zone is considered:
      // - fullyDisrupted if there're no Ready Nodes,
      // - partiallyDisrupted if at least than nc.unhealthyZoneThreshold percent of Nodes are not Ready,
      // - normal otherwise
      func (nc *Controller) ComputeZoneState(nodeReadyConditions []*v1.NodeCondition) (int, ZoneState) {
      	readyNodes := 0
      	notReadyNodes := 0
      	for i := range nodeReadyConditions {
      		if nodeReadyConditions[i] != nil && nodeReadyConditions[i].Status == v1.ConditionTrue {
      			readyNodes++
      		} else {
      			notReadyNodes++
      		}
      	}
      	switch {
      	case readyNodes == 0 && notReadyNodes > 0:
      		return notReadyNodes, stateFullDisruption
      	case notReadyNodes > 2 && float32(notReadyNodes)/float32(notReadyNodes+readyNodes) >= nc.unhealthyZoneThreshold:
      		return notReadyNodes, statePartialDisruption
      	default:
      		return notReadyNodes, stateNormal
      	}
      }
      
      // dfy: 根据该 zone 健康状态(也就是健康比例),设置驱逐效率(频率)
      func (nc *Controller) setLimiterInZone(zone string, zoneSize int, state ZoneState) {
      	switch state {
      	case stateNormal:
      		if nc.runTaintManager {
      			nc.zoneNoExecuteTainter[zone].SwapLimiter(nc.evictionLimiterQPS)
      		} else {
      			nc.zonePodEvictor[zone].SwapLimiter(nc.evictionLimiterQPS)
      		}
      	case statePartialDisruption:
      		if nc.runTaintManager {
      			nc.zoneNoExecuteTainter[zone].SwapLimiter(
      				nc.enterPartialDisruptionFunc(zoneSize))
      		} else {
      			nc.zonePodEvictor[zone].SwapLimiter(
      				nc.enterPartialDisruptionFunc(zoneSize))
      		}
      	case stateFullDisruption:
      		if nc.runTaintManager {
      			nc.zoneNoExecuteTainter[zone].SwapLimiter(
      				nc.enterFullDisruptionFunc(zoneSize))
      		} else {
      			nc.zonePodEvictor[zone].SwapLimiter(
      				nc.enterFullDisruptionFunc(zoneSize))
      		}
      	}
      }
      
  4. 进行 Pod 驱逐的处理 proceeNoTaintBaseEviction

TaintManger.Run

  • TainManager 的驱逐逻辑,看代码不难理解,大概说明

    1. 若开启 TaintManager 模式,所有 Pod、Node 的改变都会被放入,nc.tc.podUpdateQueue 和 nc.tc.nodeUpdateQueue 中

    2. 当 Node 失联时,会被打上 NoExecute Effect Taint(不在此处,在 main Controller.Run 函数中)

    3. 此处会先处理 nc.tc.nodeUpdateQueue 的驱逐

      • 首先会检查 Node 是否有 NoExecute Effect Taint;没有就取消驱逐

      • 有的话,进行 Pod 的逐个驱逐,检查 Pod 是否有该 Taint 的 toleration,有的话,就根据 toleration 设置 pod 的定时删除;没有 Toleration,就立即删除

    4. 接下来处理 nc.tc.podUpdateQueue 的驱逐

      • 进行 Pod 的逐个驱逐,检查 Pod 是否有该 Taint 的 toleration,有的话,就根据 toleration 设置 pod 的定时删除;没有 Toleration,就立即删除

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-OUQO1kpN-1692352728105)(img/nodelifecycle笔记/image-20230818160542117.png)]

Node Pod 的处理

  • 此处就是 nc.podUpdateQueue 和 nc.NodeUpdateQueue 的一些驱逐逻辑
  • 比如给 Node 打上 NoSchedule Taint
  • 检测到 Node 不健康,给 Pod 打上 Ready Condition = False 的 Status Condition
  • 进行 Pod 驱逐的处理 proceeNoTaintBaseEviction

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ogwwC6Jx-1692352728105)(img/nodelifecycle笔记/image-20230818160649929.png)]

驱逐

  • 此处 TaintManager 模式,只是打上 NoExecute Effect Taint —— doNoExecuteTaintingPass 函数
  • 非 TaintManager 模式,会清理 zonePodEvicotr 记录的 Node 上的所有 Pod( Node 级别驱逐)

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-lHU7oJde-1692352728105)(img/nodelifecycle笔记/image-20230818160708127.png)]

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/894959.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

完美解决微信小程序van-field left-icon自定义图片

实现效果&#xff1a; <view class"userName"><van-field left-icon"{{loginUserNameIcon}}" clearable class"fieldName" value"{{ loginUserName }}" placeholder"请输入账号" border"{{ false }}" &g…

python入门--抓取网页文字

要抓取网页文字&#xff0c;我们需要使用Python的一个库&#xff0c;叫做requests。这个库可以帮助我们向网站发送请求&#xff0c;获取网站的内容。 下面是一个简单的示例代码&#xff0c;用于抓取一个网页的文字&#xff1a; import requests import re import os import i…

年度数码刺客 真香小主机 英特尔 蝰蛇峡谷

作为英特尔旗下的迷你工作站&#xff0c;英特尔峡谷系列设备每年都能吸引不少眼球&#xff0c;今年英特尔推出的最新一代的蝰蛇峡谷除了采用英特尔CPU之外&#xff0c;更加重要的是加入了英特尔Arc A770M显卡&#xff0c;这是一款移动显卡&#xff0c;也算是英特尔重返游戏级独…

精彩回顾 | 迪捷软件出席2023ATC汽车电子与软件技术周

2023年8月18日&#xff0c;由ATC汽车技术会议主办&#xff0c;上海市集成电路行业协会支持的“2023ATC汽车电子与软件技术周”在上海市圆满落幕。迪捷软件上海参展之行圆满收官。 ▲开幕式 本次峰会汇聚了整车厂、汽车零部件集团、软硬件方案提供商、软件工具供应商、软件测试…

优秀产品经理所必备的6大产品思维

作为产品经理&#xff0c;我们需要真正了解产品思维&#xff0c;其核心就是透过现象看本质&#xff0c;我们从事情的宏观到微观&#xff0c;逐层抽丝剥茧&#xff0c;发现本源。如果我们无法透过现象看本质&#xff0c;那么在日常工作中往往不能深刻认识和分析问题&#xff0c;…

【HarmonyOS】codelab在hvigor版本2.4.2上无法运行问题

【关键字】 HarmonyOS、codelab、hvigor 【问题描述】 有cp反馈集成鸿蒙codelab报错。 下载音乐专辑示例文件&#xff08;一次开发&#xff0c;多端部署-音乐专辑&#xff08;ArkTS&#xff09; (huawei.com)&#xff09;后构建项目&#xff0c;显示找不到2.5.0的hvigor。 …

设计模式-过滤器模式(使用案例)

过滤器模式&#xff08;Filter Pattern&#xff09;或标准模式&#xff08;Criteria Pattern&#xff09;是一种设计模式&#xff0c;这种模式允许开发人员使用不同的标准来过滤一组对象&#xff0c;通过逻辑运算以解耦的方式把它们连接起来。这种类型的设计模式属于结构型模式…

解决@MapKey is required

问题复现&#xff1a; 出现原因&#xff1a; 因为使用了mybatisX插件&#xff0c;导致检查报错mapkey is required 当我们在mapper接口中产生错误&#xff0c;提示MapKey is required 时 解决方案&#xff1a; 1、关闭mybatis的检查&#xff0c;ctrlalts打开setting&#x…

ATFX汇评:英国7月零售销售年率大降,GBPUSD仍未升破1.3000

ATFX汇评&#xff1a;7月季调后零售销售年率&#xff0c;最新值-3.2%&#xff0c;前值-1.6%&#xff0c;降幅扩大&#xff1b;7月季调后核心零售销售年率&#xff0c;最新值-3.4%&#xff0c;前值-1.6%&#xff0c;降幅扩大。零售销售综合衡量除服务业外包括所有主要从事零售业…

Quest 2积分榜发布,快来查看你的排名吧,附上最新规则解读

在Quest 2发布时&#xff0c;Sui Network中文区发布了《详解Quest 2积分与奖励规则》带领大家解读活动规则。经过漫长而又焦急的等待&#xff0c;终于迎来了Quest 2积分榜的发布。与此同时&#xff0c;活动信息及规则也有了些许调整。 快前往Quest网站&#xff0c;查看你的排名…

HttpClint 项目中使用

大家好 , 我是苏麟 , 今天带来一个HTTP通信库 HttpClient . HttpClient是Apache Jakarta Common 下的子项目&#xff0c;可以用来提供高效的、最新的、功能丰富的支持 HTTP 协议的客户端编程工具包 . HttpClient的功能包括但不限于 1.模拟浏览器发送HTTP请求&#xff0c;发送…

echarts地图 省-市-县

// 直接用就行&#xff0c;已经是组件了 // 数据来源地址 http://datav.aliyun.com/portal/school/atlas/area_selector#&lat31.769817845138945&lng104.29901249999999&zoom4 // 例面的china.geo.json文件见https://geo.datav.aliyun.com/areas_v3/bound/100000_…

将vue项目通过electron打包成windows可执行程序

将vue项目打包成windows可执行程序 1、准备好dist将整个项目打包 npm run build2、安装electron依赖 npm install electron --save-dev npm install electron-packager --save-dev"electron": "^13.1.4", "electron-packager": "^15.2.0…

【Unity】坐标转换经纬度方法(应用篇)

【Unity】坐标转换经纬度方法&#xff08;应用篇&#xff09; 解决地图中经纬度坐标转换与unity坐标互转的问题。使用线性变换的方法&#xff0c;理论上可以解决小范围内所以坐标转换的问题。 之前有写过[Unity]坐标转换经纬度方法&#xff08;原理篇),在实际使用中&#xff0c…

外卖福利来了,以后都10元以下了

扫最后面的二维码注册&#xff0c;收藏起来&#xff0c;是个网页 使用方法&#xff1a; 纯订单 不需要评价 消费反馈 需要上传评价的截图 没要求的最少一张照片 有要求的按要求 看清美团还是饿了么 不能夸平台 美团不能修好评价 饿了么可以改一下

linux学习(文件描述符)[12]

输出重定向 本质在OS内部&#xff0c;更改fd对应内容的指向 #include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h>//myfile helloworld //int main(int argc,…

MySQL语法及常用数据类型

一、SQL语言概述 对数据库进行查询和修改操作的语言叫做SQL。SQL的含义就是结构化查询语言&#xff08;Structured Query Language&#xff09;。SQL包含以下4个部分&#xff1a; 1、数据定义语言&#xff08;DDL&#xff09;&#xff1a;DROP、CREATE、ALTER等语句&#xff…

这些选品神器,跨境卖家都在用

相信许多跨境电商商家至今不懂得如何选品&#xff0c;不会选&#xff1f;选什么类目&#xff1f;在哪选&#xff1f; 今天给大家整理一波实用选品工具&#xff0c;赶紧来码住。 1、TikTok 在国外流行着这么一句话:“TikTok mademe buyit”。 TikTok有超过 20亿的流量&#x…

ReentrantLock源码解析

定义 可重入锁&#xff0c;对于同一个线程可以重复获得此锁。分为FailLock和NonfairLock。 加锁就是将exclusiveOwnerThread设置为当前线程&#xff0c;且将status加一&#xff0c;解锁就status-1&#xff0c;且exclusiveOwnerThread设置为null。 公平锁&#xff1a;根据先来后…

C# Linq源码分析之Take (三)

概要 本文在前两篇Take源码分析的基础上&#xff0c;着重分析Range参数中有倒数的情况&#xff0c;即分析TakeRangeFromEndIterator的源码实现。 源码及分析 TakeRangeFromEndIterator方法用于处理Range中的开始和结束索引存在倒数的情况。该方法位于Take.cs文件中。通过yie…