func (s *StateStore) DeleteEval(index uint64, evals []string, allocs []string) error {
	txn := s.db.Txn(true)
	defer txn.Abort()

	jobs := make(map[string]string, len(evals))
	for _, eval := range evals {
		existing, err := txn.First("evals", "id", eval)
		if err != nil {
			return fmt.Errorf("eval lookup failed: %v", err)
		}
		if existing == nil {
			continue
		}
		if err := txn.Delete("evals", existing); err != nil {
			return fmt.Errorf("eval delete failed: %v", err)
		}
		jobID := existing.(*structs.Evaluation).JobID
		jobs[jobID] = ""
	}

	for _, alloc := range allocs {
		existing, err := txn.First("allocs", "id", alloc)
		if err != nil {
			return fmt.Errorf("alloc lookup failed: %v", err)
		}
		if existing == nil {
			continue
		}
		if err := txn.Delete("allocs", existing); err != nil {
			return fmt.Errorf("alloc delete failed: %v", err)
		}
	}

	// Update the indexes
	if err := txn.Insert("index", &IndexEntry{"evals", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}
	if err := txn.Insert("index", &IndexEntry{"allocs", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}

	// Set the job's status
	if err := s.setJobStatuses(index, txn, jobs, true); err != nil {
		return fmt.Errorf("setting job status failed: %v", err)
	}

	txn.Commit()
	return nil
}
// DeleteEval is used to delete an evaluation
DeleteEval is used to delete an evaluation
// DeleteEval is used to delete an evaluation
func (s *StateStore) DeleteEval(index uint64, evals []string, allocs []string) error {
	txn := s.db.Txn(true)
	defer txn.Abort()
	jobs := make(map[string]string, len(evals))
	for _, eval := range evals {
		existing, err := txn.First("evals", "id", eval)
		if err != nil {
			return fmt.Errorf("eval lookup failed: %v", err)
		}
		if existing == nil {
			continue
		}
		if err := txn.Delete("evals", existing); err != nil {
			return fmt.Errorf("eval delete failed: %v", err)
		}
		jobID := existing.(*structs.Evaluation).JobID
		jobs[jobID] = ""
	}
	for _, alloc := range allocs {
		existing, err := txn.First("allocs", "id", alloc)
		if err != nil {
			return fmt.Errorf("alloc lookup failed: %v", err)
		}
		if existing == nil {
			continue
		}
		if err := txn.Delete("allocs", existing); err != nil {
			return fmt.Errorf("alloc delete failed: %v", err)
		}
	}
	if err := txn.Insert("index", &IndexEntry{"evals", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}
	if err := txn.Insert("index", &IndexEntry{"allocs", index}); err != nil {
		return fmt.Errorf("index update failed: %v", err)
	}
	if err := s.setJobStatuses(index, txn, jobs, true); err != nil {
		return fmt.Errorf("setting job status failed: %v", err)
	}
	txn.Commit()
	return nil
}
func ( s * StateStore ) DeleteEval ( index uint64 , evals [ ] string , allocs [ ] string ) error { txn := s . db . Txn ( true ) defer txn . Abort ( ) jobs := make ( map [ string ] string , len ( evals ) ) for _ , eval := range evals { existing , err := txn . First ( " " , " " , eval ) if err != nil { return fmt . Errorf ( " " , err ) } if existing == nil { continue } if err := txn . Delete ( " " , existing ) ; err != nil { return fmt . Errorf ( " " , err ) } jobID := existing . ( * structs . Evaluation ) . JobID jobs [ jobID ] = " " } for _ , alloc := range allocs { existing , err := txn . First ( " " , " " , alloc ) if err != nil { return fmt . Errorf ( " " , err ) } if existing == nil { continue } if err := txn . Delete ( " " , existing ) ; err != nil { return fmt . Errorf ( " " , err ) } } if err := txn . Insert ( " " , & IndexEntry { " " , index } ) ; err != nil { return fmt . Errorf ( " " , err ) } if err := txn . Insert ( " " , & IndexEntry { " " , index } ) ; err != nil { return fmt . Errorf ( " " , err ) } if err := s . setJobStatuses ( index , txn , jobs , true ) ; err != nil { return fmt . Errorf ( " " , err ) } txn . Commit ( ) return nil }
DeleteEval is used to delete an evaluation
DeleteEval is used to delete an evaluation
// Update the indexes // Set the job's status