func (pe *ProbeEvent) addBlockDeviceEvent(msg controller.EventMessage) {
	// bdAPIList is the list of all the BlockDevice resources in the cluster
	bdAPIList, err := pe.Controller.ListBlockDeviceResource(true)
	if err != nil {
		klog.Error(err)
		go Rescan(pe.Controller)
		return
	}

	isGPTBasedUUIDEnabled := features.FeatureGates.IsEnabled(features.GPTBasedUUID)

	isErrorDuringUpdate := false
	erroredDevices := make([]string, 0)

	// iterate through each block device and perform the add/update operation
	for _, device := range msg.Devices {
		klog.Infof("Processing details for %s", device.DevPath)
		pe.Controller.FillBlockDeviceDetails(device)

		// add all devices to the hierarchy cache, irrespective of whether they will be
		// filtered at a later stage. This is done so that a complete disk hierarchy is available
		// at all times by NDM. It also helps in device processing when complex filter configurations
		// are provided. Ref: https://github.com/openebs/openebs/issues/3321
		pe.addBlockDeviceToHierarchyCache(*device)

		// if ApplyFilter returns true then we process the event further
		if !pe.Controller.ApplyFilter(device) {
			continue
		}
		klog.Infof("Processed details for %s", device.DevPath)

		if isGPTBasedUUIDEnabled {
			if isParentOrSlaveDevice(*device, erroredDevices) {
				klog.Warningf("device: %s skipped, because the parent / slave device has errored", device.DevPath)
				continue
			}
			err := pe.addBlockDevice(*device, bdAPIList)
			if err != nil {
				isErrorDuringUpdate = true
				erroredDevices = append(erroredDevices, device.DevPath)
				klog.Error(err)
			}
		} else {
			// if GPTBasedUUID is disabled and the device type is partition,
			// the event can be skipped.
			if device.DeviceAttributes.DeviceType == libudevwrapper.UDEV_PARTITION {
				klog.Info("GPTBasedUUID disabled. skip creating block device resource for partition.")
				continue
			}
			deviceInfo := pe.Controller.NewDeviceInfoFromBlockDevice(device)

			existingBlockDeviceResource := pe.Controller.GetExistingBlockDeviceResource(bdAPIList, deviceInfo.UUID)
			err := pe.Controller.PushBlockDeviceResource(existingBlockDeviceResource, deviceInfo)
			if err != nil {
				isErrorDuringUpdate = true
				klog.Error(err)
			}
		}
	}

	if isErrorDuringUpdate {
		go Rescan(pe.Controller)
	}
}
// addBlockDeviceEvent fill block device details from different probes and push it to etcd
addBlockDeviceEvent fill block device details from different probes and push it to etcd
// addBlockDeviceEvent fill block device details from different probes and push it to etcd
func (pe *ProbeEvent) addBlockDeviceEvent(msg controller.EventMessage) {
	bdAPIList, err := pe.Controller.ListBlockDeviceResource(true)
	if err != nil {
		klog.Error(err)
		go Rescan(pe.Controller)
		return
	}
	isGPTBasedUUIDEnabled := features.FeatureGates.IsEnabled(features.GPTBasedUUID)
	isErrorDuringUpdate := false
	erroredDevices := make([]string, 0)
	for _, device := range msg.Devices {
		klog.Infof("Processing details for %s", device.DevPath)
		pe.Controller.FillBlockDeviceDetails(device)
		pe.addBlockDeviceToHierarchyCache(*device)
		if !pe.Controller.ApplyFilter(device) {
			continue
		}
		klog.Infof("Processed details for %s", device.DevPath)
		if isGPTBasedUUIDEnabled {
			if isParentOrSlaveDevice(*device, erroredDevices) {
				klog.Warningf("device: %s skipped, because the parent / slave device has errored", device.DevPath)
				continue
			}
			err := pe.addBlockDevice(*device, bdAPIList)
			if err != nil {
				isErrorDuringUpdate = true
				erroredDevices = append(erroredDevices, device.DevPath)
				klog.Error(err)
			}
		} else {
			if device.DeviceAttributes.DeviceType == libudevwrapper.UDEV_PARTITION {
				klog.Info("GPTBasedUUID disabled. skip creating block device resource for partition.")
				continue
			}
			deviceInfo := pe.Controller.NewDeviceInfoFromBlockDevice(device)
			existingBlockDeviceResource := pe.Controller.GetExistingBlockDeviceResource(bdAPIList, deviceInfo.UUID)
			err := pe.Controller.PushBlockDeviceResource(existingBlockDeviceResource, deviceInfo)
			if err != nil {
				isErrorDuringUpdate = true
				klog.Error(err)
			}
		}
	}
	if isErrorDuringUpdate {
		go Rescan(pe.Controller)
	}
}
func ( pe * ProbeEvent ) addBlockDeviceEvent ( msg controller . EventMessage ) { bdAPIList , err := pe . Controller . ListBlockDeviceResource ( true ) if err != nil { klog . Error ( err ) go Rescan ( pe . Controller ) return } isGPTBasedUUIDEnabled := features . FeatureGates . IsEnabled ( features . GPTBasedUUID ) isErrorDuringUpdate := false erroredDevices := make ( [ ] string , 0 ) for _ , device := range msg . Devices { klog . Infof ( " " , device . DevPath ) pe . Controller . FillBlockDeviceDetails ( device ) pe . addBlockDeviceToHierarchyCache ( * device ) if ! pe . Controller . ApplyFilter ( device ) { continue } klog . Infof ( " " , device . DevPath ) if isGPTBasedUUIDEnabled { if isParentOrSlaveDevice ( * device , erroredDevices ) { klog . Warningf ( " " , device . DevPath ) continue } err := pe . addBlockDevice ( * device , bdAPIList ) if err != nil { isErrorDuringUpdate = true erroredDevices = append ( erroredDevices , device . DevPath ) klog . Error ( err ) } } else { if device . DeviceAttributes . DeviceType == libudevwrapper . UDEV_PARTITION { klog . Info ( " " ) continue } deviceInfo := pe . Controller . NewDeviceInfoFromBlockDevice ( device ) existingBlockDeviceResource := pe . Controller . GetExistingBlockDeviceResource ( bdAPIList , deviceInfo . UUID ) err := pe . Controller . PushBlockDeviceResource ( existingBlockDeviceResource , deviceInfo ) if err != nil { isErrorDuringUpdate = true klog . Error ( err ) } } } if isErrorDuringUpdate { go Rescan ( pe . Controller ) } }
addBlockDeviceEvent fill block device details from different probes and push it to etcd
addBlockDeviceEvent fill block device details from different probes and push it to etcd
// bdAPIList is the list of all the BlockDevice resources in the cluster // iterate through each block device and perform the add/update operation // add all devices to the hierarchy cache, irrespective of whether they will be // filtered at a later stage. This is done so that a complete disk hierarchy is available // at all times by NDM. It also helps in device processing when complex filter configurations // are provided. Ref: https://github.com/openebs/openebs/issues/3321 // if ApplyFilter returns true then we process the event further // if GPTBasedUUID is disabled and the device type is partition, // the event can be skipped.