Skip to content

Conversation

MontrealSergiy
Copy link
Contributor

resolves #1282

It maybe safer to recreate the symlink than touch, but I guess should work for us

@MontrealSergiy MontrealSergiy added Priority: Normal Admin Features or bugs related to administrative features labels Dec 20, 2023
@MontrealSergiy MontrealSergiy self-assigned this Dec 20, 2023
@MontrealSergiy MontrealSergiy changed the base branch from master to dev January 15, 2024 22:35
@MontrealSergiy MontrealSergiy changed the title touch cache, its link, md5 and id, resolves #1282 to prevent file cleaning, touch cache, its link, md5 and id, resolves #1282 Jan 15, 2024
Copy link
Member

@prioux prioux left a comment

Choose a reason for hiding this comment

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

Changes requested

@MontrealSergiy
Copy link
Contributor Author

I believe I added the requested changes

@prioux
Copy link
Member

prioux commented Mar 13, 2025

For the GridShare dir and the DP cache symlink, I'd rather both 'touch' commands to be run in the bourreau system check in a100_ensure_dp_cache_symlink_exists because this is the ideal place.

For the remaining three DataProvider cache files, the class method in DataProvider is fine as it is (minus the code moved to the place I talked about at the beginning of this comment).

@MontrealSergiy MontrealSergiy changed the base branch from dev to master March 13, 2025 18:59
Copy link
Member

@prioux prioux left a comment

Choose a reason for hiding this comment

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

See my two comments of today

Copy link
Member

@prioux prioux left a comment

Choose a reason for hiding this comment

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

See comments


sym_path = "#{gridshare_dir}/#{DataProvider::DP_CACHE_SYML}"
return if File.symlink?(sym_path) && File.realpath(sym_path) == File.realpath(cache_dir)
# update the work directory timestamp to counter cluster deletion policies
Copy link
Member

Choose a reason for hiding this comment

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

Why is this so complicated?!??

The original code's logic was:

return if symlink_is_ok
create symlink

The new code should simply be instead:

if symlink_is_ok
  touch symlink
  return
end
create symlink

But you did a complex set of conditions including checking the return status of system():

touch_but_not_create symlink
ret=system(touch symlink)
return if ret is 0 and symlink_is_ok
create_symlink

Why is make it so complicated?

Copy link
Contributor Author

@MontrealSergiy MontrealSergiy Mar 26, 2025

Choose a reason for hiding this comment

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

To make code work even if touch fails. But ok, can roll back that check.

# - the +DataProvider+ cache dir
# - the +DP_Cache_Key.md5+ and
# - +DP_Cache_Rev.id+ located in that cache dir
def self.system_touch
Copy link
Member

Choose a reason for hiding this comment

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

The method name system_touch is way too general. The method touches two special config files related to the cache subsystem. In general, in the DataProvider class, all methods that deal with the cache subsystem have "cache_" in their names. So please rename this

def self.touch_cache_md5

and place it after create_cache_md5 where it belongs.


# update timestamp for the symbolic link rather than the folder it points to
# --no-dereference works on most major os, otherwise link recreated below
link_updated = system("touch", "--no-dereference", sym_path)
Copy link
Member

@prioux prioux Mar 26, 2025

Choose a reason for hiding this comment

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

Adendum, --no-derefence doesn't work on Darwin.

The options -h works on both Darwin and Linux

sym_path = "#{gridshare_dir}/#{DataProvider::DP_CACHE_SYML}"
return if File.symlink?(sym_path) && File.realpath(sym_path) == File.realpath(cache_dir)
# update the work directory timestamp to counter cluster deletion policies
FileUtils.touch(gridshare_dir, verbose: true, nocreate: true)
Copy link
Member

Choose a reason for hiding this comment

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

Why did you leave the verbose and nocreate option there? Did you check the boot logs? I now see this crud:

C> Trying to see if there are any spurious task work directories...
C>      - No spurious task work directories detected.
C> Making sure the grid share directory has a symlink to the data provider cache...
touch -c /Users/prioux/LargeData/BourreauGridshare
C> Ensuring git commits for tasks classes are pre-cached...
C> Making sure the portal is forwarding a SSH agent to us...
C>      - Found a forwarded agent on SOCK=/tmp/ssh-8bZbwKlpmA/agent.13854

@prioux
Copy link
Member

prioux commented Mar 31, 2025

I am closing this PR without merging because it's taking too long with too many back and forth.

I replaced it with my own pull request, #1487 which shows how it's supposed to be done.

@prioux prioux closed this Mar 31, 2025
@MontrealSergiy
Copy link
Contributor Author

I didn’t realize you wanted to remove those as well. I used nocreate because the assignment was to update the timestamp, not to recreate folders. Additionally, I believe recreating the shared work could mask problems—it might allow the system to process new tasks but could obscure the need to restore all the other tasks.

As for the verbatim option, it provides more details in the logs. I probably didn’t check the log, but I wasn’t surprised by the results. I assumed it was more important to retain details, and I expected you to let me know if it was redundant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Admin Features or bugs related to administrative features Priority: Normal

Projects

None yet

Development

Successfully merging this pull request may close these issues.

At boot time, a CBRAIN app should touch() some filesystem config dirs and files

2 participants