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 more logs #676

Merged
merged 6 commits into from
Jul 23, 2019
Merged

add more logs #676

merged 6 commits into from
Jul 23, 2019

Conversation

weekface
Copy link
Contributor

What problem does this PR solve?

What is changed and how does it work?

Check List

Tests

  • Unit test
  • No code

Code changes

  • Has Go code change

Side effects

Related changes

  • Need to cherry-pick to the release branch

Does this PR introduce a user-facing change?:

NONE

@weekface weekface added this to the v1.0.0 milestone Jul 22, 2019
@weekface
Copy link
Contributor Author

/run-e2e-tests

@weekface
Copy link
Contributor Author

/run-e2e-tests

tennix
tennix previously approved these changes Jul 22, 2019
Copy link
Member

@tennix tennix left a comment

Choose a reason for hiding this comment

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

Are the logs too verbose? Should we make the logs in different levels with glog.V(n)?

@@ -40,6 +41,7 @@ func (tf *tidbFailover) Failover(tc *v1alpha1.TidbCluster) error {
_, exist := tc.Status.TiDB.FailureMembers[tidbMember.Name]
if exist && tidbMember.Health {
delete(tc.Status.TiDB.FailureMembers, tidbMember.Name)
glog.Errorf("tidb failover: delete %s from tidb failoverMembers", tidbMember.Name)
Copy link
Member

Choose a reason for hiding this comment

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

Is this an error log?

@weekface
Copy link
Contributor Author

all these logs are "state changes", they can help us diagnose problems

@weekface
Copy link
Contributor Author

/run-e2e-tests

@@ -182,6 +182,7 @@ func serviceEqual(new, old *corev1.Service) (bool, error) {
// setUpgradePartition set statefulSet's rolling update partition
func setUpgradePartition(set *apps.StatefulSet, upgradeOrdinal int32) {
set.Spec.UpdateStrategy.RollingUpdate = &apps.RollingUpdateStatefulSetStrategy{Partition: &upgradeOrdinal}
glog.Infof("set %s/%s partition to %d successfully", set.GetNamespace(), set.GetName(), upgradeOrdinal)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's not a good idea to log in the utility function. log when the API operation has done?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the successfully word. ptal

@@ -90,8 +91,10 @@ func (opc *orphanPodsCleaner) Clean(tc *v1alpha1.TidbCluster) (map[string]string

err = opc.podControl.DeletePod(tc, pod)
if err != nil {
glog.Errorf("orphan pods cleaner: failed to clean orphan pod: %s/%s, %v", ns, podName, err)
Copy link
Contributor

Choose a reason for hiding this comment

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

I generally prefer to annotate errors: that way there is a single error data structure with all the information that can be logged in one spot, and if there is an API request sent back in the response.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, our error logs style need a lot of improvements. We may discuss it in a new issue?

This pr tries to add detailed logs when something changes to help us diagnose problems.

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 up to you. I think either way you should get a detailed log to help diagnose problems. If there is concurrent logging annotation will be simpler to understand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what is "logging annotation"?

@@ -128,18 +129,21 @@ func (h *ha) Filter(instanceName string, pod *apiv1.Pod, nodes []apiv1.Node) ([]
// replicas less than 3 cannot achieve high availability
if replicas < 3 {
minNodeNames = append(minNodeNames, nodeName)
glog.Infof("replicas is %d, add node %s to minNodeNames", replicas, nodeName)
Copy link
Contributor

@cofyc cofyc Jul 22, 2019

Choose a reason for hiding this comment

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

Loglines printed here are unnecessary, at line 109 we know the replicas of the component, if the replicas is smaller than 3, all nodes will be added into minNodeNames.

How about making it simpler, we can skip the for loop if the replicas is smaller than 3 and print one informative log?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How to skip the for loop? we must range the nodeMap anyway

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, you're right, we need to get node name

continue
}

podsCount := len(podNames)
if podsCount+1 >= int(replicas+1)/2 {
glog.Infof("node %s podsCount is %d, skipping", nodeName, podsCount)
Copy link
Contributor

Choose a reason for hiding this comment

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

print the int(replicas+1)/2 too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

replicas has been printed in 109.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed.

Copy link
Contributor

@cofyc cofyc left a comment

Choose a reason for hiding this comment

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

LGTM

@weekface
Copy link
Contributor Author

/run-e2e-tests

1 similar comment
@weekface
Copy link
Contributor Author

/run-e2e-tests

@weekface weekface merged commit 41bceb5 into pingcap:master Jul 23, 2019
weekface added a commit that referenced this pull request Jul 29, 2019
(cherry picked from commit 41bceb5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants