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

[kwok] Provided service for logs #417

Merged

Conversation

nikola-jokic
Copy link
Contributor

@nikola-jokic nikola-jokic commented Mar 24, 2023

What type of PR is this?

/kind feature

Which issue(s) this PR fixes:

Fixes #217

Does this PR introduce a user-facing change?

Add logs logic with Logs and ClusterLogs type

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. kind/feature Categorizes issue or PR as related to a new feature. labels Mar 24, 2023
@netlify
Copy link

netlify bot commented Mar 24, 2023

Deploy Preview for k8s-kwok canceled.

Name Link
🔨 Latest commit 60c1bc8
🔍 Latest deploy log https://app.netlify.com/sites/k8s-kwok/deploys/6432d62ea7e01700084d3d43

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 24, 2023
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 24, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @nikola-jokic. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Mar 24, 2023
@nikola-jokic nikola-jokic changed the title Nikola jokic/logs service [kwok] Provided service for logs Mar 24, 2023
@wzshiming
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 27, 2023
@nikola-jokic
Copy link
Contributor Author

/retest

@nikola-jokic nikola-jokic marked this pull request as ready for review March 31, 2023 09:47
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Mar 31, 2023
pkg/kwokctl/runtime/kind/cluster.go Outdated Show resolved Hide resolved
pkg/kwokctl/runtime/kind/kind.yaml.tpl Outdated Show resolved Hide resolved
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 3, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 3, 2023
@nikola-jokic
Copy link
Contributor Author

I am not sure why Mac does not allow /tmp/kwok to be mounted as a volume
This workflow run shows that /tmp/kwok exists, but the docker on Mac does not allow it
Ideally, I'd go with this by creating a file in /tmp, but then the kind would fail mounting tmp twice to the kind runtime.
I did not try ignoring /tmp mount in kind since it seems to me that we would tie implementation too much with the runtime, but that might be a way to go.
@wzshiming what do you think?

Copy link
Member

@wzshiming wzshiming left a comment

Choose a reason for hiding this comment

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

I think it's a permissions issue, we don't have access to /tmp/ on the Mac in CI

test/kwokctl/kwokctl_logs_test.sh Outdated Show resolved Hide resolved
test/kwokctl/logs.yaml Outdated Show resolved Hide resolved
@nikola-jokic
Copy link
Contributor Author

Trying tests again

If they fail, I'll investigate it to see if there is a problem on the runner side... I executed logs tests on Mac, and they worked... It might be something similar to the hosted machine from the last time 😕

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 8, 2023
Copy link
Member

@wzshiming wzshiming left a comment

Choose a reason for hiding this comment

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

I've tried kubectl logs which works fine, kubectl logs -f which doesn't seem to work

func readLogs(ctx context.Context, logInfo *internalversion.Log, opts *logOptions, stdout, stderr io.Writer) error {
logger := log.FromContext(ctx)

logsFilePath := path.Join("/var/components/controller", logInfo.LogsFile)
Copy link
Member

Choose a reason for hiding this comment

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

I think this part of the logic should be handled in kwokctl, not in the kwok server.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Working on it
Thank you for reviews a lot! I wanted to push this to ask for an opinion

I'll have it ready now that I know everything how to structure it, and I'll test all scenarios
Thank you again!

volumes := make([]internalversion.Volume, 0, len(mountDirs))
i := 0
for dir := range mountDirs {
dirPath := strings.TrimPrefix(dir, "/var/components/controller")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the part I am unsure of. We can probably add strip prefix only in case when runtime is kind because we know that the prefix is going to be added, and it is going to be used in template.

The issue is that to use extra volume mounts, we add /var/components/controller to all paths.
Since we need correct configuration for logs, we expand the path. I agree that the server should not inspect the runtime from configuration, so that is why this change was necessary. Ideally it should not interfere with the binary runtime unless the actual path there is this constant. Because of that, It might be wise to use check for the runtime but I wanted to check first, since this approach might be flawed in a way I don't know 😄

@nikola-jokic
Copy link
Contributor Author

Thank you for pointing out the follow. I included tests for tail, since and follow in e2e tests 😄

@wzshiming
Copy link
Member

/approve
/lgtm
/label tide/merge-method-squash
/hold

I've tested it locally and it's all working as expected, great!
Unhold as you wish 😄

Also, add the same logic to Attach, do you think it's appropriate?

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. labels Apr 12, 2023
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 12, 2023
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nikola-jokic, wzshiming

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 Apr 12, 2023
@nikola-jokic
Copy link
Contributor Author

/unhold

Oh sure! Taking that one 😄

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 12, 2023
@k8s-ci-robot k8s-ci-robot merged commit 7e44951 into kubernetes-sigs:main Apr 12, 2023
@nikola-jokic nikola-jokic deleted the nikola-jokic/logs-service branch April 12, 2023 08:10
@wzshiming wzshiming added the kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API label Apr 17, 2023
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. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[kwok] Provided service for logs
3 participants