Merge request's "updated" timestamp changes when you view it and it calculates if a one-click merge is possible. That shouldn't happen. Make sure no other operations incorrectly update the timestamp either.
This doesn't work for me. To test it properly you should disable caching inside def can_merge, like this:
+# if cached is not None:
+# return cached
This way task will be fired on every page hit.
I think to properly fix this we should set skip_mod_date == True in the beginning of the repo_tasks.can_merge and set it back to False in the end. Maybe it can even go inside set_can_merge_cache(), so that no matter from which place cache is updated it will not trigger mod_date update.
Also, we should consider adding context manager helper for this to the Allura, similar to one we use in SF internal code:
Traceback (most recent call last):
File "/home/ibondarenko/ibondarenko-1154/forge/Allura/allura/model/monq_model.py", line 260, in __call__
self.result = func(*self.args, **self.kwargs)
File "/home/ibondarenko/ibondarenko-1154/forge/Allura/allura/tasks/repo_tasks.py", line 174, in can_merge
mr.set_can_merge_cache(result)
File "/home/ibondarenko/ibondarenko-1154/forge/Allura/allura/model/repository.py", line 854, in set_can_merge_cache
with utils.skip_mod_date(self):
File "/usr/lib64/python2.7/contextlib.py", line 17, in __enter__
return self.gen.next()
File "/home/ibondarenko/ibondarenko-1154/forge/Allura/allura/lib/utils.py", line 623, in skip_mod_date
skip_mod_date = getattr(session(model_cls)._get(), 'skip_mod_date', False)
AttributeError: 'ODMSession' object has no attribute '_get'
Also, do we really need with skip_mod_date inside both can_merge task and set_can_merge_cache. It seems to me that skipping it just in set_can_merge_cache should be sufficient. Or repo.can_merge also modifies merge request objects somehow?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Also I think skip_mod_date only works when the changes are flushed, not when you are setting the values. If that's correct, we might need to set it directly and leave it (not context manager), or think of some other approach.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How do test_branches and test_tags fail for you? I saw them fail at Apache Jenkins also, but couldn't reproduce it locally. I thought maybe it was because I lowered the default cache threshold, and it was a timing thing. But I still couldn't reproduce it locally with a setting of 0 or -1.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Review at hs/7894
This doesn't work for me. To test it properly you should disable caching inside
def can_merge
, like this:This way task will be fired on every page hit.
I think to properly fix this we should set
skip_mod_date == True
in the beginning of therepo_tasks.can_merge
and set it back toFalse
in the end. Maybe it can even go insideset_can_merge_cache()
, so that no matter from which place cache is updated it will not triggermod_date
update.Also, we should consider adding context manager helper for this to the Allura, similar to one we use in SF internal code:
Ah, nice catch Igor, thanks.
Review at:
Allura hs/7894
Forge-classic hs/7894
I ended up moving skip_mod_date into Allura (allura.lib.utils).
I'm getting errors like this from the task
Also, do we really need
with skip_mod_date
inside bothcan_merge
task andset_can_merge_cache
. It seems to me that skipping it just inset_can_merge_cache
should be sufficient. Orrepo.can_merge
also modifies merge request objects somehow?Also I think
skip_mod_date
only works when the changes are flushed, not when you are setting the values. If that's correct, we might need to set it directly and leave it (not context manager), or think of some other approach.One option is flushing inside
set_can_merge_cache
, thus inside context managerforce-pushed to: hs/7894
I also added docstrings to
skip_mod_date
with some of the notes from this ticket.I've rebased on a new master and removed a couple of unused dependencies from previous commits. See
ib/7894
That works fine, but few tests are failing https://forge-allura.apache.org/p/allura/pastebin/5594fec86d19cd6b98fe5b42
test_branches
andtest_tags
are failing in master also :( There are one more test failure specific to this ticket, thoughHow do
test_branches
andtest_tags
fail for you? I saw them fail at Apache Jenkins also, but couldn't reproduce it locally. I thought maybe it was because I lowered the default cache threshold, and it was a timing thing. But I still couldn't reproduce it locally with a setting of 0 or -1.Individually they pass, they fail only when run using
./run-tests
or:Thanks. I've fixed the failures on master.
Force pushed to hs/7894
tests.model.test_repo.TestMergeRequest
are now passing.