-
Notifications
You must be signed in to change notification settings - Fork 190
[for minor release] Aggregate DataStore Accounting Requests #8714
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
Open
chaen
wants to merge
3
commits into
DIRACGrid:integration
Choose a base branch
from
chaen:aggregate_accounting
base: integration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,8 +1,3 @@ | ||||||
| ######################################################################## | ||||||
| # File: CleanReqDBAgent.py | ||||||
| # Author: Krzysztof.Ciba@NOSPAMgmail.com | ||||||
| # Date: 2013/05/17 08:31:26 | ||||||
| ######################################################################## | ||||||
| """Cleaning the RequestDB from obsolete records and kicking assigned requests | ||||||
|
|
||||||
| .. literalinclude:: ../ConfigTemplate.cfg | ||||||
|
|
@@ -11,15 +6,8 @@ | |||||
| :dedent: 2 | ||||||
| :caption: CleanReqDBAgent options | ||||||
|
|
||||||
| .. moduleauthor:: Krzysztof.Ciba@NOSPAMgmail.com | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
| # # | ||||||
| # @file CleanReqDBAgent.py | ||||||
| # @author Krzysztof.Ciba@NOSPAMgmail.com | ||||||
| # @date 2013/05/17 08:32:08 | ||||||
| # @brief Definition of CleanReqDBAgent class. | ||||||
|
|
||||||
| # # imports | ||||||
| import datetime | ||||||
|
|
@@ -56,6 +44,12 @@ class CleanReqDBAgent(AgentModule): | |||||
| # # remove failed requests flag | ||||||
| DEL_FAILED = False | ||||||
|
|
||||||
| # # Number of Accounting requests to fetch to batch | ||||||
| # # 0 to disable | ||||||
| ACCOUNTING_BATCH_MAX_REQUESTS = 0 | ||||||
| # # Number of operations to batch in a single requests. | ||||||
| ACCOUNTING_BATCH_SIZE = 100 | ||||||
|
|
||||||
| # # request db | ||||||
| __requestDB = None | ||||||
|
|
||||||
|
|
@@ -74,6 +68,14 @@ def initialize(self): | |||||
| self.KICK_LIMIT = self.am_getOption("KickLimit", self.KICK_LIMIT) | ||||||
| self.log.info(f"Kick limit = {self.KICK_LIMIT} request/cycle") | ||||||
|
|
||||||
| self.ACCOUNTING_BATCH_MAX_REQUESTS = self.am_getOption( | ||||||
| "AccountingBatchMaxRequests", self.ACCOUNTING_BATCH_MAX_REQUESTS | ||||||
| ) | ||||||
| self.log.info(f"Accounting max requests = {self.ACCOUNTING_BATCH_MAX_REQUESTS} request/cycle") | ||||||
|
|
||||||
| self.ACCOUNTING_BATCH_SIZE = self.am_getOption("AccountingBatchSize", self.ACCOUNTING_BATCH_SIZE) | ||||||
| self.log.info(f"Accouting batch size = {self.ACCOUNTING_BATCH_SIZE} requests") | ||||||
|
|
||||||
| if self.cancelGraceDays >= self.DEL_GRACE_DAYS: | ||||||
| self.cancelGraceDays = self.DEL_GRACE_DAYS - 1 | ||||||
| self.log.warn("Cancelled jobs grace period > delete period, capping to %u days" % self.cancelGraceDays) | ||||||
|
|
@@ -88,6 +90,7 @@ def execute(self): | |||||
| now = DiracTime.utcnow() | ||||||
| kickTime = now - datetime.timedelta(hours=self.KICK_GRACE_HOURS) | ||||||
| rmTime = now - datetime.timedelta(days=self.DEL_GRACE_DAYS) | ||||||
| batched = None | ||||||
|
|
||||||
| # # kick | ||||||
| statusList = ["Assigned"] | ||||||
|
|
@@ -163,9 +166,23 @@ def execute(self): | |||||
| continue | ||||||
| cancelled += 1 | ||||||
|
|
||||||
| if self.ACCOUNTING_BATCH_MAX_REQUESTS: | ||||||
| res = self.__requestDB.aggregateAccountingDataStoreRequests( | ||||||
| batch_size=self.ACCOUNTING_BATCH_SIZE, max_requests=self.ACCOUNTING_BATCH_MAX_REQUESTS | ||||||
| ) | ||||||
| if not res["OK"]: | ||||||
| self.log.error("Failed to natch accounting requests requests:", res["Message"]) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| return res | ||||||
| batched = res["Value"] | ||||||
|
|
||||||
| self.log.info("execute: kicked assigned requests", str(kicked)) | ||||||
| self.log.info("execute: deleted finished requests", str(deleted)) | ||||||
| if self.cancelGraceDays > 0: | ||||||
| self.log.info("execute: cancelled overdue requests", str(cancelled)) | ||||||
|
|
||||||
| if batched: | ||||||
| self.log.info( | ||||||
| "Batched accounting requests", | ||||||
| f"created : {len(batched['created_requests'])}, canceled: {len(batched['canceled_requests'])}", | ||||||
| ) | ||||||
| return S_OK() | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,3 @@ | ||
| import importlib | ||
| from collections.abc import Sequence | ||
|
|
||
| # imports | ||
|
|
@@ -21,8 +20,6 @@ class ForwardDISET(OperationHandlerBase): | |
|
|
||
| There are fundamental differences in behavior between the forward diset | ||
| for DIPS service and the one for DiracX: | ||
| * dips call will be done with the server certificates and use the delegated DN field | ||
| * diracx call will be done with the credentials setup by request tasks | ||
| * dips call are just RPC call, they do not execute the logic of the client (that is anyway not relied upon for now) | ||
| * diracx calls will effectively call the client entirely. | ||
|
|
||
|
|
@@ -54,19 +51,7 @@ def __call__(self): | |
|
|
||
| # This is the DISET rpcStub | ||
| if isinstance(stub, Sequence): | ||
| # Ensure the forwarded request is done on behalf of the request owner | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove this code? |
||
| res = getDNForUsername(self.request.Owner) | ||
| if not res["OK"]: | ||
| return res | ||
| stub[0][1]["delegatedDN"] = res["Value"][0] | ||
| stub[0][1]["delegatedGroup"] = self.request.OwnerGroup | ||
|
|
||
| # ForwardDiset is supposed to be used with a host certificate | ||
| useServerCertificate = gConfig.useServerCertificate() | ||
| gConfigurationData.setOptionInCFG("/DIRAC/Security/UseServerCertificate", "true") | ||
| forward = disetExecuteRPCStub(stub) | ||
| if not useServerCertificate: | ||
| gConfigurationData.setOptionInCFG("/DIRAC/Security/UseServerCertificate", "false") | ||
| # DiracX stub | ||
| elif isinstance(stub, dict): | ||
| forward = diracxExecuteRPCStub(stub) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You should put this info block inside the block starting with
if self.ACCOUNTING_BATCH_MAX_REQUESTS:which is below