-
Notifications
You must be signed in to change notification settings - Fork 85
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
OCPBUGS-50476: v2/cli: always stop local registry and close registry.log #1068
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: r4f4 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
if o.registryLogFile != nil { | ||
// NOTE: we cannot just close the registry.log file as it is set as logrus output, which could still be in use | ||
// by other dependencies before we exit. First we need to make sure logrus uses a different output. | ||
logrus.SetOutput(io.Discard) |
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.
@r4f4 - good one, this has been a lingering problem
@r4f4 - Thanks for this update, improves our user experience and proper shutdown of the local registry and logs |
The local registry was not being gracefully shutdown and in some cases the `registry.log` file was closed while `logrus` was still trying to write to it: ``` 2025/02/05 21:50:45 [INFO] : mirror time : 29.768175677s 2025/02/05 21:50:45 [INFO] : 👋 Goodbye, thank you for using oc-mirror Failed to write to log, write /oc-mirror-issue-ret/working-dir/logs/registry.log: file already closed Failed to write to log, write /oc-mirror-issue-ret/working-dir/logs/registry.log: file already closed Failed to write to log, write /oc-mirror-issue-ret/working-dir/logs/registry.log: file already closed Failed to write to log, write /oc-mirror-issue-ret/working-dir/logs/registry.log: file already closed Failed to write to log, write /oc-mirror-issue-ret/working-dir/logs/registry.log: file already closed ```
4217ffa
to
25f0600
Compare
Update: fixed unit tests. |
/retitle OCPBUGS-50476: v2/cli: always stop local registry and close registry.log |
@r4f4: This pull request references Jira Issue OCPBUGS-50476, which is invalid:
Comment The bug has been updated to refer to the pull request using the external bug tracker. In response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
/jira refresh |
@r4f4: This pull request references Jira Issue OCPBUGS-50476, which is valid. The bug has been moved to the POST state. 3 validation(s) were run on this bug
Requesting review from QA contact: In response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
/test e2e |
@r4f4: all tests passed! Full PR test history. Your PR dashboard. 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. |
// stopLocalRegistry - stops the local registry and closes the registry.log file | ||
func (o *ExecutorSchema) stopLocalRegistry(ctx context.Context) { | ||
// Try to gracefully shutdown the local registry | ||
ctx, cancel := context.WithTimeout(ctx, time.Second) |
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.
@r4f4 - +1 using context
Verified locally using m2d d2m & m2m |
/lgtm |
@r4f4 - I will wait for QE before adding the correct labels |
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.
Thanks @r4f4, a lot of good improvements.
I left only one comment, please let me know if you have questions about it.
interruptSig := NormalStorageInterruptErrorf("end of mirroring to disk. Stopping local storage to prepare the archive") | ||
o.localStorageInterruptChannel <- interruptSig |
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.
The tar ball generated in the end of m2d is the data under ~/.oc-mirror/.cache. Since this data is used by the local registry running on top of oc-mirror cache, to avoid data corruption, it is better to stop the local registry before starting the preparation of the tarball.
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.
Notice that the previous interrupt was not stopping the registry. But I can add the logic here. So this is only needed for the Mirror2Disk workflow, right?
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.
Actually it seems we cannot stop the registry as the blob collector for the tarball still accesses the registry: https://github.com/openshift/oc-mirror/blob/main/v2/internal/pkg/archive/image-blob-gatherer.go#L24
2025/02/11 15:12:20 [INFO] : === Results ===
2025/02/11 15:12:20 [INFO] : ✓ 193 / 193 release images mirrored successfully
2025/02/11 15:12:20 [INFO] : 📦 Preparing the tarball archive...
2025/02/11 15:12:24 [WARN] : Close registry.log failed: close /prjs/mirrors/oc-mirror-ocpbugs-49990/data/working-dir/logs/registry.log: file already closed
2025/02/11 15:12:24 [INFO] : 👋 Goodbye, thank you for using oc-mirror
2025/02/11 15:12:24 [ERROR] : unable to add image blobs to the archive : unable to find blobs corresponding to docker://localhost:55000/openshift/release:4.16.1-x86_64-ovirt-machine-controllers: pinging container registry localhost:55000: Get "http://localhost:55000/v2/": dial tcp [::1]:55000: connect: connection refused
Description
The local registry was not being gracefully shutdown and in some cases the
registry.log
file was closed whilelogrus
was still trying to write to it:Github / Jira issue:
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration.
Expected Outcome
Please describe the outcome expected from the tests.