-
Notifications
You must be signed in to change notification settings - Fork 171
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
Fix harvest migration message logging for batched migrations #2842
Fix harvest migration message logging for batched migrations #2842
Conversation
…ge of context - Can't store migration object in context since they have PDO connection active. Store the logID instead.
@janette Had another go at this and caught some cases where it did not really fix the problem. The The trick is to add the |
…arvest Log instead of the UI. Update the HarvestMigrate class to reduce as much as possible the use of HarvestMigrate::displayMessage(). Leverage the messages queue to defer saveing messages to log until with have a usable migrate log id. BREAKING CHANGE: HarvestMigration::prepareMetadataSourceHelper() and HarvestMigration::prepareResourceHelper() return value changed to be an array ($status, $object) instead of False or Object. This is done to be able to return errors from those static functions to the calling method and save them to the message log. All the overriding classes may need to be updated. To migrate the code follow the example below: Before: - When the helper funcion failed: ``` self::displayMessage($message, 'error'); return FALSE; ``` - When the helper function succeded ``` return $resource; ``` After: - When the helper funcion failed: ``` return array(FALSE, $message); ``` - When the helper function succeded ``` return array(TRUE, $resource); ```
@janette commit c44ef54 is my take on #2819 that I mentioned on Slack. I had to update the *Helper function signature to return the message to the caller method and report it. There is also the messages queue mechanism implemented by the I used the https://open.fda.gov/data.json source to test, and all the messages reported by the migration process are saved to the log table instead of being rendered on on the UI. The remaining messages are not from |
@rhabbachi this is great stuff here, and I think you are right let's not deal with the datastore messages on this one, we can make some adjustments on the datastore separately. I'm concerned that the harvest status says 'ERROR', because the harvest does complete, but has errors on the resources. How hard would it be to add a column for 'Errors', so the status could still say 'OK' once the harvest completes, and the error column would be 'yes or no' and if yes, the yes is a link to the log. And I'm guessing the phpunit tests need updating. :) |
@rhabbachi what if we scratch my additional column idea and instead under status it would list one of these:
|
@janette Yeah I like the 2nd suggestion better. Was out of commission as I just finished migrating to a new work machine. Planning on taking a look later today. |
…for harvest dashboard
@janette Still work in progress but this is the direction I'm taking for the status. The gist is that we are outgrowing the boolean View field handler The "failed" is not well supported, I will do more testing on this later next week. |
@rhabbachi right maybe 'failed' is not quite right, I think 'N/A' is what we get now? something to indicate it is not finished I guess, 'in progress' or 'stuck' .... staying with 'N/A' would be fine if we create a new ticket to work out the finer points of the status. Really appreciate your work on this. |
@janette Alright progress! I added a test to see if all the datasets tracked failed (count of the datasets recorded in the map table against the failed count), if all the datasets failed the import then the status is shown as.. failed.. This should work well when the source is lost or have problems. I also added the "New" status for harvest migrations that were not executed before (no MLID). Also to me 'N/A' sounded either new or unknown, since we support both now I dropped it from the returned status. Interestingly, we can't really know if a Migration is stuck, it's either in progress or idle. I guess that should be left to the user's judgement (been showing as in progress for 3 days for example). So to summarize:
How does that sound? Also any idea about the color coding? 😄 |
@rhabbachi sounds fantastic - very informative status values 😄 |
…ard status * Add support for "Replacement Patterns" to the harvest status custom field handler.
@janette had to add a views token to the custom handler to have reliable css classes to target. But it should be working now! Unfortunately I don't know have access to sources that will reproduce the other status, do you have examples that you test this? |
Hi @rhabbachi,
At the end that code isn't really needed as we are checking later in the process for the existence of the harvest source and the user still get the message |
Hey @dharizza! Off the top of my head. I think the What are the other errors that you found? From the screenshot in my previous comment I got a multiple suspect |
Yes, but comparing with the results from 7.x-1.x they are legit, and it is fine for them to be there according to the test files we are using. The differences are really on the
And later in the code, we use that to tell the user there wasn't a source, so I think it is fine if we just get rid of it. I run the php unit tests with that change locally and they all passed, also did some manual testing and it worked ok. Now, this part is just a theory: I'm not sure if this is related to the movement of |
I see. This change:
Should've replaced this snipped.
When the 7.x-1.x was merged into this branch. But since I introduced the change at Your reasoning is correct @dharizza IMO! Thanks for spotting the subtle change! |
Ah wait! Seems like it was not deleted from the 7.x-1.x actually https://github.com/GetDKAN/dkan/blob/7.x-1.x/modules/dkan/dkan_harvest/dkan_harvest.migrate.inc#L131 |
… + phpunit test updates Using the HarvestMigration::reportMessage will add new entries to the log. Update unit tests accordingly.
Fix harvest migration message logging for batched migrations
Fix harvest migration message logging for batched migrations
Message (including various types like info, warning, error) logging during harvest migrations broke after the introduction of the "batched" migrations #2075. The logID is generated too late during the process and the messages were not being assigned to the migration being ran. This affected the "Errors" tab for the Harvest Source as all the errors gathered for a said source are stacked and displayed without any association with the Harvest Migration event.
(fig. 1)
This PR updates the HarvestMigration class and the harvest batch function to restore the migration logID generation and presist the
migration
object during batch calls.(fig. 2)
How to reproduce
DKAN Harvest Dashboard
, trigger the batch cache and migrate of the added source multiple timesExpected:
Errors grouped per harvest event (listed on the "Events" tab). See fig. 2.
Actual
Errors stacked under the same 01/01/1970 entry. regardless of the Harvest Migration events. See fig. 1.
Merge process
Reminders