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
Jenkins 13493 - Automatic git cache maintenance #1277
base: master
Are you sure you want to change the base?
Conversation
Thank You @MarkEWaite for fixing those tests. |
@@ -1253,6 +1274,7 @@ protected static File getCacheDir(String cacheEntry, boolean createDirectory) { | |||
if (!cacheDir.isDirectory()) { | |||
if (createDirectory) { | |||
boolean ok = cacheDir.mkdirs(); | |||
cacheEntries.add(cacheEntry); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this not add invalid cache directory entry to the static map?
cacheEntries.add(cacheEntry); | |
if (ok) { | |
cacheEntries.add(cacheEntry); | |
} else { | |
LOGGER.log(Level.WARNING, "Failed mkdirs of {0}", cacheDir); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed this issue. Thank You. My apologies for not observing it.
|
||
public static String checkSanity(String cron) throws ANTLRException { | ||
try { | ||
CronTab cronTab = new CronTab(cron.trim()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can the input string cron
ever be null? It could be a potential NPE.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cron string will not be null. If the user leave the text field blank in the UI, an empty string is passed to this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a NonNull annotation to declare to spotbugs that the argument should never be allowed to be null.
src/main/java/jenkins/plugins/git/maintenance/MaintenanceUI.java
Outdated
Show resolved
Hide resolved
src/main/java/jenkins/plugins/git/maintenance/MaintenanceUI.java
Outdated
Show resolved
Hide resolved
|
||
lock.lock(); | ||
LOGGER.log(Level.FINE, "Cache " + cacheFile.getName() + " locked."); | ||
executeMaintenanceTask(gitClient, taskType); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some concerns over this locking mechanism.
- running a git maintenance task can be time intensive, locking a thread while others are waiting to acquire the lock might increase the number of waiting threads (need to take a jvm thread dump to analyse and confirm this)
- we should try to reduce the scope of locking instead of locking the whole git maintenance process, i.e, identify the operations that need locking and only apply it conditionally
- another strategy to use locks, lock.tryLock(time interval). This allows the waiting threads to wait for a certain time and move on if the subjected lock to be acquired is not free.
|
||
List<Task> configuredTasks = config.getMaintenanceTasks(); | ||
addTasksToQueue(configuredTasks); | ||
// Option of Using the same thread for executing more maintenance task, or create a new thread the next minute and execute the maintenance task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting, would like to discuss this more in our weekly sync.
pom.xml
Outdated
<dependency> | ||
<groupId>com.thoughtworks.xstream</groupId> | ||
<artifactId>xstream</artifactId> | ||
<version>1.4.19</version> | ||
</dependency> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The xstream API is already provided by Jenkins core without requiring the inclusion of a dependency. This needs to be removed. It causes several additional transitive dependencies to be included that should not be in the git plugin.
<dependency> | |
<groupId>com.thoughtworks.xstream</groupId> | |
<artifactId>xstream</artifactId> | |
<version>1.4.19</version> | |
</dependency> |
|
||
public static String checkSanity(String cron) throws ANTLRException { | ||
try { | ||
CronTab cronTab = new CronTab(cron.trim()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a NonNull annotation to declare to spotbugs that the argument should never be allowed to be null.
src/main/java/jenkins/plugins/git/maintenance/MaintenanceUI.java
Outdated
Show resolved
Hide resolved
@@ -0,0 +1,3 @@ | |||
<div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@MarkEWaite needs to find the technique to add the help icon to the user interface. Users will expect to view help for the various maintenance commands.
@Hrushi20 it appears there are testing failing in the CI job that were not failing before. I'm on vacation and won't be able to investigate for several weeks. If you have time over the next few weeks, it would be very nice if you could investigate the test failures. |
Sure @MarkEWaite I'll look into it. Enjoy your vacation. |
Hello @MarkEWaite, I have gone through the failed tests. I realized that the below code is not creating a cache on the Jenkins controller.
Before I could access the caches, but now I am not able to create caches. Is there a way to create a MultibranchPipeline so that it handle creating the caches. |
Hello @MarkEWaite, can you help me fix these failing tests. The problem I am facing right now is that I am not able to create fake caches during tests. |
I won't be able to help with these tests until after I've completed the release of git client plugin 4.0.0 and git plugin 5.0.0. Those releases are getting all the time that I can allocate to the git plugin and git client plugin. |
Hey @MarkEWaite, incremental repack is failing. I'm getting task timeout error. Can you help me with that. I fixed all the other tests. Looking forward to getting this feature merged. |
remove unwanted test
Provided by Jenkins core, no need for a separate dependency. Cause several other transitive dependencies to be included unnecessarily.
Let spotbugs help with checks for null pointer exceptions
See CONTRIBUTING file for rationale
Provides maintenance API
Signed-off-by: Hrushi20 <hrushikesh20thegreat@gmail.com>
Signed-off-by: Hrushi20 <hrushikesh20thegreat@gmail.com>
Signed-off-by: Hrushi20 <hrushikesh20thegreat@gmail.com>
Signed-off-by: Hrushi20 <hrushikesh20thegreat@gmail.com>
2214dbc
to
c0ff128
Compare
Hey @MarkEWaite, I've fixed all the Unit test Issues. I ran a git rebase and the code is up to date with latest master. There are 2 spotbug issues, I am facing. Should I use the Spotbug flag to neglect such an issue? Looking forward to getting this merged. |
Hey @MarkEWaite, can we get this code merged? |
JENKINS-13493 - Automatic git cache maintenance
This PR adds git maintenance to the Jenkins controller to optimize the git caches on the controller.
Please refer to Project Page for reference and design:
https://www.jenkins.io/projects/gsoc/2022/projects/automatic-git-cache-maintenance/
Checklist
Types of changes