Ensure the bootstrap store has a padding length of zero (#38975)
Without this PR, padded length was propagating from user configuration to bootstrap configuration, and was causing the issue reported in #38963
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							f24f98a1e2
						
					
				
				
					commit
					14f3297cca
				
			@@ -155,13 +155,13 @@ def _ensure_bootstrap_configuration() -> Generator:
 | 
				
			|||||||
    with spack.environment.no_active_environment():
 | 
					    with spack.environment.no_active_environment():
 | 
				
			||||||
        with spack.platforms.prevent_cray_detection(), spack.platforms.use_platform(
 | 
					        with spack.platforms.prevent_cray_detection(), spack.platforms.use_platform(
 | 
				
			||||||
            spack.platforms.real_host()
 | 
					            spack.platforms.real_host()
 | 
				
			||||||
        ), spack.repo.use_repositories(spack.paths.packages_path), spack.store.use_store(
 | 
					        ), spack.repo.use_repositories(spack.paths.packages_path):
 | 
				
			||||||
            bootstrap_store_path
 | 
					 | 
				
			||||||
        ):
 | 
					 | 
				
			||||||
            # Default configuration scopes excluding command line
 | 
					            # Default configuration scopes excluding command line
 | 
				
			||||||
            # and builtin but accounting for platform specific scopes
 | 
					            # and builtin but accounting for platform specific scopes
 | 
				
			||||||
            config_scopes = _bootstrap_config_scopes()
 | 
					            config_scopes = _bootstrap_config_scopes()
 | 
				
			||||||
            with spack.config.use_configuration(*config_scopes):
 | 
					            with spack.config.use_configuration(*config_scopes), spack.store.use_store(
 | 
				
			||||||
 | 
					                bootstrap_store_path, extra_data={"padded_length": 0}
 | 
				
			||||||
 | 
					            ):
 | 
				
			||||||
                # We may need to compile code from sources, so ensure we
 | 
					                # We may need to compile code from sources, so ensure we
 | 
				
			||||||
                # have compilers for the current platform
 | 
					                # have compilers for the current platform
 | 
				
			||||||
                _add_compilers_if_missing()
 | 
					                _add_compilers_if_missing()
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,20 +22,29 @@ def active_mock_environment(mutable_config, mutable_mock_env_path):
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
@pytest.mark.regression("22294")
 | 
					@pytest.mark.regression("22294")
 | 
				
			||||||
def test_store_is_restored_correctly_after_bootstrap(mutable_config, tmpdir):
 | 
					def test_store_is_restored_correctly_after_bootstrap(mutable_config, tmpdir):
 | 
				
			||||||
    # Prepare a custom store path. This should be in a writeable location
 | 
					    """Tests that the store is correctly swapped during bootstrapping, and restored afterward."""
 | 
				
			||||||
    # since Spack needs to initialize the DB.
 | 
					 | 
				
			||||||
    user_path = str(tmpdir.join("store"))
 | 
					    user_path = str(tmpdir.join("store"))
 | 
				
			||||||
    # Reassign global variables in spack.store to the value
 | 
					    with spack.store.use_store(user_path):
 | 
				
			||||||
    # they would have at Spack startup.
 | 
					        assert spack.store.root == user_path
 | 
				
			||||||
    spack.store.reinitialize()
 | 
					        assert spack.config.config.get("config:install_tree:root") == user_path
 | 
				
			||||||
    # Set the custom user path
 | 
					        with spack.bootstrap.ensure_bootstrap_configuration():
 | 
				
			||||||
    spack.config.set("config:install_tree:root", user_path)
 | 
					            assert spack.store.root == spack.bootstrap.config.store_path()
 | 
				
			||||||
 | 
					        assert spack.store.root == user_path
 | 
				
			||||||
 | 
					        assert spack.config.config.get("config:install_tree:root") == user_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    # Test that within the context manager we use the bootstrap store
 | 
					
 | 
				
			||||||
    # and that outside we restore the correct location
 | 
					@pytest.mark.regression("38963")
 | 
				
			||||||
    with spack.bootstrap.ensure_bootstrap_configuration():
 | 
					def test_store_padding_length_is_zero_during_bootstrapping(mutable_config, tmpdir):
 | 
				
			||||||
        assert spack.store.root == spack.bootstrap.config.store_path()
 | 
					    """Tests that, even though padded length is set in user config, the bootstrap store maintains
 | 
				
			||||||
    assert spack.store.root == user_path
 | 
					    a padded length of zero.
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    user_path = str(tmpdir.join("store"))
 | 
				
			||||||
 | 
					    with spack.store.use_store(user_path, extra_data={"padded_length": 512}):
 | 
				
			||||||
 | 
					        assert spack.config.config.get("config:install_tree:padded_length") == 512
 | 
				
			||||||
 | 
					        with spack.bootstrap.ensure_bootstrap_configuration():
 | 
				
			||||||
 | 
					            assert spack.store.root == spack.bootstrap.config.store_path()
 | 
				
			||||||
 | 
					            assert spack.config.config.get("config:install_tree:padded_length") == 0
 | 
				
			||||||
 | 
					        assert spack.config.config.get("config:install_tree:padded_length") == 512
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@pytest.mark.parametrize(
 | 
					@pytest.mark.parametrize(
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -15,6 +15,7 @@ spack:
 | 
				
			|||||||
  config:
 | 
					  config:
 | 
				
			||||||
    install_tree:
 | 
					    install_tree:
 | 
				
			||||||
      root: {{ store_path }}
 | 
					      root: {{ store_path }}
 | 
				
			||||||
 | 
					      padded_length: 0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  packages:
 | 
					  packages:
 | 
				
			||||||
    python:
 | 
					    python:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user