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

Mark aggregated condition ready only when No error happened #184

Merged
merged 1 commit into from
Mar 6, 2020

Conversation

nan-yu
Copy link
Contributor

@nan-yu nan-yu commented Mar 6, 2020

Fixes #183

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 6, 2020
@nan-yu
Copy link
Contributor Author

nan-yu commented Mar 6, 2020

/assign @barney-s

@@ -96,7 +96,7 @@ func (r *ApplicationReconciler) getNewApplicationStatus(ctx context.Context, app
Objects: objectStatuses,
}
newApplicationStatus.ComponentsReady = fmt.Sprintf("%d/%d", countReady, len(objectStatuses))
if aggReady && errs != nil {
if aggReady && errs == nil {
setReadyCondition(newApplicationStatus, "ComponentsReady", "all components ready")
} else {
setNotReadyCondition(newApplicationStatus, "ComponentsNotReady", "some components not ready")
Copy link
Contributor

Choose a reason for hiding this comment

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

is it possible that all components are ready but there's an error ?
I assume yes, the message / status should reflect that or it's still confusing.

The status would be in error with "some components not ready", as a user I would check which components isn't ready but won't find any....
Could we add a separate case:
something like :

if errs != nil { 
  "there's an error"
} else if aggReady {
 "all components ready"
} else 
{
 "some components not ready" // 'some' could be replaced with (len(objectStatuses)-countReady)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are two types of conditions: Ready and Error and we need to set both.
I think we can leverage the Unknown status for the Ready condition:

if errs != nil {
   //set ready condition to unknown
} else if aggReady {
  "all components ready"
} else {
    "x components not ready"
}

if errs != nil {
   setErrorCondition
} else {
   clearErrorCondition
}

@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 6, 2020
@nan-yu
Copy link
Contributor Author

nan-yu commented Mar 6, 2020

Example when errors happened in aggregating statuses:

"status": {
    "observedGeneration": 1,
    "conditions": [
      {
        "type": "Ready",
        "status": "Unknown",
        "reason": "ComponentsReadyUnknown",
        "message": "failed to aggregate all components' statuses, check the Error condition for details",
        "lastUpdateTime": "2020-03-06T20:20:29Z",
        "lastTransitionTime": "2020-03-06T20:20:29Z"
      },
      {
        "type": "Error",
        "status": "True",
        "reason": "ErrorSeen",
        "message": "[fetchComponentListResources error, setOwnerRefForResources error, service status error, statefulset status error]",
        "lastUpdateTime": "2020-03-06T20:20:29Z",
        "lastTransitionTime": "2020-03-06T20:20:29Z"
      }
    ],
    "components": [
      {
        "link": "/api/v1/namespaces/default/services/wordpress-mysql-hsvc",
        "name": "wordpress-mysql-hsvc",
        "kind": "Service",
        "status": "Unknown"
      },
      {
        "link": "/api/v1/namespaces/default/services/wordpress-webserver-hsvc",
        "name": "wordpress-webserver-hsvc",
        "kind": "Service",
        "status": "Unknown"
      },
      {
        "link": "/api/v1/namespaces/default/services/wordpress-webserver-svc",
        "name": "wordpress-webserver-svc",
        "kind": "Service",
        "status": "Unknown"
      },
      {
        "link": "/apis/apps/v1/namespaces/default/statefulsets/wordpress-mysql",
        "name": "wordpress-mysql",
        "kind": "StatefulSet",
        "group": "apps",
        "status": "Unknown"
      },
      {
        "link": "/apis/apps/v1/namespaces/default/statefulsets/wordpress-webserver",
        "name": "wordpress-webserver",
        "kind": "StatefulSet",
        "group": "apps",
        "status": "Unknown"
      }
    ],
    "componentsReady": "0/5"
  }

@ant31
Copy link
Contributor

ant31 commented Mar 6, 2020

thank you,
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 6, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ant31, nan-yu

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 6, 2020
@k8s-ci-robot k8s-ci-robot merged commit f10d9ca into kubernetes-sigs:master Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

is it desired to mark Ready even if errors happened?
4 participants