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

fix(api/category): plugin init_settings add more detail in log info #422

Merged

Conversation

wklken
Copy link
Collaborator

@wklken wklken commented May 10, 2022

No description provided.

@wklken
Copy link
Collaborator Author

wklken commented May 10, 2022

数据库中存在错误数据导致无法更新, 无法第一时间排查到是哪个key有问题(涉及两张表, 存在关系)

before

ERROR [2022-05-10 16:29:42] 48 import_plugins 6 140263422788096 
⚠️ failed to import plugin: path[bkuser_core.categories.plugins.mad] 
Traceback (most recent call last):
  File "/app/bkuser_core/categories/apps.py", line 46, in import_plugins
    importlib.import_module(module_path)
  File "/app/.heroku/python/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/app/bkuser_core/categories/plugins/mad/__init__.py", line 24, in <module>
    settings_path=os.path.dirname(__file__) / Path("settings.yaml"),
  File "/app/bkuser_core/categories/plugins/plugin.py", line 71, in register
    self.load_settings_from_yaml()
  File "/app/bkuser_core/categories/plugins/plugin.py", line 112, in load_settings_from_yaml
    self.init_settings(key, meta_info)
  File "/app/bkuser_core/categories/plugins/plugin.py", line 103, in init_settings
    meta=meta, category_id=category.id, defaults={"value": meta.default}
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 581, in get_or_create
    return self.get(**kwargs), False
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 442, in get
    num if not limit or num < limit else 'more than %s' % (limit - 1),
bkuser_core.user_settings.models.Setting.MultipleObjectsReturned: get() returned more than one Setting -- it returned 2!

after

ERROR [2022-05-10 17:14:55] 113 init_settings 6 139852856115712 
Setting default of meta<base_dn-connection-mad>, category_id<2>, defaults<> can not been created. 
Traceback (most recent call last):
  File "/app/bkuser_core/categories/plugins/plugin.py", line 104, in init_settings
    meta=meta, category_id=category.id, defaults={"value": meta.default}
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 581, in get_or_create
    return self.get(**kwargs), False
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 442, in get
    num if not limit or num < limit else 'more than %s' % (limit - 1),
bkuser_core.user_settings.models.Setting.MultipleObjectsReturned: get() returned more than one Setting -- it returned 2!

@wklken wklken merged commit 83b1d8a into TencentBlueKing:development May 11, 2022
This was referenced May 11, 2022
@wklken wklken mentioned this pull request Jul 28, 2022
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.

1 participant