Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#7297 fix config install when scheduled #7311

Merged
merged 4 commits into from Jul 7, 2020

Conversation

uilianries
Copy link
Member

@uilianries uilianries commented Jul 3, 2020

There was a bug which considered config install as command which was able to trigger a new config command when the scheduler was ready.

This PR won't prevent the error when the remote git has been removed and it's listed as config remote, the scheduler will continue to fail. However, you will be able to run conan config install -r 0, or any conan config install xxx without problem now.

Changelog: Fix: Conan config install does not trigger scheduled config command.
Docs: Omit

Fixes: #7297

/cc @michaelmaguire @memsharded

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop branch, documenting this one.

Note: By default this PR will skip the slower tests and will use a limited set of python versions. Check here how to increase the testing level by writing some tags in the current PR body text.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@@ -2045,7 +2045,7 @@ def run(self, *args):
raise ConanException("Unknown command %s" % str(exc))

if is_config_install_scheduled(self._conan) and \
(command != "config" or (command == "config" and args[0] != "install")):
(command != "config" or (command == "config" and args[0][1] != "install")):
Copy link
Member Author

@uilianries uilianries Jul 3, 2020

Choose a reason for hiding this comment

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

args now is a tuple with a list ([]) that's why config install triggered the scheduler ...

self.assertIn("Repo cloned!", self.client.out)
shutil.rmtree(self.folder)
with patch("conans.client.command.is_config_install_scheduled", return_value=True):
self.client.run("config --help", assert_error=True)
Copy link
Member

@memsharded memsharded Jul 5, 2020

Choose a reason for hiding this comment

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

Please test that you can actually conan config install --remove the offending config, and then after that next scheduled call will succeed.

Copy link
Member Author

@uilianries uilianries Jul 5, 2020

Choose a reason for hiding this comment

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

that's a good test case

@memsharded memsharded added this to the 1.28 milestone Jul 5, 2020
Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries uilianries marked this pull request as draft Jul 6, 2020
now = datetime.now(gettz())
return now > sched
else:
api.out.warn("Skipping scheduled config install, "
Copy link
Member

@memsharded memsharded Jul 6, 2020

Choose a reason for hiding this comment

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

I would say that if it is empty, it would keep warning this all the time, at every invocation?

Copy link
Member Author

@uilianries uilianries Jul 6, 2020

Choose a reason for hiding this comment

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

I've reformulated the idea. It will warn the user, but only when scheduled, not for every new command.

now = datetime.now(gettz())
return now > sched
if _load_configs(config_install_file):
timestamp = os.path.getmtime(config_install_file)
Copy link
Member

@memsharded memsharded Jul 6, 2020

Choose a reason for hiding this comment

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

This should happen always, what if there is one broken one not removed?

Copy link
Member Author

@uilianries uilianries Jul 6, 2020

Choose a reason for hiding this comment

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

The scheduler only checks if the task is scheduled and if a config is there, doesn't matter if it's broken or not. The method configuration_install (at same file) is the judge, it will consume the configs file.

I believe the scheduler should be stupid, only run a task if available and the interval passed. Otherwise, it will need to "steal" the configuration_install action too.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries uilianries marked this pull request as ready for review Jul 6, 2020
@@ -2044,8 +2044,8 @@ def run(self, *args):
self._print_similar(command)
raise ConanException("Unknown command %s" % str(exc))

if is_config_install_scheduled(self._conan) and \
(command != "config" or (command == "config" and args[0] != "install")):
if (command != "config" or (command == "config" and args[0][1] != "install")) and \
Copy link
Member Author

@uilianries uilianries Jul 6, 2020

Choose a reason for hiding this comment

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

now it complete ignores the scheduler if running config install

@@ -258,10 +262,25 @@ def configuration_install(app, uri, verify_ssl, config_type=None,
_save_configs(configs_file, configs)


def _is_scheduled_intervals(file, interval):
Copy link
Member Author

@uilianries uilianries Jul 6, 2020

Choose a reason for hiding this comment

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

I moved to here for better simplification, and be able to mock in functional tests.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries
Copy link
Member Author

@uilianries uilianries commented Jul 6, 2020

@memsharded I reformulated this PR 30 minutes ago, I think it looks better now, including the logic.

czoido
czoido approved these changes Jul 7, 2020
@czoido czoido merged commit a15701f into conan-io:develop Jul 7, 2020
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants