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/add ingestion cron #36

Merged
merged 5 commits into from
Mar 6, 2024
Merged

Feature/add ingestion cron #36

merged 5 commits into from
Mar 6, 2024

Conversation

samleeflang
Copy link
Collaborator

@samleeflang samleeflang commented Feb 27, 2024

Added functionality to the source system endpoint.
When a new SourceSystem is added:

  • It will create a new CronJob on the cluster
  • It will trigger a new Job on the cluster (starting ingestion immediatly)

On update:

  • It will update the CronJob

On delete:

  • Delete the CronJob

Additional endpoint to schedule an extra run of the job.
Upgraded kubernetes library which impacted MAS code.
Large update of all libs.
Removed old/deprecated translator code.

@samleeflang samleeflang requested a review from southeo February 27, 2024 10:24
@samleeflang
Copy link
Collaborator Author

Getting a bit nuts about this condition coverage.
I am not sure if adding tests will actually add anything other then trying to make the condition coverage bar.
Anyway, will take another look this afternoon / tomorrow to see if I can add something

Copy link
Contributor

@southeo southeo left a comment

Choose a reason for hiding this comment

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

💼 looking good, this will be really useful

}

private static String generateJobName(SourceSystemRecord sourceSystem, boolean isCron) {
var name = sourceSystem.sourceSystem().translatorType().name().toLowerCase() + "-" + getSuffix(
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't find a name() function in translatorType. The function getName() returns the constant "translator_type". Is it possible you want to use translatorType().getLiteral() instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The name function is available by default for enums. It just returns the name of the enum as a string. So in this case it will be the same as the literal. Changed it to the literal, as that might be better understandable.

Copy link
Contributor

Choose a reason for hiding this comment

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

didn't know that about enums! Either function should be good

}
}

private void createTranslatorJob(SourceSystemRecord sourceSystemRecord, boolean rollback)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just semantics, but calling this argument "rollback" says to me, "rollback whatever was created". Maybe call it "rollbackOnFailure" or something a bit more clear

@@ -98,12 +193,35 @@ public JsonApiWrapper updateSourceSystem(String id, SourceSystem sourceSystem, S
var sourceSystemRecord = new SourceSystemRecord(id, currentSourceSystem.version() + 1, userId,
Instant.now(), null, sourceSystem);
repository.updateSourceSystem(sourceSystemRecord);
updateCronJob(sourceSystemRecord, currentSourceSystem);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also re-run ingestion, like we do on creation of a source system?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair point, I was doubting about this. However, when you do a minor change in, I don't know the description, it might not be necessary. You can now always trigger it separately as well through the run endpoint.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we include this in the request? A user can check a box that says "re-run ingestion on update"? Then pass that boolean to this function.

Can be a separate user story.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

💯 But in a new user story https://naturalis.atlassian.net/browse/DD-1031

@samleeflang samleeflang requested a review from southeo March 6, 2024 08:00
Copy link

sonarqubecloud bot commented Mar 6, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
73.08% Condition Coverage on New Code (required ≥ 80%)

See analysis details on SonarCloud

Copy link
Contributor

@southeo southeo left a comment

Choose a reason for hiding this comment

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

🏑

@samleeflang samleeflang merged commit 001bd97 into main Mar 6, 2024
1 of 2 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.

2 participants