#579 Add multiple decision contexts support
Merged by vmaljulin. Opened by vmaljulin.
vmaljulin/greenwave RHELWF-413  into  master

Download 579.patch

New policy field decision_contexts supports list, context of this field is being added
to the original decision_context field

JIRA: RHELWF-413

rebased onto 404e9620846e86db00b44fa5c6a75434797b2ef8

s/keeped/kept/g

Is this optional=True because you can still have "decision_context" for backward compatibility? In that case, optional=True seems appropriate, otherwise not.

Could you add a test with multiple decision contexts in the list?

Some small comments, but when those are addressed it looks good +1

Probably not needed, used for testing

rebased onto a488f0aa1dab358d1f7437968d6610efbdc194b7

Is this optional=True because you can still have "decision_context" for backward compatibility? In that case, optional=True seems appropriate, otherwise not.

Yes, I need to keep backward compatibility, because I think it would be a nightmare if we'd need to change all the policies all around the world. So I've added a new parameter instead of modifying the old one. That's why this new parameter is optional.

Probably not needed, used for testing

Removed

Could you add a test with multiple decision contexts in the list?

Done

s/keeped/kept/g

Done

Pull-Request has been merged by vmaljulin

decision_context shouldn't be required if decision_contexts is specified. Probably only one should be required, i.e. if decision_contexts is defined, decision_context should be undefined -- this could help identify some mistakes when writing the policy file.

This should return decision contexts in policies that are not defined in Greenwave policies. The new code doesn't seem to do the same.

E.g. if context x, y are defined in Greenwave policies and y, z is defined in policies, this should return z.

decision_context shouldn't be required if decision_contexts is specified. Probably only one should be required, i.e. if decision_contexts is defined, decision_context should be undefined -- this could help identify some mistakes when writing the policy file.

Making decision_contexts to be mandatory means a requirement to replace ALL the current policy files, i.e. it will be completely backward-incompatible change. Making it backward-compatible was the primary reason for introducing a new field instead of changing the existing one.

Also, as you can see, it removes duplicates, so if something is specified in both fields, it will be used only once.

Making decision_contexts to be mandatory means a requirement to replace ALL the current policy files, i.e. it will be completely backward-incompatible change. Making it backward-compatible was the primary reason for introducing a new field instead of changing the existing one.

The logic should be that exactly one of the two is required. It's unnecessary to define decision_context if decision_contexts is defined.

BTW, the original request (#467) is to allow list of strings in decision_context (but allow it to be also a string for backwards compatibility).

Functional tests fail (test_validate_gating_yaml_valid, test_validate_gating_yaml_missing_decision_context).

Metadata