-
Notifications
You must be signed in to change notification settings - Fork 6
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
Development 3botdeployer autoextend pool #1526
Development 3botdeployer autoextend pool #1526
Conversation
Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com>
Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com>
…ion instead of threebot_deployer and adding mail service
be5e7e6
to
b88d3cb
Compare
|
||
def job(self): | ||
auto_extend_pools() | ||
print("Auto extend pool service done successfully") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we convert that pring to j.logger ?
) | ||
return True | ||
except: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we log the error ?
|
||
def check_pool_expiration(pool, threshold_days=14): | ||
remaining_days = (pool.empty_at - time.time()) / 86400 # converting seconds to days | ||
if remaining_days < threshold_days and remaining_days > 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can just return boolean expression return remaining_days < threshold_days and remaining_days > 0
auto_extend_pool(pool.pool_id, int(cu), int(su)) | ||
|
||
|
||
def auto_extend_pool(pool_id: int, cu: int, su: int, currencies=["TFT"]): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defining a list in the parameters is not the best thing in the world, we can start with None and assign that value inside the method
recipients_emails.append(user_mail) | ||
escalation_emails = j.core.config.get("ESCALATION_EMAILS") | ||
recipients_emails.extend(escalation_emails) | ||
message = f""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can use dedent to align the code with the normal indentation
send_mail(recipients_emails, message, sender=sender) | ||
|
||
|
||
def send_mail(recipients_emails=[], message="", sender=""): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make the recipients_emails with None, to avoid passing by reference, and assign it later inside the method ?
destination_address=escrow_address, amount=total_amount, asset=escrow_asset, memo_text=f"p-{resv_id}" | ||
) | ||
return True | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add an error log here?
pool_info = j.sals.zos.get().pools.extend(pool_id, cu, su, currencies=currencies) | ||
except Exception as e: | ||
send_pool_info_mail(pool_id) | ||
raise j.exceptions.Runtime(f"Error happend during extending the pool, {str(e)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if one pool raises an exception, wouldn't it stop the remaining pools from being extended?
recipients_emails = [] | ||
user_mail = j.core.identity.me.email | ||
recipients_emails.append(user_mail) | ||
escalation_emails = j.core.config.get("ESCALATION_EMAILS") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check escalation_emails
return, if not set it will return None
jumpscale/packages/admin/frontend/components/settings/Settings.vue
Outdated
Show resolved
Hide resolved
jumpscale/packages/admin/frontend/components/settings/EmailServerConfig.vue
Show resolved
Hide resolved
jumpscale/packages/admin/frontend/components/settings/Settings.vue
Outdated
Show resolved
Hide resolved
Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com>
destination_address=escrow_address, amount=total_amount, asset=escrow_asset, memo_text=f"p-{resv_id}" | ||
) | ||
return True | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except: | |
except Exception as e: | |
j.logger.warning(f"failed to pay pool {pool_info.pool_id} with wallet {wallet_name} due to error {str(e)}") |
send_pool_info_mail(pool_id) | ||
j.logger.error(f"Error happend during extending the pool, {str(e)}") | ||
if not pay_pool(pool_info): | ||
send_pool_info_mail(pool_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have some kind of validation on emails or what happens in case sending emails failed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com>
@@ -127,6 +127,7 @@ def get_developer_options(self) -> str: | |||
over_provision = j.core.config.set_default("OVER_PROVISIONING", False) | |||
explorer_logs = j.core.config.set_default("EXPLORER_LOGS", False) | |||
escalation_emails = j.core.config.set_default("ESCALATION_EMAILS_ENABLED", False) | |||
auto_pool_extend = j.core.config.set_default("auto_extend_pool", False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the variable name used should be auto_extend_pools
and the config param should AUTO_EXTEND_POOLS_ENABLED
* Add location choice * Block the chatflow until the farms are ready * Add location policy * Fetch farm name early * Fix pool selection when forcing specific node * Use drop down menu instead of single choice * Create wallet on entry * working on adding 3bot status * Create a new wallet on 3bot creation * Rename the wallet to mainnet_wallet * Move wallet creation to threebot start * Log wallet creation errors and continue starting * Don't discriminate between self hosted and chatflow hosted 3Bots * update backup path related to restic server * Deploy on the new identity * add flavors for deployer * override the flavors * Create 3bot on new pool and new managed network * add destroy, delete and restart actions * add /root/.ssh to restic backup paths * add the deployer actions depending on the status * update methods with identity_name wip * separate 3bot deployers in separate component * refactor models dir * fix saved subdomain id * fix instance name * working on the frontend for listin the 3bots * use mainnet default * fixing and issue related to back /.ssh path * threebot listing wip * check for workload container type in building info * remove debugging prints * expired pools have empty_at at max int64 * add stop and delete threebot solutions * check if metadata exists before trying to decrypt it * fix typos * set owner key in networks metadata updated by the admin dashboard * move threebot config validation to a separate method * remove unused statement * address comments * deploy on mainnet * Development 3botdeployer escalation emails (#1478) * Add escalation emails button in developer options in fron-end and update the back-end * Add escalation email front-end and back-end * Handle the None stat in config manager related to escalating emails * fix invalid import * use management as name for networks 3bot deployment * pass identity to dry_run context * use new listing util in threebot chatflow * fix network name * return expiration * Update front-end and back end to use the new methods in listing the threebot states * add start method in utils * Restart 3Bot wip * Adds correct actions for stop / destroy threebot for threebot deployer Signed-off-by: Ashraf Fouda <ashraf.m.fouda@gmail.com> * Fix steps missing comma * Add final step * Add some hardening for threebot deletion and stopping * clean up threebot identity * updated frontend view * delete only deployed workloads * add change size and location chatflows * receive 3bot name from params * clean up unused identity * fix log config * fix log config * fix message * remove extend * clear workloads in deployment_context before deleting threebot identity * show the correct empty at in blocked nodes * one table for all workloads * Add state filter in deployed 3bots UI * show bell icon and extend message and remove expiration column * update quick start guide * update quick start guide * change expiration icon * show href in info if the threebot is running * remove not needed inof when threebot is not running * fix error message * Create wallets when deploying new threebot * remove unused actor methods * override the flist with latest flist on redeployments * override the flist with latest flist on redeployments * fix api url and remove deprecated apis * return status 400 instead of raising exception * fix cancel solution for other identities * update branch in redeployments * open url in another tab * pass identity name to metadata encryption & decryption in delete_access * use root instead of homedir * change variable name * change ssh dir path based on the current user running 3bot server * fix message * revert ssh dir * respect over provisioning in farm capacity check * remove extend test * use identity name when decrypting metadata * Development 3botdeployer autoextend pool (#1526) auto-extend pools * Use std instead of default identity for the main wallet * update threebot tests * remove conflicts * remove recover and extend tests * Update email server config in admin dashboard vue to include tooltips * add threebot start & change size gedis patches * add threebot change location patch * add threebot change location patch * init test cases for threebot deployer * Make development as the default branch for threebot deployer Co-authored-by: Omar Elawady <omarelawady1998@gmail.com> Co-authored-by: Rafy Benjamin <rafy.amgadbenjamin@gmail.com> Co-authored-by: m-motawea <magedmotawea@gmail.com> Co-authored-by: RafyAmgadBenjamin <46320202+RafyAmgadBenjamin@users.noreply.github.com> Co-authored-by: Ashraf Fouda <ashraf.m.fouda@gmail.com> Co-authored-by: ranatrk <rana.t.hassan@gmail.com> Co-authored-by: Waleed <waleed.hammam@gmail.com>
Description
Related Issues
#1337