Skip to content

Discussion around a Conditions api abstraction #971

Closed
@scrocquesel

Description

@scrocquesel

This is about managing primary resource conditions not the dependent one.

Like with GenerationAware, there could be a ConditionsSetAwareStatus.

interface ConditionsSetAwareStatus {
    List<Condition> getConditions();
    void setConditions(List<Condition> conditions);
}

The idea is to have a manager for a ConditionType which is basically a wrapper around the condition property. The ConditionType will explicit a Ready condition type and dependent conditions type. When all dependent conditions are True, the Ready is True, False otherwise.

public class ConditionTypeSet
{
   private String readyConditionType;
   private String[] dependentsConditionType;
}

A manager would then use this ConditionTypeSet configuration and allow to manage the list of condition with a set of methods

public interface ConditionManager
{
    // add all conditions defined in the conditionSet
    Initialize();
   // set a condition to True and set the ready condition to True if all depedents are True
    SetTrue(String conditionType);
   // set a condition to False and set theready condition to False 
    SetFalse(String conditionType);
   // some override of True/False to pass reason/message

   // some other method to get the Ready Condition, check wether Ready is True, etc... to allow for logging for eg
}

public class ConditionManagerImpl implements ConditionManager
{
    public ConditionManagerImpl (ConditionSet set, ConditionsSetAwareStatus status);
}

I think it can be used wisely with dependents. With the exemple given in #850, a status could be

conditions:
  - lastTransitionTime: 2022-02-04T00:00:00Z
    type: dep1
    status: TRUE
  - lastTransitionTime: 2022-02-04T00:01:00Z
    type: ser1
    status: TRUE
  - lastTransitionTime: 2022-02-04T00:02:00Z
    type: OtherResource
    status: FALSE
  - lastTransitionTime: 2022-02-04T00:02:00Z
    type: READY
    status: FALSE

I omit reason/message but they may be valued the same way.

I don't know how the ConditionTypeSet should be exposed. Should it be a getter on ConditionsSetAwareStatus. And maybe the Manager could then be made available from the context if the Resource implements the interface.

What do you think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-discussionIssue needs to be discussed more before working on it

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions