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

Feature rework install log processing #240

Merged
merged 81 commits into from
Jun 20, 2018
Merged

Conversation

sheagcraig
Copy link
Contributor

To keept his from being another giant one, let's call it here.

Unless someone has some Install.log entries to add to the test, the regex I wrote should grab all of the relevant data from a line and simplifies the processing.

This also adds some TZ info in a few different places so that Django doesn't complain about naive datetimes.

@sheagcraig
Copy link
Contributor Author

Also, I should add that this removes the assumption that base64 decoding will have to occur during report checkins for the main checkin view and the install log; but it still will base64 decode if called for. @grahamgilbert is going to update sal-scripts to only bz2 compress the reports.

base64 encoding results in a size gain of about 33%, plus the processing time, so this should be a minor improvement in checkin speed.

This adds the feature that UpdateHistory will create an initial item if
there isn't one to begin with. This may not indeed be the actual install
date, but we don't have that information anyway.
If an UpdateHistory is no longer a managed item (created every checkin
run from the Munki ManagedInstalls report), put it into a list for later
processing.

Then, for each of those, if it has no history items, delete it. Also, if
the most recent history item is older than our `HISTORICAL_DAYS`
setting, delete it.
@sheagcraig
Copy link
Contributor Author

Okay, done adding stuff. Please test and review!

To summarize, this PR updates the machine checkin procedure, both to address performance concerns, and to clean up code that has aged.

As suggested, Sal will generate UpdateHistoryItem entries from the ManagedInstallsReport.plist rather than the Install.log file. This removes all functional code from the server/install_log_hash and server/install_log_submit views (we'll need to update sal-scripts to skip this step next).

Several now-unused methods on the Machine model class have been removed.

The server/non_ui_views.py:checkin view has been reorganized and refactored to group like-operations together and take out all of the duplication.

PendingUpdates, PendingAppleUpdates, InstalledUpdates, UpdateHistory, and UpdateHistoryItem are all updated in a single function, which now does some cleanup and bookkeeping that didn't exist before.

If an UpdateHistory has been created, checkin will now create an initial UpdateHistoryItem with whichever entry in the report triggered the UpdateHistory creation.

If an UpdateHistory ever has zero UpdateHistoryItems associated with it at the end of this function, they will be removed. Likewise, items that no longer are considered ManagedInstalls and have not had an UpdateHistoryItem created since HISTORICAL_DAYS ago, the UpdateHistory will be deleted.

There's a little timezone fix for plugin data submissions to add a timezone if parsing the one submitted results in a naive datetime.

Checking for request method == POST now uses Django decorators.

Wherever possible, raw_delete and bulk_create have been used to speed up checkin.

@sheagcraig
Copy link
Contributor Author

Cool.

@grahamgilbert grahamgilbert merged commit 77a2e36 into master Jun 20, 2018
@grahamgilbert grahamgilbert deleted the feature_rework_checkin branch June 20, 2018 22:46
grahamgilbert added a commit that referenced this pull request Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants