Skip to content

#7297 fix config install when scheduled - #7311

Merged
czoido merged 4 commits into
conan-io:developfrom
uilianries:hotfix/catch-22
Jul 7, 2020
Merged

czoido merged 4 commits into
conan-io:developfrom
uilianries:hotfix/catch-22

Conversation

@uilianries

@uilianries uilianries commented Jul 3, 2020

Copy link
Copy Markdown
Member

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>
Comment thread conans/client/command.py Outdated

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")):

@uilianries uilianries Jul 3, 2020

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member

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
Copy Markdown
Member Author

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 July 6, 2020 12:55
Comment thread conans/client/conf/config_installer.py Outdated
now = datetime.now(gettz())
return now > sched
else:
api.out.warn("Skipping scheduled config install, "

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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.

Comment thread conans/client/conf/config_installer.py Outdated
now = datetime.now(gettz())
return now > sched
if _load_configs(config_install_file):
timestamp = os.path.getmtime(config_install_file)

Copy link
Copy Markdown
Member

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
Copy Markdown
Member Author

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 July 6, 2020 14:31
Comment thread conans/client/command.py Outdated

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 \

@uilianries uilianries Jul 6, 2020

Copy link
Copy Markdown
Member Author

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

_save_configs(configs_file, configs)


def _is_scheduled_intervals(file, interval):

Copy link
Copy Markdown
Member Author

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
Copy Markdown
Member Author

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

@czoido
czoido merged commit a15701f into conan-io:develop Jul 7, 2020
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.

[bug] Automated config update exception needed for conan config install commands to prevent catch-22

3 participants