MarkFaulty marks the given device and corresponding devmapper device ID as faulty. The snapshotter might attempt to recreate a device in 'Faulty' state with another devmapper ID in subsequent calls, and in case of success its status will be changed to 'Created' or 'Activated'. The devmapper dev ID w
(ctx context.Context, name string)
| 137 | // subsequent calls, and in case of success its status will be changed to 'Created' or 'Activated'. |
| 138 | // The devmapper dev ID will remain in 'deviceFaulty' state until manually handled by a user. |
| 139 | func (m *PoolMetadata) MarkFaulty(ctx context.Context, name string) error { |
| 140 | return m.db.Update(func(tx *bolt.Tx) error { |
| 141 | var ( |
| 142 | device = DeviceInfo{} |
| 143 | devBucket = tx.Bucket(devicesBucketName) |
| 144 | ) |
| 145 | |
| 146 | if err := getObject(devBucket, name, &device); err != nil { |
| 147 | return err |
| 148 | } |
| 149 | |
| 150 | device.State = Faulty |
| 151 | |
| 152 | if err := putObject(devBucket, name, &device, true); err != nil { |
| 153 | return err |
| 154 | } |
| 155 | |
| 156 | return markDeviceID(tx, device.DeviceID, deviceFaulty) |
| 157 | }) |
| 158 | } |
| 159 | |
| 160 | // getNextDeviceID finds the next free device ID by taking a cursor |
| 161 | // through the deviceIDBucketName bucket and finding the next sequentially |