@@ -160,157 +160,3 @@ func (o *TridentOrchestrator) reapLongRunningTransaction(ctx context.Context, tx
160160 }).Error ("Could not delete expired transaction. Transaction record may have to be removed manually." )
161161 }
162162}
163-
164- ////////////
165- // COREV2 //
166- ////////////
167-
168- // StartTransactionMonitor starts the thread that reaps abandoned long-running transactions.
169- //func (o *ConcurrentTridentOrchestrator) StartTransactionMonitor(
170- // ctx context.Context, txnPeriod, txnMaxAge time.Duration,
171- //) {
172- // ctx = GenerateRequestContextForLayer(ctx, LogLayerCore)
173- //
174- // o.txnMonitorTicker = time.NewTicker(txnPeriod)
175- // o.txnMonitorChannel = make(chan struct{})
176- // Logc(ctx).Debug("Transaction monitor started.")
177- //
178- // // Perform the check once and run it in a goroutine for every tick
179- // o.checkLongRunningTransactions(ctx, txnMaxAge)
180- // go func() {
181- // for {
182- // select {
183- // case tick := <-o.txnMonitorTicker.C:
184- // Logc(ctx).WithField("tick", tick).Debug("Transaction monitor running.")
185- // o.checkLongRunningTransactions(ctx, txnMaxAge)
186- // case <-o.txnMonitorChannel:
187- // Logc(ctx).Debugf("Transaction monitor stopped.")
188- // return
189- // }
190- // }
191- // }()
192- //}
193- //
194- //// StopTransactionMonitor stops the thread that reaps abandoned long-running transactions.
195- //func (o *ConcurrentTridentOrchestrator) StopTransactionMonitor() {
196- // if o.txnMonitorTicker != nil {
197- // o.txnMonitorTicker.Stop()
198- // }
199- // if o.txnMonitorChannel != nil && !o.txnMonitorStopped {
200- // close(o.txnMonitorChannel)
201- // o.txnMonitorStopped = true
202- // }
203- // Logc(context.Background()).Debug("Transaction monitor stopped.")
204- //}
205- //
206- //// checkLongRunningTransactions is called periodically by the transaction monitor to
207- //// see if any long-running transactions exist that have expired and must be reaped.
208- //func (o *ConcurrentTridentOrchestrator) checkLongRunningTransactions(ctx context.Context, txnMaxAge time.Duration) {
209- // if o.bootstrapError != nil {
210- // Logc(ctx).WithField("error", o.bootstrapError).Errorf("Transaction monitor blocked by bootstrap error.")
211- // return
212- // }
213- //
214- // txns, err := o.storeClient.GetVolumeTransactions(ctx)
215- // if err != nil {
216- // if !persistentstore.MatchKeyNotFoundErr(err) {
217- // Logc(ctx).WithField("error", err).Errorf("Could not read transactions.")
218- // }
219- // return
220- // }
221- // Log().Debugf("Transaction monitor found %d long-running transaction(s).", len(txns))
222- //
223- // // Build map of long-running transactions
224- // txnMap := make(map[*storage.VolumeTransaction]time.Time)
225- //
226- // for _, txn := range txns {
227- // switch txn.Op {
228- // case storage.VolumeCreating:
229- // txnMap[txn] = txn.VolumeCreatingConfig.StartTime
230- // default:
231- // continue
232- // }
233- // }
234- //
235- // // Reap each long-running transaction that has expired
236- // for txn, startTime := range txnMap {
237- // expirationTime := startTime.Add(txnMaxAge)
238- // Logc(ctx).WithFields(LogFields{
239- // "started": startTime,
240- // "expires": expirationTime,
241- // "op": txn.Op,
242- // "name": txn.Name(),
243- // }).Debug("Transaction monitor checking transaction.")
244- //
245- // if expirationTime.Before(time.Now()) {
246- // o.reapLongRunningTransaction(ctx, txn)
247- // }
248- // }
249- //}
250- //
251- //// reapLongRunningTransaction cleans up any transactions that have expired so that any
252- //// storage resources associated with them are not orphaned indefinitely.
253- //func (o *ConcurrentTridentOrchestrator) reapLongRunningTransaction(ctx context.Context, txn *storage.VolumeTransaction) {
254- // // o.mutex.Lock()
255- // // defer o.mutex.Unlock()
256- //
257- // Logc(ctx).WithFields(LogFields{
258- // "op": txn.Op,
259- // "name": txn.Name(),
260- // }).Debug("Transaction monitor reaping transaction.")
261- //
262- // // Clean up any resources associated with the transaction.
263- // switch txn.Op {
264- // case storage.VolumeCreating:
265- // // If the volume was somehow fully created and the transaction was left around, don't delete the volume!
266- // if o.cache.CheckVolume(txn.VolumeCreatingConfig.Name) {
267- // Logc(ctx).WithFields(LogFields{
268- // "volume": txn.VolumeCreatingConfig.Name,
269- // }).Warning("Volume for expired transaction is known to Trident and will not be reaped.")
270- // break
271- // }
272- //
273- // // Get the backend where this abandoned volume may still exist
274- // if !o.cache.CheckBackendByUUID(txn.VolumeCreatingConfig.BackendUUID) {
275- // Logc(ctx).WithFields(LogFields{
276- // "backendUUID": txn.VolumeCreatingConfig.BackendUUID,
277- // "volume": txn.VolumeCreatingConfig.Name,
278- // }).Error("Backend for expired transaction not found. Volume may have to be removed manually.")
279- // break
280- // }
281- //
282- // // TODO: If the caller already invokes backend locks, don't do this.
283- // backend, cacheUpdateBackendFunc, cacheUpdateBackendUnlocker, err := o.cache.PrepareUpdateBackend(txn.VolumeCreatingConfig.BackendUUID)
284- // if err != nil {
285- // Logc(ctx).WithFields(LogFields{
286- // "backendUUID": txn.VolumeCreatingConfig.BackendUUID,
287- // "volume": txn.VolumeCreatingConfig.Name,
288- // "err": err,
289- // }).Error("Backend for expired transaction not found. Volume may have to be removed manually.")
290- // break
291- // }
292- //
293- // // Delete the volume. This should be safe since the transaction was left around and Trident doesn't
294- // // know anything about the volume.
295- // if err := backend.RemoveVolume(ctx, &txn.VolumeCreatingConfig.VolumeConfig); err != nil {
296- // Logc(ctx).WithFields(LogFields{
297- // "backendUUID": txn.VolumeCreatingConfig.BackendUUID,
298- // "volume": txn.VolumeCreatingConfig.Name,
299- // "error": err,
300- // }).Error("Volume for expired transaction not deleted. Volume may have to be removed manually.")
301- // break
302- // }
303- // cacheUpdateBackendFunc(backend)
304- // cacheUpdateBackendUnlocker()
305- // default:
306- // break
307- // }
308- //
309- // // Delete the transaction record in all cases.
310- // if err := o.DeleteVolumeTransaction(ctx, txn); err != nil {
311- // Logc(ctx).WithFields(LogFields{
312- // "op": txn.Op,
313- // "name": txn.Name(),
314- // }).Error("Could not delete expired transaction. Transaction record may have to be removed manually.")
315- // }
316- //}
0 commit comments