Skip to content

Refactor Revision lifecycle functions #5780

Closed

Description

@dgerd

In what area(s)?

/area API

/area autoscale
/area build
/area monitoring
/area networking
/area test-and-release

Describe the feature

https://github.com/knative/serving/blob/master/pkg/apis/serving/v1alpha1/revision_lifecycle.go is up to 12 Mark* functions for manipulating the RevisionStatus. The number of functions here is starting to get unwieldy, and it is not immediately clear when to call a particular function and which ConditionType the function impacts. In addition there is inconsistency in how the Reason and Message is being set in these functions.

The proposal here is to create True/Unknown/False functions for each ConditionType and a struct type to pass the remaining relevant string information.

For example,

const (
 ReasonDeadlineExceeded = "ProgressDeadlineExceeded"
 ReasonNotOwned = "NotOwned"
 ...
)

/// These methods pre-set Type/Status/Severity. They take a Reason and Message for Unknown/False status.
MarkResourcesAvailableTrue()
MarkResourcesAvailableUnknown(reason, message string)
MarkResourcesAvailableFalse(reason, message string)

func ExitCodeReason(exitCode int32) string { ...}

Activity

  1. added
    kind/feature
    on Oct 9, 2019
  2. added
    area/API
    on Oct 9, 2019
  3. knative-prow-robot commented on Oct 9, 2019

    @knative-prow-robot
    Contributor

    @dgerd: The label(s) kind/proposal cannot be applied. These labels are supported: ``

    Details

    In response to this:

    In what area(s)?

    /area API

    /area autoscale
    /area build
    /area monitoring
    /area networking
    /area test-and-release

    Describe the feature

    https://github.com/knative/serving/blob/master/pkg/apis/serving/v1alpha1/revision_lifecycle.go is up to 12 Mark* functions for manipulating the RevisionStatus. The number of functions here is starting to get unwieldy, and it is not immediately clear when to call a particular function and which ConditionType the function impacts. In addition there is inconsistency in how the Reason and Message is being set in these functions.

    The proposal here is to create True/Unknown/False functions for each ConditionType and a struct type to pass the remaining relevant string information.

    For example,

    const (
    ReasonDeadlineExceeded = "ProgressDeadlineExceeded"
    ReasonNotOwned = "NotOwned"
    ...
    )
    
    /// These methods pre-set Type/Status/Severity. They take a Reason and Message for Unknown/False status.
    MarkResourcesAvailableTrue()
    MarkResourcesAvailableUnknown(reason, message string)
    MarkResourcesAvailableFalse(reason, message string)
    
    func ExitCodeReason(exitCode int32) string { ...}
    

    Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

  4. nimakaviani commented on Oct 10, 2019

    @nimakaviani
    Contributor

    I can take a stab at refactoring it.

  5. added a commit that references this issue on Oct 14, 2019
    68cefa9
  6. nimakaviani commented on Oct 15, 2019

    @nimakaviani
    Contributor

    looks like lifecycle functions for other resources can also benefit from similar refactoring. once I have the first PR approved, I can refactor those functions as well.

  7. added a commit that references this issue on Oct 15, 2019
    3a007c3
  8. added a commit that references this issue on Oct 17, 2019
    3336b1e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/APIkind/feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions