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 #13667: Add condition_once and execute_once generic methods #849

Conversation

amousset
Copy link
Member

@amousset
Copy link
Member Author

Do not merge for now, wip

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from e43e02c to 4e2d6c6 Compare October 17, 2018 10:37
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 4e2d6c6 to 69ae5a6 Compare October 17, 2018 10:43
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 69ae5a6 to 76b3e54 Compare October 17, 2018 10:54
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 76b3e54 to 314647f Compare October 17, 2018 15:00
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 314647f to 234dc15 Compare October 17, 2018 15:42
@amousset
Copy link
Member Author

Commit modified


commands:
reserved::
"${command}"
Copy link
Member

Choose a reason for hiding this comment

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

why not using command_execution ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense indeed (with command_execution_result)

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 234dc15 to e2b6475 Compare October 18, 2018 10:27
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from e2b6475 to 979a997 Compare October 18, 2018 11:13
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 979a997 to fc816c3 Compare October 18, 2018 11:19
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from fc816c3 to 02b19f7 Compare October 18, 2018 11:35
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 02b19f7 to a3c92df Compare October 18, 2018 12:06
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from a3c92df to 63d5765 Compare October 18, 2018 12:32
@amousset
Copy link
Member Author

Commit modified

"phDDD" usebundle => command_execution_once("exit 4", "${ok_codes}", "ok", "testD");

"enable" usebundle => set_dry_run_mode("true");
"phE" usebundle => command_execution_once("exit 5", "${ok_codes}", "ok", "testE");
Copy link
Member

Choose a reason for hiding this comment

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

auditing execute_once is an error ? this is surprising, but i don't know what it should be

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the current behavior with other command methods, I think it's the best we can do.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm adding a test for already executed command in audit mode

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 63d5765 to 2b94157 Compare October 18, 2018 12:53
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 2b94157 to 899a3c5 Compare October 18, 2018 14:35
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 899a3c5 to 1838973 Compare October 18, 2018 15:03
@amousset
Copy link
Member Author

Commit modified

"failure" usebundle => _classes_failure("${old_class_prefix}");
"failure" usebundle => _classes_failure("${class_prefix}");

pass3.already_set::
Copy link
Member

Choose a reason for hiding this comment

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

already_set is set if the flag was already reserved - so if something else reserved it previously, but didn't set it, it will be reported as success. Is it expected ?

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 1838973 to 6e9d741 Compare October 18, 2018 16:07
@amousset
Copy link
Member Author

Commit modified

@@ -54,7 +54,7 @@ bundle agent permissions_recurse(path, mode, owner, group)
"reenable_reporting_${class_prefix}"
usebundle => enable_reporting,
ifvarclass => "should_report";
"new result classes" usebundle => _classes_copy("${inner_class}", "${class_prefix}");
"new result classes" usebundle => _classes_copy("${inner_class_prefix}", "${class_prefix}");
Copy link
Member

Choose a reason for hiding this comment

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

this should not be part of this PR

Copy link
Member Author

Choose a reason for hiding this comment

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

definitely, I'll open a ticket (I just saw this while copy/pasting the inner class code)

@@ -49,6 +49,8 @@
# * `ok`: if the flag was correctly reserved
# * `failed`: if the flag could not be reserved. I can happen if it was reserved by another agent.
#
# * `cancel_flag` to remove a flag reservation. This does not affect already set classes.
Copy link
Member

Choose a reason for hiding this comment

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

the code DO cancel the persistent classes.

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, good spot, s/classes/flags

@@ -169,16 +198,17 @@ bundle agent set_flag(name) {
"notreserved"
bundle_return_value_index => "1",
comment => "${flag_unique.value}",
if => "!flag_reserved_${cname}";
if => "!reserved";
Copy link
Member

Choose a reason for hiding this comment

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

notreserved is never used - is it for future usage ?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is actually used for more precise testing (and maybe for future usage too).

Copy link
Member

Choose a reason for hiding this comment

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

Great ! Thank you

# @parameter until Try to execute the command until a particular state: 'ok', 'any' (defaults to 'any')
# @parameter_constraint until "allow_empty_string" : true
# @parameter_constraint until "select" : [ "", "any", "ok" ]
# @parameter unique_id To identify the command (allows to change the command without losing track)
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 it be optionnal, and default to command ?

Copy link
Member Author

Choose a reason for hiding this comment

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

would be better indeed!

Copy link
Member

@ncharles ncharles left a comment

Choose a reason for hiding this comment

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

This is awesome ! just two question, about uniqueid, and the notreserved usage, and one requested change (permissions is changed)

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 6e9d741 to 72f75f0 Compare October 18, 2018 20:13
@amousset
Copy link
Member Author

Commit modified

@amousset amousset force-pushed the ust_13667/add_condition_once_and_execute_once_generic_methods branch from 72f75f0 to 06da08a Compare October 18, 2018 20:18
@amousset
Copy link
Member Author

Commit modified

@Normation-Quality-Assistant
Copy link
Contributor

OK, merging this PR

@Normation-Quality-Assistant Normation-Quality-Assistant merged commit 06da08a into Normation:branches/rudder/4.3 Oct 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants