Repository: pantsbuild/pants

Issue:
[pantsd] don't fingerprint config-files or rc-files
Stu had a great thought earlier which was essentially that in order to avoid daemon lifecycle invalidation when the string values of  `--pants-config-files` or `--pantsrc-files` change, we should not fingerprint these (because their transitive inner values will already be considered during fingerprinting and may or may not be affected by pointing to a new config or rc filename).


Discussion:

Resolving patch:
diff --git a/src/python/pants/option/global_options.py b/src/python/pants/option/global_options.py
--- a/src/python/pants/option/global_options.py
+++ b/src/python/pants/option/global_options.py
@@ -106,7 +106,7 @@ def register_bootstrap_options(cls, register):
              help='The directory to use for tracking subprocess metadata, if any. This should '
                   'live outside of the dir used by `--pants-workdir` to allow for tracking '
                   'subprocesses that outlive the workdir data (e.g. `./pants server`).')
-    register('--pants-config-files', advanced=True, type=list,
+    register('--pants-config-files', advanced=True, type=list, daemon=False,
              default=[get_default_pants_config_file()], help='Paths to Pants config files.')
     # TODO: Deprecate the --pantsrc/--pantsrc-files options?  This would require being able
     # to set extra config file locations in an initial bootstrap config file.
@@ -116,7 +116,7 @@ def register_bootstrap_options(cls, register):
              help='A second config file, to override pants.ini.')
     register('--pantsrc', advanced=True, type=bool, default=True,
              help='Use pantsrc files.')
-    register('--pantsrc-files', advanced=True, type=list, metavar='<path>',
+    register('--pantsrc-files', advanced=True, type=list, metavar='<path>', daemon=False,
              default=['/etc/pantsrc', '~/.pants.rc'],
              help='Override config with values from these files. '
                   'Later files override earlier ones.')


Test patch:
diff --git a/tests/python/pants_test/pantsd/test_pantsd_integration.py b/tests/python/pants_test/pantsd/test_pantsd_integration.py
--- a/tests/python/pants_test/pantsd/test_pantsd_integration.py
+++ b/tests/python/pants_test/pantsd/test_pantsd_integration.py
@@ -18,6 +18,7 @@
 
 from pants.pantsd.process_manager import ProcessManager
 from pants.util.collections import combined_dict
+from pants.util.contextutil import temporary_dir
 from pants.util.dirutil import touch
 from pants_test.pants_run_integration_test import PantsRunIntegrationTest
 from pants_test.testutils.process_test_util import no_lingering_process_by_command
@@ -259,6 +260,33 @@ def test_pantsd_lifecycle_non_invalidation(self):
           self.assertEqual(last_pid, next_pid)
         last_pid = next_pid
 
+  def test_pantsd_lifecycle_non_invalidation_on_config_string(self):
+    with temporary_dir() as dist_dir_root, temporary_dir() as config_dir:
+      config_files = [
+        os.path.abspath(os.path.join(config_dir, 'pants.ini.{}'.format(i))) for i in range(2)
+      ]
+      for config_file in config_files:
+        print('writing {}'.format(config_file))
+        with open(config_file, 'wb') as fh:
+          fh.write('[GLOBAL]\npants_distdir: {}\n'.format(os.path.join(dist_dir_root, 'v1')))
+
+      invalidating_config = os.path.join(config_dir, 'pants.ini.invalidates')
+      with open(invalidating_config, 'wb') as fh:
+        fh.write('[GLOBAL]\npants_distdir: {}\n'.format(os.path.join(dist_dir_root, 'v2')))
+
+      with self.pantsd_successful_run_context() as (pantsd_run, checker, _):
+        variants = [['--pants-config-files={}'.format(f), 'help'] for f in config_files]
+        pantsd_pid = None
+        for cmd in itertools.chain(*itertools.repeat(variants, 2)):
+          pantsd_run(cmd)
+          if not pantsd_pid:
+            pantsd_pid = checker.await_pantsd()
+          else:
+            checker.assert_running()
+
+        pantsd_run(['--pants-config-files={}'.format(invalidating_config), 'help'])
+        self.assertNotEqual(pantsd_pid, checker.await_pantsd())
+
   def test_pantsd_stray_runners(self):
     # Allow env var overrides for local stress testing.
     attempts = int(os.environ.get('PANTS_TEST_PANTSD_STRESS_ATTEMPTS', 20))