Skip to content

Commit d4c0a8e

Browse files
authored
Removed unused concurrent core code
1 parent 0564b68 commit d4c0a8e

File tree

2 files changed

+2
-169
lines changed

2 files changed

+2
-169
lines changed

core/concurrent_core.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ type ConcurrentTridentOrchestrator struct {
4949
scPoolMap *storageclass.PoolMap
5050
scPoolMapMutex *sync.RWMutex
5151

52-
txnMutex *locks.GCNamedMutex
53-
txnMonitorTicker *time.Ticker
54-
txnMonitorChannel chan struct{}
55-
txnMonitorStopped bool
52+
txnMutex *locks.GCNamedMutex
5653

5754
lastNodeRegistrationMutex *sync.RWMutex
5855
lastNodeRegistrationTime time.Time
@@ -163,7 +160,7 @@ func (o *ConcurrentTridentOrchestrator) transformPersistentState(ctx context.Con
163160
return nil
164161
}
165162

166-
func (o *ConcurrentTridentOrchestrator) Bootstrap(monitorTransactions bool) error {
163+
func (o *ConcurrentTridentOrchestrator) Bootstrap(_ bool) error {
167164
ctx := GenerateRequestContext(nil, "", ContextSourceInternal, WorkflowCoreBootstrap, LogLayerCore)
168165
var err error
169166

@@ -189,12 +186,6 @@ func (o *ConcurrentTridentOrchestrator) Bootstrap(monitorTransactions bool) erro
189186
return o.bootstrapError
190187
}
191188

192-
// TODO (cknight): reenable
193-
// if monitorTransactions {
194-
// // Start transaction monitor
195-
// o.StartTransactionMonitor(ctx, txnMonitorPeriod, txnMonitorMaxAge)
196-
// }
197-
198189
o.bootstrapped = true
199190
o.bootstrapError = nil
200191
Logc(ctx).Infof("%s bootstrapped successfully.", convert.ToTitle(config.OrchestratorName))
@@ -684,10 +675,6 @@ func (o *ConcurrentTridentOrchestrator) Stop() {
684675
if o.stopReconcileBackendLoop != nil {
685676
o.stopReconcileBackendLoop <- true
686677
}
687-
688-
// TODO (cknight): reenable
689-
// // Stop transaction monitor
690-
// o.StopTransactionMonitor()
691678
}
692679

693680
// validateAndCreateBackendFromConfig validates config and creates backend based on Config

core/transaction_monitor.go

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)