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

Prt 40 periodic full system reconcile process #568

Merged
merged 28 commits into from
May 20, 2024

Conversation

miker985
Copy link
Contributor

Not a real PR yet - just trying to make sure we don't code the same things in different ways...

miker985 added 6 commits May 16, 2024 09:14
Add docstring to Role + MANGAER_ROLE constant
blacken models/shared_drive.py
Change SharedDrive.drive_id max_length (32 => 25; 19 is largest value)
Add SharedDrive.is_deleted
Add SharedDriveRecord.get_itbill_key_remote()


def load_shared_drives_from_csv(file_path):
def load_shared_drives(google_drive_states):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notable change: load_shared_drives management command is now loading from the MSCA endpoint and not a CSV file

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent!

shared_drive=shared_drive)
shared_drive=shared_drive,
defaults={
"datetime_created": dt.datetime.now(dt.timezone.utc),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeseibel Please confirm datetime_created is meant to refer to the creation of the SharedDriveRecord object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup!

try:
defaults["quota_limit"] = a.quota_limit
except ValueError:
"Drive has no quota set. Probably in invalid org unit."
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The expectation is this will get "fixed" during reconciliation, but it's a little awkward prior to our cutover when the majority of the share drives are in an OU with no quota

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should the placeholder for those cases be?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have to confer with Ken on that to see if there's a quota currently being enforced.

I'm aware of 3 OUs

  • the default UW one, where most drives are
  • one that follows a different naming scheme but appears to be compatible with a new "XXXGB" OU
  • the one for drives pending deletion

def __init__(self, *args, **kwargs):
columns = kwargs.get('columns', [])
row = kwargs.get('row', [])
def get_subscription(sdr: SharedDriveRecord):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mikeseibel this method prompted the PR as I think it's getting dangerously close to code you're writing and I'd really rather only write it once 😆

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to junk whats there. i just added it quick and dirty to import ken's early csv.

def reconcile_existing_drives(
self, drives, id_GoogleDriveState, subsidized_quota
):
# helper functions that probably need to be moved to a DAO file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ignore this function - I quickly put some stubs together but it's not even remotely complete

org_unit_name = models.CharField(max_length=64, null=True)
org_unit_name = models.CharField(
max_length=64, null=True
) # TODO: shouldn't this be non-NULL?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK to make this not-nullable?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

drive_id = models.SlugField(max_length=32)

# NOTE: maximum observed is 19 characters (2024-05-16)
drive_id = models.SlugField(max_length=25)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduced from 32 => 25 so that the new method get_itbill_key_remote() would never return a value <= length rquired by ITBillSubscription

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine... i didn't look too hard and felt like some fudge didn't hurt

"""
# if changing be sure this does not exceed the max_length of
# ITBillSubscription.key_remote
key_remote = f"prt_sd_{self.shared_drive.drive_id}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find any notes where we agreed on a prefix with the ITBill team. Do you have anything?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think they had any suggestion for key_remote aside from uniqueness since it's for our use. i think they suggested subscription name be something like GSD_<drive_id>

@coveralls
Copy link

coveralls commented May 20, 2024

Coverage Status

coverage: 77.811% (+1.7%) from 76.106%
when pulling c4aa5ea on PRT-40-periodic-full-system-reconcile-process
into b8e4e88 on develop.

@miker985 miker985 requested a review from mikeseibel May 20, 2024 16:45
org_unit_name = models.CharField(max_length=64, null=True)
org_unit_name = models.CharField(
max_length=64, null=True
) # TODO: shouldn't this be non-NULL?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure!

drive_id = models.SlugField(max_length=32)

# NOTE: maximum observed is 19 characters (2024-05-16)
drive_id = models.SlugField(max_length=25)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems fine... i didn't look too hard and felt like some fudge didn't hurt

"""
# if changing be sure this does not exceed the max_length of
# ITBillSubscription.key_remote
key_remote = f"prt_sd_{self.shared_drive.drive_id}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think they had any suggestion for key_remote aside from uniqueness since it's for our use. i think they suggested subscription name be something like GSD_<drive_id>



def load_shared_drives_from_csv(file_path):
def load_shared_drives(google_drive_states):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

excellent!

shared_drive=shared_drive)
shared_drive=shared_drive,
defaults={
"datetime_created": dt.datetime.now(dt.timezone.utc),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup!

try:
defaults["quota_limit"] = a.quota_limit
except ValueError:
"Drive has no quota set. Probably in invalid org unit."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what should the placeholder for those cases be?

def __init__(self, *args, **kwargs):
columns = kwargs.get('columns', [])
row = kwargs.get('row', [])
def get_subscription(sdr: SharedDriveRecord):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

feel free to junk whats there. i just added it quick and dirty to import ken's early csv.

@mikeseibel mikeseibel merged commit 9add29b into develop May 20, 2024
5 checks passed
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.

3 participants