Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #384 from brickbox-io/fix_bg_task #385

Merged
merged 3 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions bb_billing/views/views_invoice.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@ def invoice_event(request):
if customer.threshold < 1000.00:
owned_bricks = VirtualBrickOwner.objects.filter(owner=customer)
for brick in owned_bricks:
pause_vm_subprocess.apply_async(
(brick.virt_brick.id,),
queue='ssh_queue'
)
brick.virt_brick.is_on=False
brick.virt_brick.save()
if brick.virt_brick.is_on:
pause_vm_subprocess.apply_async(
(brick.virt_brick.id,),
queue='ssh_queue'
)
brick.virt_brick.is_on=False
brick.virt_brick.save()

# -------------------------------- Destroy VMs ------------------------------- #
bill = BillingHistory.objects.get(invoice_id=invoice.id)
Expand Down
2 changes: 1 addition & 1 deletion bb_tasks/tasks/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def prepare_gpu_background_task():
'''
gpu_list = GPU.objects.all()
for gpu in gpu_list:
if not gpu.bg_ready and not gpu.rented and gpu.host.is_ready:
if not gpu.bg_ready and not gpu.rented and gpu.host.is_ready and gpu.host.is_enabled:
host = gpu.host

background_brick = box.Brick(host_port=host.ssh_port, brick_id=f'gpu_{str(gpu.id)}')
Expand Down