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

add default interpreter for interpretHealth #2370

Merged
merged 1 commit into from
Aug 19, 2022

Conversation

zhuwint
Copy link
Contributor

@zhuwint zhuwint commented Aug 12, 2022

/kind feature

What this PR does / why we need it:

add default resource interpreter for interpretHealth

Which issue(s) this PR fixes:
Part of #2354

Special notes for your reviewer:

The method for health check is referred to https://github.com/jessesuen/argo-cd/blob/37a58fb9f1a2d7e20fe8e37a93ffa2e66b0eb9c7/util/health/health.go

Does this PR introduce a user-facing change?:
NONE

@karmada-bot karmada-bot added the kind/feature Categorizes issue or PR as related to a new feature. label Aug 12, 2022
@karmada-bot karmada-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 12, 2022
return false, err
}

if replicaSet.Generation == replicaSet.Status.ObservedGeneration {
Copy link
Member

Choose a reason for hiding this comment

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

We can use guard code here, just like:

	if replicaSet.Generation != replicaSet.Status.ObservedGeneration {
		return false, nil
	}

Same as bellow.

Comment on lines 132 to 133
healthy := pvc.Status.Phase == corev1.ClaimBound
return healthy, nil
Copy link
Member

Choose a reason for hiding this comment

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

How about this:

return pvc.Status.Phase == corev1.ClaimBound, nil

@@ -211,3 +212,314 @@ func Test_interpretStatefulSetHealth(t *testing.T) {
})
}
}

func Test_interpretReplicaSetHealth(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

The case for determining the replicas is missing.

Comment on lines 223 to 233
{
name: "failed convert to ReplicaSet object",
object: &unstructured.Unstructured{
Object: map[string]interface{}{
"spec": "format error",
"status": "format error",
},
},
want: false,
wantErr: true,
},
Copy link
Member

Choose a reason for hiding this comment

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

I see similar judgments in each test case. Is it possible to consider testing method ConvertToTypedObject so that similar test cases can be omitted?

If this is feasible, you can submit a separate pr to test method ConvertToTypedObject.

@XiShanYongYe-Chang
Copy link
Member

/assign

Signed-off-by: zhuwint <zhuwentao15@huawei.com>
Copy link
Member

@XiShanYongYe-Chang XiShanYongYe-Chang left a comment

Choose a reason for hiding this comment

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

Thanks~
/lgtm
/approve

@karmada-bot karmada-bot added the lgtm Indicates that a PR is ready to be merged. label Aug 19, 2022
Copy link
Member

@RainbowMango RainbowMango left a comment

Choose a reason for hiding this comment

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

/approve

@karmada-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RainbowMango, XiShanYongYe-Chang

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

@karmada-bot karmada-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 19, 2022
@karmada-bot karmada-bot merged commit 78c299c into karmada-io:master Aug 19, 2022
@zhuwint zhuwint deleted the dev-defaultinterpreter branch August 25, 2022 07:08
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. kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants