Commit ecf144ee authored by Rafael Monnerat's avatar Rafael Monnerat

runner: Fix symlinks on softwareLink

   The generation of the link and the verification were inconsistent, this commit
   normalize both.

   PS.: Software Links are deprecated, it should be removed in future, as it lost
   the goals
parent 6cba6d95
Pipeline #8972 failed with stage
in 0 seconds
......@@ -352,10 +352,8 @@ def config_SR_folder(config):
cf.write(current_project + '#' + folder)
# First create the link for current project
with open(os.path.join(config['etc_dir'], ".project")) as f:
current_project = f.read().strip().rstrip('/')
profile = getCurrentSoftwareReleaseProfile(config)
name = current_project.split('/')[-1]
name = getSoftwareReleaseName(config)
md5sum = md5digest(profile)
link_to_folder(name, md5sum)
# check other links
......@@ -656,7 +654,9 @@ def getSoftwareReleaseName(config):
sr_profile = os.path.join(config['etc_dir'], ".project")
if os.path.exists(sr_profile):
with open(sr_profile, "r") as f:
project = f.read().split("/")
project = f.read().strip().rstrip().split("/")
# we always use the suffix workspace, so this is the intention
# behind this method, get the checkout.
software = project[-2]
return software.replace(' ', '_')
return None
......@@ -853,8 +853,8 @@ def isSoftwareReleaseCompleted(config):
software_name = getSoftwareReleaseName(config)
if software_name is None:
return False
elif os.path.exists(os.path.join(config['runner_workdir'],
'softwareLink', software_name, '.completed')):
elif os.path.exists(os.path.join(config['software_link'],
software_name, '.completed')):
return True
else:
return False
......
......@@ -208,7 +208,7 @@ class TestRunnerBackEnd(unittest.TestCase):
# First tests that if the current instance doesn't extend the Software
# Release to delete, the instance isn't deleted
runner_utils.open = mock.mock_open(read_data="/workspace/software/another/")
runner_utils.open = mock.mock_open(read_data="/workspace/my_project/software/another/")
runner_utils.removeSoftwareByName(config, '1234567890', 'my_software_name')
self.assertFalse(mock_removeCurrentInstance.called)
......@@ -218,7 +218,7 @@ class TestRunnerBackEnd(unittest.TestCase):
# be removed
mock_removeSoftwareRootDirectory.reset_mock()
runner_utils.open = mock.mock_open(read_data="/workspace/software/my_software_name/")
runner_utils.open = mock.mock_open(read_data="/workspace/my_project/software/my_software_name/")
runner_utils.removeSoftwareByName(config, '1234567890', 'my_software_name')
self.assertTrue(mock_removeCurrentInstance.called)
......
  • @rafael , @jerome

    Jerôme told me he found this in gunicorn log :

    ==> inst/s0/.s0_gunicorn-7ed58af4f9430517becda13470abc64b.log <==
    Unhandled exception in thread started by <function runSlapgridUntilSuccess at 0x7fc28a837d50>
    Traceback (most recent call last):
      File "/srv/slapgrid/slappart9/srv/testnode/czp/inst/test0-0/tmp/soft/8be16c39f805436135ea96f4b6ba8368/parts/slapos.toolbox-repository/slapos/runner/utils.py", line 992, in runSlapgridUntilSuccess
        slapgrid = runSlapgridWithLock(config, lock=True)
      File "/srv/slapgrid/slappart9/srv/testnode/czp/inst/test0-0/tmp/soft/8be16c39f805436135ea96f4b6ba8368/parts/slapos.toolbox-repository/slapos/runner/utils.py", line 390, in runSoftwareWithLock
        return runSlapgridWithLock(config, 'software', 'slapgrid-sr', lock)
      File "/srv/slapgrid/slappart9/srv/testnode/czp/inst/test0-0/tmp/soft/8be16c39f805436135ea96f4b6ba8368/parts/slapos.toolbox-repository/slapos/runner/utils.py", line 379, in runSlapgridWithLock
        config_SR_folder(config)
      File "/srv/slapgrid/slappart9/srv/testnode/czp/inst/test0-0/tmp/soft/8be16c39f805436135ea96f4b6ba8368/parts/slapos.toolbox-repository/slapos/runner/utils.py", line 422, in config_SR_folder
        link_to_folder(name, md5sum)
      File "/srv/slapgrid/slappart9/srv/testnode/czp/inst/test0-0/tmp/soft/8be16c39f805436135ea96f4b6ba8368/parts/slapos.toolbox-repository/slapos/runner/utils.py", line 416, in link_to_folder
        cf.write(current_project + '#' + folder)

    It seems this commit removes the allocation to current_project :

    -  with open(os.path.join(config['etc_dir'], ".project")) as f:
    -    current_project = f.read().strip().rstrip('/')

    but current_project is retrieved in an ugly way (not you, it was there before) by the inner function link_to_folder. which now fails.

  • I will debug this to see, but which tests are those that are running? and why assertions don't fail?

  • I saw this when looking in instance logs when slaprunner test was running

  • mentioned in commit 1a348526

    Toggle commit list
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment