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

Fixes #15864: add an option to prevent backup of node policy at the end of policy generation #2561

Conversation

ncharles
Copy link
Member

@ncharles
Copy link
Member Author

Commit modified

@ncharles ncharles force-pushed the bug_15864/add_an_option_to_prevent_backup_of_node_policy_at_the_end_of_policy_generation branch from 79ffe1a to 0f12fd5 Compare October 28, 2019 22:33
Copy link
Member

@fanf fanf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two formating changes, and a question :)

* Move the generated promises from the new folder to their final folder, backuping previous promises in the way
* @param folder : (Container identifier, (base folder, new folder of the policies, backup folder of the policies) )
* Move the generated policies from the new folder to their final folder, backuping previous policies in the way
* if backupPoliciesAtEndOfGeneration is true, otherwise removing preivous policies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/preivous/previous

logger.trace("Backuping old promises from %s to %s ".format(baseFolder, backupFolder))
backupNodeFolder(baseFolder, backupFolder)
if (backupPoliciesAtEndOfGeneration) {
logger.trace("Backuping old policies from %s to %s ".format(baseFolder, backupFolder))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you change it to: s"Backuping old policies from ${baseFolder} to ${backupFolder}" for consistency ?

backupNodeFolder(baseFolder, backupFolder)
} else {
logger.trace(s"Deleting old policies in ${baseFolder}")
deleteNodeFolder(baseFolder)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we also delete backupFolder if it exits from a previous generation with a different backup strategy?
Else, people may become confuse when/if they find back the olds generated files at some point.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that's a good idea

@ncharles
Copy link
Member Author

here is something odd here: with the delete

[2019-10-28 23:09:16] DEBUG policy.generation - Previous set of policies are backuped at the end of policy generation: false (change with REST API settings parameter 'rudder_backup_previous_policies')
[2019-10-28 23:09:16] WARN policy.generation - Computing dynamic groups disable by REST API settings 'rudder_generation_compute_dyngroups'
[2019-10-28 23:09:16] DEBUG policy.generation - Computing dynamic groups finished in 18 ms
[2019-10-28 23:09:16] DEBUG policy.generation - Pre-policy-generation scripts hooks ran in 1 ms
[2019-10-28 23:09:16] DEBUG policy.generation - Pre-policy-generation modules hooks in 0 ms, start getting all generation related data.
[2019-10-28 23:09:16] TRACE policy.generation - Fetched rules in 25 ms
[2019-10-28 23:09:16] TRACE policy.generation - Fetched node infos in 94 ms
[2019-10-28 23:09:16] TRACE policy.generation - Fetched directives in 80 ms
[2019-10-28 23:09:17] TRACE policy.generation - Fetched groups in 529 ms
[2019-10-28 23:09:17] TRACE policy.generation - Fetched global parameters in 2 ms
[2019-10-28 23:09:17] TRACE policy.generation - Fetched run infos in 9 ms
[2019-10-28 23:09:17] DEBUG policy.generation - All relevant information fetched in 753 ms, start names historization.
[2019-10-28 23:09:21] DEBUG policy.generation - Historization of names done in 4268 ms, start to build rule values.
[2019-10-28 23:09:22] DEBUG policy.generation - RuleVals built in 791 ms, start to expand their values.
[2019-10-28 23:09:39] DEBUG policy.generation - Node contexts built in 17340 ms, start to build new node configurations.
[2019-10-28 23:11:59] DEBUG policy.generation - Node's target configuration built in 140131 ms, start to update rule values.
[2019-10-28 23:12:24] DEBUG policy.generation - Reports updated in 13048 ms
[2019-10-28 23:12:26] DEBUG policy.generation - Paths computed and templates read in 170 ms
[2019-10-28 23:12:36] DEBUG policy.generation - Promises prepared in 10488 ms
[2019-10-28 23:17:35] DEBUG policy.generation - Promises written in 298827 ms
[2019-10-28 23:17:37] DEBUG policy.generation - Properties written in 1988 ms
[2019-10-28 23:17:39] DEBUG policy.generation - Parameters written in 2577 ms
[2019-10-28 23:17:39] DEBUG policy.generation - Licenses copied in 1 ms
[2019-10-28 23:18:11] DEBUG policy.generation - Hooks for policy-generation-node-ready executed in 31446 ms
[2019-10-28 23:24:06] DEBUG policy.generation - Policies moved to their final position in 354937 ms
[2019-10-28 23:24:07] DEBUG policy.generation - Hooks for policy-generation-node-ready executed in 1253 ms
[2019-10-28 23:24:07] DEBUG policy.generation - Node configuration written on filesystem in 703195 ms
[2019-10-28 23:24:15] DEBUG policy.generation - Node configuration cached in LDAP in 8360 ms
[2019-10-28 23:24:15] DEBUG policy.generation - Node configuration written in 711569 ms, start to update expected reports.
[2019-10-28 23:24:39] DEBUG policy.generation - Node expected reports saved in base in 23993 ms.
[2019-10-28 23:24:40] DEBUG policy.generation - Post-policy-generation hooks ran in 218 ms
[2019-10-28 23:24:40] INFO policy.generation - Timing summary:
[2019-10-28 23:24:40] INFO policy.generation - Run pre-gen scripts hooks : 1 ms
[2019-10-28 23:24:40] INFO policy.generation - Run pre-gen modules hooks : 0 ms
[2019-10-28 23:24:40] INFO policy.generation - Fetch all information : 753 ms
[2019-10-28 23:24:40] INFO policy.generation - Historize names : 4268 ms
[2019-10-28 23:24:40] INFO policy.generation - Build current rule values : 791 ms
[2019-10-28 23:24:40] INFO policy.generation - Build target configuration : 140131 ms
[2019-10-28 23:24:40] INFO policy.generation - Write node configurations : 711569 ms
[2019-10-28 23:24:40] INFO policy.generation - Save expected reports : 13048 ms
[2019-10-28 23:24:40] INFO policy.generation - Run post generation hooks : 218 ms
[2019-10-28 23:24:40] INFO policy.generation - Number of nodes updated : 4549
[2019-10-28 23:24:40] INFO policy.generation - Policy generation completed in: 15 min 23 s
[2019-10-28 23:24:40] INFO policy.generation - Flag file '/opt/rudder/etc/policy-update-running' successfully removed

with the move

[2019-10-28 23:26:43] DEBUG policy.generation - Previous set of policies are backuped at the end of policy generation: true (change with REST API settings parameter 'rudder_backup_previous_policies')
[2019-10-28 23:26:43] WARN policy.generation - Computing dynamic groups disable by REST API settings 'rudder_generation_compute_dyngroups'
[2019-10-28 23:26:43] DEBUG policy.generation - Computing dynamic groups finished in 19 ms
[2019-10-28 23:26:43] DEBUG policy.generation - Pre-policy-generation scripts hooks ran in 2 ms
[2019-10-28 23:26:43] DEBUG policy.generation - Pre-policy-generation modules hooks in 0 ms, start getting all generation related data.
[2019-10-28 23:26:43] TRACE policy.generation - Fetched rules in 24 ms
[2019-10-28 23:26:44] TRACE policy.generation - Fetched node infos in 104 ms
[2019-10-28 23:26:44] TRACE policy.generation - Fetched directives in 149 ms
[2019-10-28 23:26:46] TRACE policy.generation - Fetched groups in 1854 ms
[2019-10-28 23:26:46] TRACE policy.generation - Fetched global parameters in 1 ms
[2019-10-28 23:26:46] TRACE policy.generation - Fetched run infos in 11 ms
[2019-10-28 23:26:46] DEBUG policy.generation - All relevant information fetched in 2161 ms, start names historization.
[2019-10-28 23:26:50] DEBUG policy.generation - Historization of names done in 4480 ms, start to build rule values.
[2019-10-28 23:26:51] DEBUG policy.generation - RuleVals built in 992 ms, start to expand their values.
[2019-10-28 23:27:09] DEBUG policy.generation - Node contexts built in 18115 ms, start to build new node configurations.
[2019-10-28 23:29:29] DEBUG policy.generation - Node's target configuration built in 139395 ms, start to update rule values.
[2019-10-28 23:29:53] DEBUG policy.generation - Reports updated in 12857 ms
[2019-10-28 23:29:55] DEBUG policy.generation - Paths computed and templates read in 172 ms
[2019-10-28 23:30:06] DEBUG policy.generation - Promises prepared in 10560 ms
[2019-10-28 23:35:08] DEBUG policy.generation - Promises written in 301854 ms
[2019-10-28 23:35:10] DEBUG policy.generation - Properties written in 2348 ms
[2019-10-28 23:35:11] DEBUG policy.generation - Parameters written in 1209 ms
[2019-10-28 23:35:11] DEBUG policy.generation - Licenses copied in 1 ms
[2019-10-28 23:35:52] DEBUG policy.generation - Hooks for policy-generation-node-ready executed in 40567 ms
[2019-10-28 23:37:20] DEBUG policy.generation - Policies moved to their final position in 88092 ms
[2019-10-28 23:37:21] DEBUG policy.generation - Hooks for policy-generation-node-ready executed in 1034 ms
[2019-10-28 23:37:21] DEBUG policy.generation - Node configuration written on filesystem in 447433 ms
[2019-10-28 23:37:29] DEBUG policy.generation - Node configuration cached in LDAP in 7596 ms
[2019-10-28 23:37:29] DEBUG policy.generation - Node configuration written in 455041 ms, start to update expected reports.
[2019-10-28 23:37:51] DEBUG policy.generation - Node expected reports saved in base in 22912 ms.
[2019-10-28 23:37:52] DEBUG policy.generation - Post-policy-generation hooks ran in 187 ms
[2019-10-28 23:37:52] INFO policy.generation - Timing summary:
[2019-10-28 23:37:52] INFO policy.generation - Run pre-gen scripts hooks : 2 ms
[2019-10-28 23:37:52] INFO policy.generation - Run pre-gen modules hooks : 0 ms
[2019-10-28 23:37:52] INFO policy.generation - Fetch all information : 2161 ms
[2019-10-28 23:37:52] INFO policy.generation - Historize names : 4480 ms
[2019-10-28 23:37:52] INFO policy.generation - Build current rule values : 992 ms
[2019-10-28 23:37:52] INFO policy.generation - Build target configuration : 139395 ms
[2019-10-28 23:37:52] INFO policy.generation - Write node configurations : 455041 ms
[2019-10-28 23:37:52] INFO policy.generation - Save expected reports : 12857 ms
[2019-10-28 23:37:52] INFO policy.generation - Run post generation hooks : 187 ms
[2019-10-28 23:37:52] INFO policy.generation - Number of nodes updated : 4549
[2019-10-28 23:37:52] INFO policy.generation - Policy generation completed in: 11 min 8 s

@ncharles
Copy link
Member Author

ncharles commented Oct 28, 2019

delete: [2019-10-28 23:24:06] DEBUG policy.generation - Policies moved to their final position in 354937 ms
vs
move: [2019-10-28 23:37:20] DEBUG policy.generation - Policies moved to their final position in 88092 ms

/**
* Delete the previous node policies folder
*/
private[this] def deleteNodeFolder(nodeFolder: String): Unit = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually, we could skip it as moveNewNodeFolder does the deletion of dest if it exists

@fanf
Copy link
Member

fanf commented Nov 15, 2019

So, what do we do with that one? Close it as "not a good idea finaly?"

@fanf
Copy link
Member

fanf commented Nov 15, 2019

We will close that PR for now, until we have better understanding of the underlying perf.

@fanf fanf closed this Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants