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

Ssot snow delete function #263

Merged
merged 6 commits into from
Apr 16, 2024
Merged

Ssot snow delete function #263

merged 6 commits into from
Apr 16, 2024

Conversation

collin-wicker
Copy link
Contributor

Added delete functionality to ServiceNowCRUDMixin in models.py. Disabled cacheing functionality in models.py as it was causing unpredictable results when testing deleting records from ServiceNow. Tested this code with a ServiceNow personal development environment and everything worked as intended in the current format.

I was unsure as to whether the delete functionality should be available by default in the ServiceNow job but it is currently available by default. Please contact me with any questions/concerns.

@collin-wicker collin-wicker requested review from glennmatthews, qduk and a team as code owners November 2, 2023 20:14
@jdrew82 jdrew82 added type: minor feature integration: servicenow Issues originally from standalone ServiceNow SSoT repo labels Nov 2, 2023
Copy link
Contributor

@Kircheneer Kircheneer left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! It would probably be good if @glennmatthews could take a look as well

# description="Delete records from ServiceNow if not present in Nautobot",
# default=False,
# )
delete_records = BooleanVar(
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this used anywhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are several areas in the models.py file that use diffsync.job.logger.debug but I believe I defaulted the debug value to True in the jobs.py file when I was testing and must have forgotten to set it back to False.

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 have removed the "default=True" for the delete checkbox in the latest commits.

self.diffsync.objects_to_delete[self._modelname].append(_object)
print(self.diffsync.objects_to_delete[self._modelname])
super().delete()
except Exception as exception:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you narrow this exception down a little so its not a blanket except Exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After updating the code in the latest commit I don't believe a try/except clause is necessary here as I'm not having any issues with errors in my tests. I have eliminated this try/except clause in the latest commits.

if value is not None:
# Cacheing disabled as it was introducing instability and unpredictable results during delete method testing
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you figure out why this was the case? Can we possibly fix the cache mechanism instead? I reckon its existence is probably necessary for some bigger deployments. Also if we do decide to omit caching, can you delete the commented out code?

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 figured out what the issue with the caching functionality was and handled it in the new commits. Please review the newest commits for the changes.

Copy link
Contributor Author

@collin-wicker collin-wicker left a comment

Choose a reason for hiding this comment

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

Please review latest commits for requested changes and comments.

if value is not None:
# Cacheing disabled as it was introducing instability and unpredictable results during delete method testing
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 figured out what the issue with the caching functionality was and handled it in the new commits. Please review the newest commits for the changes.

self.diffsync.objects_to_delete[self._modelname].append(_object)
print(self.diffsync.objects_to_delete[self._modelname])
super().delete()
except Exception as exception:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

After updating the code in the latest commit I don't believe a try/except clause is necessary here as I'm not having any issues with errors in my tests. I have eliminated this try/except clause in the latest commits.

# description="Delete records from ServiceNow if not present in Nautobot",
# default=False,
# )
delete_records = BooleanVar(
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 have removed the "default=True" for the delete checkbox in the latest commits.

Copy link
Contributor

@jdrew82 jdrew82 left a comment

Choose a reason for hiding this comment

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

LGTM!

@jdrew82 jdrew82 merged commit 09e36c3 into nautobot:develop Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integration: servicenow Issues originally from standalone ServiceNow SSoT repo type: minor feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants