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

Retain process logs on robustness tests #16077

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

Conversation

tjungblu
Copy link
Contributor

Adding a new flag to retain e2e etcd process logs after stop and saving next to the visualized model.

Spun out of #16018 where I used it for easier local debugging on model violations.

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

@serathius
Copy link
Member

Etcd logs are available the same way as e2e logs. By passing EXPECT_DEBUG=true flag to the test run.

@tjungblu
Copy link
Contributor Author

Etcd logs are available the same way as e2e logs. By passing EXPECT_DEBUG=true flag to the test run.

If you feel like browsing the logs is convenient enough already I'm happy to close. For me it makes more sense to have the member debug logs next to the history.html in the artifacts zip.

@serathius
Copy link
Member

If you feel like browsing the logs is convenient enough already I'm happy to close. For me it makes more sense to have the member debug logs next to the history.html in the artifacts zip.

It's not #15079

@serathius
Copy link
Member

serathius commented Jun 14, 2023

FYI main challenge here is to merge logs from between server restarts.

@tjungblu tjungblu force-pushed the etcdprocess_logs branch 2 times, most recently from 9359aa9 to ab50d80 Compare June 14, 2023 14:16
@tjungblu
Copy link
Contributor Author

@serathius created an aggregation of LogExpects to merge the logs. Let me know if the implemented behavior works for you, too (mostly on the expect side of things).

@@ -230,7 +233,7 @@ func (ep *EtcdServerProcess) Config() *EtcdServerProcessConfig { return ep.cfg }

func (ep *EtcdServerProcess) Logs() LogsExpect {
Copy link
Member

Choose a reason for hiding this comment

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

Code looks nice, but changing func (ep *EtcdServerProcess) Logs() LogsExpect semantic behavior is risky. When I expect most people will assume member.Logs().ExpectWithContext() will analyse logs emitted from the current run and might stumble on problem that log they are expecting was already emitted before restart.

Proposal:

  • Have func (ep *EtcdServerProcess) Logs() LogsExpect return logsExpect from the latest run ep.logs.procLogs[len(ep.logs.procLogs)-1]
  • Have a separate method like allLogLines or aggregatedLogLines etcd that will return appended results of all runs.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

Agreed with the incremental changes to be safe.

func (ep *EtcdServerProcess) Logs() LogsExpect was using ep.proc in happy case and most of the cases.

The PR is intended to retain all the previous runs logs after all the runs of the process are stopped.

Seems only func (m *multiLogsExpect) Lines() is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have func (ep *EtcdServerProcess) Logs() LogsExpect return logsExpect from the latest run ep.logs.procLogs[len(ep.logs.procLogs)-1]

Sounds like a good proposal to me. Is that also acceptable for you @chaochn47?

Seems only func (m *multiLogsExpect) Lines() is needed.

Currently yes, I'm surprised we don't have expect tests across stop/restart scenarios.

Copy link
Contributor Author

@tjungblu tjungblu Jun 15, 2023

Choose a reason for hiding this comment

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

I pushed a slight alternative as a new commit, while the process is running it will return the running LogsExpect, otherwise the last one from the multiLogsExpect.

Looking into the dependencies of the Lines method we could also split the interface in two, one for the Lines+Count and one for the expect to leave the current code paths untouched. There's only a zap test depending on the lines of a given process.

Copy link
Member

Choose a reason for hiding this comment

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

Currently yes, I'm surprised we don't have expect tests across stop/restart scenarios.

We want to explicitly avoid that because it not natural. Imagine that you want to check that etcd member has started using one of the starting logs. It's natural to call member.Logs().Expect("etcd started"), but it needs to only consider the logs from the last restart to make sense. Otherwise it might always return true when member was already restarted.

tldr. Don't want to change the semantics of func (ep *EtcdServerProcess) Logs() LogsExpect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool, pushed another by just moving up the Lines and Count via interface, so the current LogsExpect stays entirely untouched.

Adding a set of functions which retain e2e etcd process logs after stop and
saving next to the visualized model during robustness tests.

Spun out of etcd-io#16018 where I used it for easier local debugging on model
violations. Fixes etcd-io#15079 partially.

Signed-off-by: Thomas Jungblut <tjungblu@redhat.com>
return ep.logs.Lines()
}

func (ep *EtcdServerProcess) LineCount() int {
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't looks like it's used by anyone. Remove?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just two places ultimately: https://github.com/search?q=repo%3Aetcd-io%2Fetcd%20LineCount&type=code

but looks like it could be removed

Copy link
Member

Choose a reason for hiding this comment

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

I mean it's not needed for EtcdServerProcess.

@@ -235,6 +242,14 @@ func (ep *EtcdServerProcess) Logs() LogsExpect {
return ep.proc
}

func (ep *EtcdServerProcess) Lines() []string {
Copy link
Member

Choose a reason for hiding this comment

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

Proposed interface member.Logs() and member.Lines() seems unnatural. Recommendation:

  • Rename member.Logs() to member.ProcessLogs() to inform that those logs come only from the started process.
  • Rename member.Lines() to member.DumpLogs().

@@ -72,6 +77,7 @@ type EtcdServerProcess struct {
proxy proxy.Server
failpoints *BinaryFailpoints
donec chan struct{} // closed when Interact() terminates
logs *procLogs
Copy link
Member

@serathius serathius Jun 15, 2023

Choose a reason for hiding this comment

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

Suggested change
logs *procLogs
logs procLogs

It doesn't need to be a pointer.

@@ -235,6 +242,14 @@ func (ep *EtcdServerProcess) Logs() LogsExpect {
return ep.proc
}

func (ep *EtcdServerProcess) Lines() []string {
return ep.logs.Lines()
Copy link
Member

Choose a reason for hiding this comment

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

I find it pretty unnatural that calling member.Lines() will not return me any log lines until the process has exited.

@@ -378,3 +393,20 @@ func GetVersionFromBinary(binaryPath string) (*semver.Version, error) {

return nil, fmt.Errorf("could not find version in binary output of %s, lines outputted were %v", binaryPath, lines)
}

type procLogs struct {
Copy link
Member

Choose a reason for hiding this comment

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

Don't think the name makes sense. Does "proc" refer to process or something else? As this merges log lines from multiple process lines it's definitely not processLogs.

@@ -378,3 +393,20 @@ func GetVersionFromBinary(binaryPath string) (*semver.Version, error) {

return nil, fmt.Errorf("could not find version in binary output of %s, lines outputted were %v", binaryPath, lines)
}

type procLogs struct {
procLogs []string
Copy link
Member

Choose a reason for hiding this comment

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

You know you don't need to create struct just have type logs []string ?

@serathius
Copy link
Member

Also, please remove environment EXPECT_DEBUG from the Robustness tests github workflow.

@stale
Copy link

stale bot commented Sep 17, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 21 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 17, 2023
@stale stale bot removed the stale label Jan 16, 2024
@k8s-ci-robot
Copy link

@tjungblu: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-etcd-verify b5cdfc0 link true /test pull-etcd-verify
pull-etcd-unit-test-amd64 b5cdfc0 link true /test pull-etcd-unit-test-amd64
pull-etcd-unit-test-arm64 b5cdfc0 link true /test pull-etcd-unit-test-arm64

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants