)]}'
{"watcher/decision_engine/audit/base.py":[{"author":{"_account_id":18971,"name":"Vincent Françoise","email":"Vincent.FRANCOISE@b-com.com","username":"v-francoise"},"change_message_id":"a594c0a93b7d54b039e4c1ac2a4830d56e293be4","unresolved":false,"context_lines":[{"line_number":113,"context_line":"            self.pre_execute(audit, request_context)"},{"line_number":114,"context_line":"            solution \u003d self.do_execute(audit, request_context)"},{"line_number":115,"context_line":"            self.post_execute(audit, solution, request_context)"},{"line_number":116,"context_line":"            if audit.strategy_id is None:"},{"line_number":117,"context_line":"                obj_strategy \u003d objects.Strategy.get_by_name("},{"line_number":118,"context_line":"                    request_context, solution.strategy_name)"},{"line_number":119,"context_line":"                audit.strategy_id \u003d obj_strategy.id"},{"line_number":120,"context_line":"                audit.strategy \u003d obj_strategy"},{"line_number":121,"context_line":"                audit.save()"},{"line_number":122,"context_line":"        except Exception as e:"},{"line_number":123,"context_line":"            LOG.exception(e)"},{"line_number":124,"context_line":"            self.update_audit_state(audit, objects.audit.State.FAILED)"}],"source_content_type":"text/x-python","patch_set":2,"id":"ba5201f7_4a4ade84","line":121,"range":{"start_line":116,"start_character":0,"end_line":121,"end_character":28},"updated":"2017-01-03 10:27:50.000000000","message":"As you can see in https://github.com/openstack/watcher/blob/master/watcher/objects/audit.py#L95 , the strategy_id attribute is nullable. The reason behind it is not fully obvious nor is it actually commented in the codebase which should probably be the case.\n\nWhen an audit gets created without referencing a strategy, it means that the operator wants to delegate the strategy selection to Watcher given a goal. This dynamic strategy selection is handled here https://github.com/openstack/watcher/blob/master/watcher/decision_engine/strategy/selection/default.py#L42-L73 and is called by the decision engine upon executing an audit. However, this strategy selection is done differently depending on the audit type:\n\n- For the CONTINUOUS audit: https://github.com/openstack/watcher/blob/master/watcher/decision_engine/audit/continuous.py#L68-L69\n- For the ONESHOT audit: https://github.com/openstack/watcher/blob/master/watcher/decision_engine/audit/oneshot.py#L23-L24\n\nIn the case of the CONTINUOUS audit, the main objective it to maintain this strategy selection dynamic which means that we want to be able to compute the best strategy over time regardless of the previous executions. The idea here to anticipate to adapt the response given the evolution of the cluster over time. So if we save in DB the strategy that was used against the audit, this would cause the strategy selector logic to be skipped by the time we execution a CONTINUOUS audit for 2nd time onwards.\n\nThis is why I am in favour of a Watcher CLI fix that would \"translate\" the absence of strategy_id as \"auto\" rather than this fix you propose.\nIf you get what I tried to explain, I would like you to instead add the necessary comments to make this concern more explicit :)","commit_id":"952802cb2ba16f32316e9bd738e1138f08a3dd07"},{"author":{"_account_id":21692,"name":"licanwei","email":"li.canwei2@zte.com.cn","username":"licanwei"},"change_message_id":"0c72912392639daf6680e485a4b7d4c33b958f82","unresolved":false,"context_lines":[{"line_number":113,"context_line":"            self.pre_execute(audit, request_context)"},{"line_number":114,"context_line":"            solution \u003d self.do_execute(audit, request_context)"},{"line_number":115,"context_line":"            self.post_execute(audit, solution, request_context)"},{"line_number":116,"context_line":"            if audit.strategy_id is None:"},{"line_number":117,"context_line":"                obj_strategy \u003d objects.Strategy.get_by_name("},{"line_number":118,"context_line":"                    request_context, solution.strategy_name)"},{"line_number":119,"context_line":"                audit.strategy_id \u003d obj_strategy.id"},{"line_number":120,"context_line":"                audit.strategy \u003d obj_strategy"},{"line_number":121,"context_line":"                audit.save()"},{"line_number":122,"context_line":"        except Exception as e:"},{"line_number":123,"context_line":"            LOG.exception(e)"},{"line_number":124,"context_line":"            self.update_audit_state(audit, objects.audit.State.FAILED)"}],"source_content_type":"text/x-python","patch_set":2,"id":"ba5201f7_13862ab9","line":121,"range":{"start_line":116,"start_character":0,"end_line":121,"end_character":28},"in_reply_to":"ba5201f7_4a4ade84","updated":"2017-01-04 06:45:22.000000000","message":"ok, thank you for the explanation.","commit_id":"952802cb2ba16f32316e9bd738e1138f08a3dd07"}]}
