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

Archive Logs for init and wait container #12640

Open
tczhao opened this issue Feb 8, 2024 · 10 comments
Open

Archive Logs for init and wait container #12640

tczhao opened this issue Feb 8, 2024 · 10 comments
Labels
area/archive-logs Archive Logs feature type/feature Feature request

Comments

@tczhao
Copy link
Member

tczhao commented Feb 8, 2024

Summary

Currently argo ArchiveLogs only supports logs from main container.
From time to time user is asking if it supports init and wait container log.

I'm aware the archivelog docs recommend a proper logging facility for logging,
Maybe this is still something we could consider if there's enough 👍

Use Cases

When would you use this?
Archive init and wait container log for debugging purpose


Message from the maintainers:

Love this enhancement proposal? Give it a 👍. We prioritize the proposals with the most 👍.

@tczhao tczhao added the type/feature Feature request label Feb 8, 2024
@ljyanesm
Copy link

ljyanesm commented Feb 8, 2024

I think it'd be enough if the docs (https://argo-workflows.readthedocs.io/en/latest/configure-archive-logs/) on top of suggesting:

⚠️ We do not recommend you rely on Argo Workflows to archive logs. Instead, use a conventional Kubernetes logging facility.

Had a link to the relevant section in workflow-controller-configmap.yaml for suggesting a better alternative.

@Joibel
Copy link
Member

Joibel commented Feb 8, 2024

@ljyanesm there is already a PR in progress #12597 for the documentation for this. Please feel free to review and add your perspective on it.

@agilgur5 agilgur5 added the area/archive-logs Archive Logs feature label Feb 8, 2024
@panicboat
Copy link
Contributor

panicboat commented Mar 17, 2024

Hello.
Are there any barriers to implementing this feature?
If there are no barriers to implementation, I would be happy to take on the challenge.

I believe that we can simply modify this section slightly to make it feasible. Wouldn't this be a good first issue?

func (we *WorkflowExecutor) SaveLogs(ctx context.Context) []wfv1.Artifact {
var logArtifacts []wfv1.Artifact
tempLogsDir := "/tmp/argo/outputs/logs"
if we.Template.SaveLogsAsArtifact() {
err := os.MkdirAll(tempLogsDir, os.ModePerm)
if err != nil {
we.AddError(argoerrs.InternalWrapError(err))
}
containerNames := we.Template.GetMainContainerNames()
logArtifacts = make([]wfv1.Artifact, 0)
for _, containerName := range containerNames {
// Saving logs
art, err := we.saveContainerLogs(ctx, tempLogsDir, containerName)
if err != nil {
we.AddError(err)
} else {
logArtifacts = append(logArtifacts, *art)
}
}
}
return logArtifacts
}

@tczhao
Copy link
Member Author

tczhao commented Mar 18, 2024

I believe that we can simply modify this section slightly to make it feasible.

Yes,

But you would also need to consider

  • if we should modify workflow-controller configmap so that the user can choose what to log
  • if the current UI works well with this change

@panicboat
Copy link
Contributor

Thanks for confirming.

if we should modify workflow-controller configmap so that the user can choose what to log

I'm thinking this could be recorded without awareness if archiveLogs: true is set.
If you don't have strong feelings about this matter, could you please assign it to me so I can proceed?
Having the assignments set up allows me to remember to work on them.

@panicboat
Copy link
Contributor

panicboat commented May 22, 2024

📝 Simply adding the container name doesn't seem to work.

containerNames := we.Template.GetMainContainerNames()

Changes

containerNames := append(we.Template.GetMainContainerNames(), common.InitContainerName, common.WaitContainerName)

Logs

