-
Notifications
You must be signed in to change notification settings - Fork 376
Container: T7473: Fix show/monitor container log failed when log-driver is journald #4522
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
base: current
Are you sure you want to change the base?
Conversation
❌ |
👍 |
491b56b
to
2e80fb1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except some minor changes the overall implementation looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors how container log drivers are configured per-container and restores show log
/monitor log
for the journald
driver by routing through a new show_log
wrapper script.
- Added a
show_log
function in the op-mode script to invoke Podman orjournalctl
and support anone
driver. - Updated conf-mode generation to include
--log-driver
flags and amended interface and template definitions for the newlog-driver
option. - Adjusted smoke tests and op-mode XML to call the new
show_log
command instead of rawpodman logs
.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/op_mode/container.py | Added show_log implementation and subprocess import |
src/conf_mode/container.py | Inject --log-driver into container run args |
smoketest/scripts/cli/test_container.py | Set log-driver in test and update inspect command |
op-mode-definitions/container.xml.in | Changed log commands to call the wrapper script |
interface-definitions/container.xml.in | Added log-driver leaf with none option |
data/templates/container/containers.conf.j2 | Removed stale log_driver template snippet |
Comments suppressed due to low confidence (2)
src/op_mode/container.py:148
- The module does not import
vyos
, sovyos.opmode.InternalError
will cause aNameError
. Import thevyos
package or the exception class.
raise vyos.opmode.InternalError(f"Error starting logging command: {e} ")
smoketest/scripts/cli/test_container.py:113
- There's an extra double-quote at the end of the format string, which will break the command. Remove the redundant quote.
tmp = cmd(f'podman container inspect {cont_name} --format "{{{{ .HostConfig.LogConfig.Type }}}}""')
optimize code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All changes to the logging driver look solid.
I think there was a misunderstanding regarding my comment. In short:
I could also rework that in a followup merge request. |
❌ Conflicts Found. This pull request has conflicts. Please resolve them before we can evaluate the pull request. |
✅ Conflicts Resolved. Conflicts have been resolved. A maintainer will review the pull request shortly. |
@nvollmar I have updated the containers' log driver default value to journald, I hope this change can solve your concern. |
Could you check smoketest again? |
c5567ad
to
05b7a13
Compare
Changing the default would accommodate my use case, but might be a breaking change for users currently expecting k8s_file or wanting to use k8s_file on all containers. I'd still think keeping the global config option (with k8s_file as default to not break users) and having per container optional override would be the best of both. |
@sever-sever I have fixed the smoketest errors |
✅ No issues found in unused-imports check.. Please refer the workflow run |
@nvollmar I have added a migration script to remove the global log-driver option |
@opswill As said, I'd rather keep the global config option. I don't see a reason to remove that, does not block in any way a per-container option to override. |
CI integration ❌ failed! Details
|
I've followed your suggestions and made the code changes as much as possible. Regarding the global config, I disagree with keeping it. In my view, the current implementation already gives each container a default value, which effectively acts as a global config. So keeping a separate global config feels redundant. The only scenario where a global config might help reduce repetitive work is when running many containers on VyOS and needing to change the log driver in bulk. But changes still require a container manually restart to take effect. So this isn't really an issue for VyOS. You're welcome to describe your use case in more detail or provide further context. But since I'm mainly focused on fixing issues I've encountered while using VyOS, and I think the current implementation works fine, I'll keep this PR open. Let the VyOS maintainers decide whether to merge it or not. |
k8s_file is probably was most people will just use as default, and if you want to transfer logs remotely you'd set it up globally for journald. That's why I added the global configuration option in the first place. So far I don't really see a use case where I want to configure a different log_driver for each container. Making the log op command working when journald log driver is used is a good fix. I'm also not against having a per-container option, but I don't see a need or benefit to remove the global config option. I can also make a followup PR to add back the global option and make the per-container optional. |
Change summary
This PR introduces the following changes:
Refactored log-driver for conf mode containers: Refactored the log driver in conf mode containers to allow individual configuration per container. In addition to k8s-file and journald, a none option was added to disable logging.
Fixed op mode logging failures: fix the show/monitor commands failed to display journald logs.
When the container's log-driver is configured to journald, the commands show log container <container_name> and monitor log container <container_name> fail with the error message:
Current Configuration:
journald logs are able to retrieve and display:
run vyos op mode commands:
Types of changes
Related Task(s)
https://vyos.dev/T7473
Related PR(s)
How to test / Smoketest result
I built the vyos-1x deb package installed and tested it, and everything seems good.
smoketest result:
container with log-driver journald enabled
show logs:
monitor logs:
containers with log-driver k8s-file enabled
show logs:
monitor logs:
container with log-driver none:
Checklist: