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

refactor(status): update status.condition in DSC and DSCI #1196

Open
wants to merge 1 commit into
base: incubation
Choose a base branch
from

Conversation

zdtsw
Copy link
Member

@zdtsw zdtsw commented Aug 21, 2024

Description

re-wrok on #977

feat(status): update status.condition in DSC and DSCI

for Condition:

  • create a generic function FailedComponentCondition() for all components to use, return condition and error
  • keep status types to only "avaiable" "progressing" degraded" and "reconcilesuccess"
  • status:ReconcileComplete is renamed to ReconcileSuccess
  • status:upgradeable is removed

for Phase: Created, Ready, Error, deleting

  • set phase to Error if Argo CRD exist
  • remove Progressing to use Created instead

chore:

  • fix typo and some missing customized error message
  • fix Message when created

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

@openshift-ci openshift-ci bot requested review from AjayJagan and CFSNM August 21, 2024 17:18
Copy link

openshift-ci bot commented Aug 21, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from zdtsw. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@zdtsw zdtsw requested review from lburgazzoli and VaishnaviHire and removed request for CFSNM and AjayJagan August 21, 2024 17:19
// type: <component>Ready
// status: Unknown
// reason: ReconcileStart
func SetInitComponentCondition(componentName string, enabled bool) conditionsv1.Condition {
Copy link
Contributor

Choose a reason for hiding this comment

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

All these functions do not set/update anything (VS https://pkg.go.dev/k8s.io/apimachinery/pkg/api/meta#SetStatusCondition which operates on existing list, but still "Set" is not the best name there either) but create a new condition object with different properties. I would call that family of functions "New*".

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 update the name from SetInitComponentCondition() to InitControllerCondition()
and a bunch of others: removed Set in prefix

main idea is:
in controller:

  • on DSC/DSCI/FTer condition
case to call
DSC/DSCI just created UpdateCondition(oldcondition, InitControllerCondition())
deleting DSC by configmap UpdateCondition(oldcondition, UnavailableCondition())
DSC exist but no DSCI UpdateCondition(oldcondition, UnavailableCondition())
DSC/DSCI success reconciled SetCompleteCondition()
FTer success applied SetCompleteCondition()
DSCI failed reconcile SetErrorCondition(...,CapabilityFailed,...)
DSC failed reconcile SetErrorCondition()
FTer failed to create SetErrorCondition()
  • on component condition (under DSC):
result to call
success + removed RemoveComponentCondition()
failure UpdateCondition(oldcondition, reconcileCondition)
success + managed UpdateCondition(oldcondition, reconcileCondition)
sepcial on argo UpdateCondition(oldcondition, ArgoExistCondition())
component just set to managed UpdateCondition(oldcondition, InitComponentCondition())

in each component logic:

result return
success SuccessComponentCondition(...) used as reconcileCondition
failure FailedComponentCondition(....) used as reconcileCondition

Copy link
Contributor

Choose a reason for hiding this comment

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

So, why not New* when you just create a structure? It makes intentions clear, while reading "InitComponentCondition" at the first glance I would read is "Initialize ComponentCondition".

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 take your suggestion and renamed it also skipped UpdateCondition on this init creation phase

func UpdateFailedCondition(componentName string, err error) (conditionsv1.Condition, error) {
FailedCondition := setFailedComponentCondition(componentName)
FailedCondition.Message = err.Error()
return FailedCondition, err
Copy link
Contributor

Choose a reason for hiding this comment

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

What the point to return unchanged err you just passed?

Copy link
Member Author

Choose a reason for hiding this comment

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

to convert err into String and set as condition.Message.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is the point of the function, but it does not answer my question :)

}

// UpdateCondition is top caller in DSC controller to handle different case: init, check, error, successetc.
func UpdateCondition(conditions *[]conditionsv1.Condition, newCondition conditionsv1.Condition) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Plural then, it updates the first argument (vs the callee, which sets the second argument in the first list)
What is the point of the wrapper? I doubt it brings more clarity.

Copy link
Member Author

Choose a reason for hiding this comment

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

could have it directly calling conditionsv1.SetStatusCondition everywhere in DSC
but feel like easier to follow the same pattern as RemoveComponentCondition
maybe not be that useful to have it for now, till we want to add more logic within the function

Copy link
Contributor

Choose a reason for hiding this comment

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

So it should have been called UpdateComponentCondition. But I did not change my opinion that both wrappers are misleading. They assume there is some logic related to component behind the call while they just operate on the provided lists. The intention (the list and the provided member of the list) is clear from the call itself without the wrapper.

for Condition:
- create a generic function UpdateFailedCondition() for all components to use, return condition and error
- keep status types to only "avaiable" "progressing" degraded" and "reconcilesuccess"
- status:ReconcileComplete is renamed to ReconcileSuccess
- status:upgradeable is removed

for pipeline:
- move SetExistingArgoCondition from pipeline to status
- remove duplicated update on DSC, since error already catch in pipeline and UpdateFailedCondition() is called

for Phase: Created, Ready, Error, deleting
- set phase to Error if Argo CRD exist
- remove Progressing to use Created instead when DSCI CR just created

chore:
- fix typo and some missing customized error message
- fix Message when created
- move static reason,message into status package

Signed-off-by: Wen Zhou <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

3 participants