Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/spaceone/plugin/manager/repository_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def check_plugin_version(
if version not in response.get("results", []):
raise ERROR_INVALID_PLUGIN_VERSION(plugin_id=plugin_id, version=version)

@cacheable(key="plugin-latest-version:{domain_id}:{plugin_id}", expire=600)
@cacheable(key="plugin-latest-version:{domain_id}:{plugin_id}", expire=300)
def get_plugin_latest_version(
self, plugin_id: str, domain_id: str, token: str
) -> Union[str, None]:
Expand Down
22 changes: 21 additions & 1 deletion src/spaceone/plugin/service/plugin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ def _select_endpoint(self, plugin_ref, updated_version=None):
f"[_select_endpoint] select endpoint. (index = {current_index}, endpoints = {endpoints})"
)

endpoint = endpoints[installed_plugin.current_index]
endpoint = self._get_current_index_endpoint(
endpoints, installed_plugin.current_index, installed_plugin.plugin_id
)

endpoint_info = {"endpoint": endpoint}

Expand Down Expand Up @@ -357,3 +359,21 @@ def verify(self, params: dict):
self.plugin_mgr.verify_plugin(
plugin_endpoint_info.get("endpoint"), api_class, options, secret_data
)

@staticmethod
def _get_current_index_endpoint(
endpoints: list, current_index: int, plugin_id: str
) -> str:
try:
return endpoints[current_index]
except IndexError:
randon_index = secrets.randbelow(len(endpoints))
_LOGGER.debug(
f"[_get_current_index_endpoint] current_index: {current_index}, randon_index: {randon_index}"
)
return endpoints[randon_index]
except Exception as e:
_LOGGER.error(
f"[_get_current_index_endpoint] plugin_id: {plugin_id}, endpoints: {endpoints}, current_index: {current_index}, error: {e}"
)
raise ERROR_PLUGIN_ENDPOINT_NOT_FOUND(plugin_id=plugin_id)
Loading