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

Switches plugin reporting to use Django name #1102

Merged
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
23 changes: 16 additions & 7 deletions .ci/ansible/start_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,22 @@
command: "docker logs pulp"
failed_when: true

- name: "Check version of component being tested"
assert:
that:
- (result.json.versions | items2dict(key_name="component", value_name="version"))[component_name] | canonical_semver == (component_version | canonical_semver)
fail_msg: |
Component {{ component_name }} was expected to be installed in version {{ component_version }}.
Instead it is reported as version {{ (result.json.versions | items2dict(key_name="component", value_name="version"))[component_name] }}.
- block:
- name: "Check version of component being tested"
assert:
that:
- (result.json.versions | items2dict(key_name="component", value_name="version"))[component_name] | canonical_semver == (component_version | canonical_semver)
fail_msg: |
Component {{ component_name }} was expected to be installed in version {{ component_version }}.
Instead it is reported as version {{ (result.json.versions | items2dict(key_name="component", value_name="version"))[component_name] }}.
rescue:
- name: "Check version of component being tested (legacy)"
assert:
that:
- (result.json.versions | items2dict(key_name="component", value_name="version"))[legacy_component_name] | canonical_semver == (component_version | canonical_semver)
fail_msg: |
Component {{ legacy_component_name }} was expected to be installed in version {{ component_version }}.
Instead it is reported as version {{ (result.json.versions | items2dict(key_name="component", value_name="version"))[legacy_component_name] }}.

- name: "Set pulp password in .netrc"
copy:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/scripts/before_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ else
fi
mkdir .ci/ansible/vars || true
echo "---" > .ci/ansible/vars/main.yaml
echo "component_name: pulpcore" >> .ci/ansible/vars/main.yaml
echo "legacy_component_name: pulpcore" >> .ci/ansible/vars/main.yaml
echo "component_name: core" >> .ci/ansible/vars/main.yaml
echo "component_version: '${COMPONENT_VERSION}'" >> .ci/ansible/vars/main.yaml

export PRE_BEFORE_INSTALL=$PWD/.github/workflows/scripts/pre_before_install.sh
Expand Down
3 changes: 3 additions & 0 deletions CHANGES/8198.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The ``component`` field of the ``versions`` section of the status API ```/pulp/api/v3/status/`` now
lists the Django app name, not the Python package name. Similarly the OpenAPI schema at
``/pulp/api/v3`` does also.
25 changes: 15 additions & 10 deletions pulpcore/app/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
from django.conf import settings
from django.core.files.storage import default_storage
from drf_spectacular.utils import extend_schema
from pkg_resources import get_distribution
from rest_framework.response import Response
from rest_framework.views import APIView

from pulpcore.app.apps import pulp_plugin_configs
from pulpcore.app.models.status import ContentAppStatus
from pulpcore.app.models.task import Worker
from pulpcore.app.serializers.status import StatusSerializer
from pulpcore.app.settings import INSTALLED_PULP_PLUGINS
from pulpcore.tasking.connection import get_redis_connection

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -42,16 +41,22 @@ class StatusView(APIView):
operation_id="status_read",
responses={200: StatusSerializer},
)
def get(self, request, format=None):
def get(self, request):
"""
Returns app information including the version of pulpcore and loaded pulp plugins,
known workers, database connection status, and messaging connection status
Returns status and app information about Pulp.

Information includes:
* version of pulpcore and loaded pulp plugins
* known workers
* known content apps
* database connection status
* redis connection status
* disk usage information
"""
components = ["pulpcore"] + INSTALLED_PULP_PLUGINS
versions = [
{"component": component, "version": get_distribution(component).version}
for component in components
]
versions = []
for app in pulp_plugin_configs():
versions.append({"component": app.label, "version": app.version})
Copy link
Member

Choose a reason for hiding this comment

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

I just realized, this changes the keys and not only the trailing "0" in the versions.
This will break the version check logic in the cli.
Can we get back to the old names`

Copy link
Member Author

Choose a reason for hiding this comment

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

I also thought about this, but I don't see an easy way to. :/ What this change does is hand control over to the plugin for the name it provides. So it's up to the plugins really. Let's talk about it at the pulpcore meeting, I put an agenda item on there.

Copy link
Member

Choose a reason for hiding this comment

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

And BTW. This is what breaks the CI here too.


redis_status = {"connected": self._get_redis_conn_status()}
db_status = {"connected": self._get_db_conn_status()}

Expand Down
12 changes: 6 additions & 6 deletions pulpcore/openapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
from drf_spectacular.settings import spectacular_settings
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter
from pkg_resources import get_distribution
from rest_framework import mixins, serializers
from rest_framework.schemas.utils import get_pk_description

from pulpcore.app.settings import INSTALLED_PULP_PLUGINS
from pulpcore.app.apps import pulp_plugin_configs


class PulpAutoSchema(AutoSchema):
Expand Down Expand Up @@ -446,11 +445,12 @@ def get_schema(self, request=None, public=False):
result["info"]["x-logo"] = {
"url": "https://pulp.plan.io/attachments/download/517478/pulp_logo_word_rectangle.svg"
}

# Adding plugin version config
components = ["pulpcore"] + INSTALLED_PULP_PLUGINS
result["info"]["x-pulp-app-versions"] = {
component: get_distribution(component).version for component in components
}
result["info"]["x-pulp-app-versions"] = {}
for app in pulp_plugin_configs():
result["info"]["x-pulp-app-versions"][app.label] = app.version
Comment on lines +450 to +452
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
result["info"]["x-pulp-app-versions"] = {}
for app in pulp_plugin_configs():
result["info"]["x-pulp-app-versions"][app.label] = app.version
result["info"]["x-pulp-app-versions"] = {
app.label: app.version
for app in pulp_plugin_configs()
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to decline this change if that's alright. The list comprehension with the iterator at the end is less readable for me. What I wrote is a bit slower though.


# Adding current host as server (it will provide a default value for the bindings)
server_url = "http://localhost:24817" if not request else request.build_absolute_uri("/")
result["servers"] = [{"url": server_url}]
Expand Down
2 changes: 1 addition & 1 deletion template_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ deploy_daily_client_to_rubygems: true
deploy_to_pypi: true
docker_fixtures: true
docs_test: true
plugin_app_label: pulpcore
plugin_app_label: core
plugin_camel: Pulpcore
plugin_camel_short: Pulpcore
plugin_caps: PULPCORE
Expand Down