vscode ➜ ~/go/src/github.com/argoproj/argo-workflows (main) $ kubectl logs arguments-parameters-from-configmap-14 -c wait
time="2024-05-22T06:48:56.008Z" level=info msg="Starting Workflow Executor" version=latest+d4b9327.dirty
time="2024-05-22T06:48:56.108Z" level=info msg="Using executor retry strategy" Duration=1s Factor=1.6 Jitter=0.5 Steps=5
time="2024-05-22T06:48:56.110Z" level=info msg="Executor initialized" deadline="2024-05-22 06:53:49 +0000 UTC" includeScriptOutput=false namespace=argo podName=arguments-parameters-from-configmap-14 templateName=whalesay version="&Version{Version:latest+d4b9327.dirty,BuildDate:2024-05-22T06:46:22Z,GitCommit:d4b9327b93511164d4f4401df6e867cd08faa2f7,GitTag:untagged,GitTreeState:dirty,GoVersion:go1.21.10,Compiler:gc,Platform:linux/amd64,}"
time="2024-05-22T06:48:56.211Z" level=debug msg="Create workflowtaskresults 403"
time="2024-05-22T06:48:56.274Z" level=warning msg="failed to patch task result, falling back to legacy/insecure pod patch, see https://argo-workflows.readthedocs.io/en/latest/workflow-rbac/" error="workflowtaskresults.argoproj.io is forbidden: User \"system:serviceaccount:argo:argo\" cannot create resource \"workflowtaskresults\" in API group \"argoproj.io\" in the namespace \"argo\""
time="2024-05-22T06:48:56.282Z" level=debug msg="Patch pods 200"
time="2024-05-22T06:48:56.298Z" level=info msg="+++++++++++++++++Starting deadline monitor+++++++++++++++++"
time="2024-05-22T06:48:57.303Z" level=info msg="Main container completed" error="<nil>"
time="2024-05-22T06:48:57.305Z" level=info msg="No Script output reference in workflow. Capturing script output ignored"
time="2024-05-22T06:48:57.305Z" level=info msg="No output parameters"
time="2024-05-22T06:48:57.306Z" level=info msg="No output artifacts"
time="2024-05-22T06:48:57.316Z" level=info msg="S3 Save path: /tmp/argo/outputs/logs/main.log, key: arguments-parameters-from-configmap-14/arguments-parameters-from-configmap-14/main.log"
time="2024-05-22T06:48:57.496Z" level=info msg="Creating minio client using static credentials" endpoint=s3.amazonaws.com
time="2024-05-22T06:48:57.497Z" level=info msg="Saving file to s3" bucket=panicboat-sandbox-723535945756 endpoint=s3.amazonaws.com key=arguments-parameters-from-configmap-14/arguments-parameters-from-configmap-14/main.log path=/tmp/argo/outputs/logs/main.log
time="2024-05-22T06:48:57.973Z" level=info msg="Save artifact" artifactName=main-logs duration=656.608042ms error="<nil>" key=arguments-parameters-from-configmap-14/arguments-parameters-from-configmap-14/main.log
time="2024-05-22T06:48:57.973Z" level=info msg="not deleting local artifact" localArtPath=/tmp/argo/outputs/logs/main.log
time="2024-05-22T06:48:57.973Z" level=info msg="Successfully saved file: /tmp/argo/outputs/logs/main.log"
time="2024-05-22T06:48:57.974Z" level=error msg="executor error: open /var/run/argo/ctr/init/combined: no such file or directory"
time="2024-05-22T06:48:57.974Z" level=error msg="executor error: open /var/run/argo/ctr/wait/combined: no such file or directory"
time="2024-05-22T06:48:57.978Z" level=debug msg="Create workflowtaskresults 403"
time="2024-05-22T06:48:57.979Z" level=warning msg="failed to patch task result, falling back to legacy/insecure pod patch, see https://argo-workflows.readthedocs.io/en/latest/workflow-rbac/" error="workflowtaskresults.argoproj.io is forbidden: User \"system:serviceaccount:argo:argo\" cannot create resource \"workflowtaskresults\" in API group \"argoproj.io\" in the namespace \"argo\""
time="2024-05-22T06:48:57.991Z" level=debug msg="Patch pods 200"
time="2024-05-22T06:48:57.999Z" level=info msg="Alloc=8996 TotalAlloc=16888 Sys=24677 NumGC=6 Goroutines=10"
time="2024-05-22T06:48:58.001Z" level=debug msg="Patch workflowtaskresults 403"
time="2024-05-22T06:48:58.001Z" level=warning msg="failed to patch task result, falling back to legacy/insecure pod patch, see https://argo-workflows.readthedocs.io/en/latest/workflow-rbac/" error="workflowtaskresults.argoproj.io \"arguments-parameters-from-configmap-14\" is forbidden: User \"system:serviceaccount:argo:argo\" cannot patch resource \"workflowtaskresults\" in API group \"argoproj.io\" in the namespace \"argo\""
time="2024-05-22T06:48:58.007Z" level=debug msg="Patch pods 200"
time="2024-05-22T06:48:58.011Z" level=fatal msg="open /var/run/argo/ctr/init/combined: no such file or directory"

@Joibel
Copy link
Member

Joibel commented May 22, 2024

I'm thinking this could be recorded without awareness if archiveLogs: true is set.

I'd prefer it if this was separately controllable.
For many scenarios this will just be archiving things people don't want, which will cost them money.

@panicboat
Copy link
Contributor

I would like to work on this assignment, although the modifications are going to be more extensive than I originally thought.
However, I have little knowledge of Golang or the implementation of Argo Workflows, so I was wondering if anyone would be willing to work with me on the task.
I know this is a loaded request, so please consider it.

I believe this issue requires capturing the logs of the init/wait container as well as the main container, but I don't understand how to implement this.

@tooptoop4
Copy link
Contributor

dupe of #8902

@agilgur5 agilgur5 changed the title Support archive init and wait container logs Archive Logs for init and wait container Oct 16, 2024
@agilgur5
Copy link
Member

dupe of #8902

Marked it as superseded since there are more implementation details here and more upvotes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/archive-logs Archive Logs feature type/feature Feature request
Projects
None yet
Development

No branches or pull requests

6 participants