Skip to content

Commit

Permalink
release 2.3.4 to master (RedHatProductSecurity#107)
Browse files Browse the repository at this point in the history
  • Loading branch information
osoukup authored Dec 15, 2022
2 parents ecb1286 + d7a3ffa commit ec532bc
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 37 deletions.
2 changes: 1 addition & 1 deletion collectors/product_definitions/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
"default_ps_update_streams",
"eus_ps_update_streams",
"aus_ps_update_streams",
"unacked_ps_update_stream_tmp",
"unacked_ps_update_stream",
)
23 changes: 10 additions & 13 deletions collectors/product_definitions/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,7 @@ def sync_ps_products_modules(ps_products_data: dict, ps_modules_data: dict):
module_data = ps_modules_data[module_name]
filtered_module_data = {}
for fname in ps_module_fields:
# TODO: Remove hack in version 2.3.4 or above
# This essentially maps unacked_ps_update_stream_tmp (new field)
# to the value of unacked_ps_update_stream (old field) without
# using nor setting the old field, so that we can remain N-1
# compatible.
key = fname
if fname == "unacked_ps_update_stream":
fname = "unacked_ps_update_stream_tmp"
if val := module_data.get(key, False):
if val := module_data.get(fname, False):
filtered_module_data[fname] = val

# get names of the related PS Update Streams as they will be
Expand All @@ -147,10 +139,7 @@ def sync_ps_products_modules(ps_products_data: dict, ps_modules_data: dict):
if stream_type in filtered_module_data
}

# since filtered_module_data no longer contains the key for
# unacked_ps_update_stream (old field) we can determine that
# there's now 0 usage of the old field.
# note that this behavior is probably incorrect somehow as
# TODO note that the following is probably incorrect somehow as
# we're attempting to set multiple related objects with string
# values but Django doesn't seem to care?
ps_module, _ = PsModule.objects.update_or_create(
Expand All @@ -166,3 +155,11 @@ def sync_ps_products_modules(ps_products_data: dict, ps_modules_data: dict):
# so we have to turn it into a list while not touch the others
PsUpdateStream.objects.filter(name__in=ensure_list(stream_names))
)
# unacked PS update stream may or may not be present in ps_updates_streams array
# therefore we need to explicitly ensure that it is linked to PS module
if stream_type == "unacked_ps_update_stream":
unacked_ps_update_stream = PsUpdateStream.objects.filter(
name=stream_names
).first()
if unacked_ps_update_stream:
ps_module.ps_update_streams.add(unacked_ps_update_stream)
49 changes: 35 additions & 14 deletions collectors/product_definitions/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def sample_data(self, raw_data):
"""take only sample of the raw data"""
to_keep = {
"ps_modules": [
"cfme-5",
"cfme-6",
"rhint-dv-1",
"rhint-camel-k-1",
"rhint-debezium-1",
Expand All @@ -40,6 +42,17 @@ def sample_data(self, raw_data):
"fis-2",
],
"ps_update_streams": [
"cfme-5.2",
"cfme-5.3",
"cfme-5.4",
"cfme-5.5",
"cfme-5.6",
"cfme-5.7",
"cfme-5.8",
"cfme-5.9",
"cfme-5.10",
"cfme-5.11",
"cfme-5",
"rhint-dv-1",
"rhelsa-7.1",
"rhelsa-7.2",
Expand All @@ -51,7 +64,7 @@ def sample_data(self, raw_data):
"fuse-7.3.1",
"fuse-7.4.0",
],
"ps_products": ["rhint", "rhelsa", "fuse"],
"ps_products": ["cfme", "rhint", "rhelsa", "fuse"],
}

sampled_data = {
Expand All @@ -76,9 +89,6 @@ def check_fields_population(
for key, value in raw_data.items():
instance = model.objects.get(**{unique_field: key})
for field in raw_data[key]:
# TODO remove this conditional statement in version 2.3.4 or above
if field == "unacked_ps_update_stream":
field = "unacked_ps_update_stream_tmp"
if field in fields:
if raw_data[key].get(field):
assert getattr(instance, field)
Expand Down Expand Up @@ -171,19 +181,30 @@ def test_additional_ps_update_stream_module_link(self):
# syncing Update Streams
sync_ps_products_modules(ps_products, ps_modules)

module = PsModule.objects.get(name="fuse-7")
assert not module.ps_update_streams.all()
assert not module.active_ps_update_streams.all()
assert not module.default_ps_update_streams.all()
module1 = PsModule.objects.get(name="fuse-7")
assert not module1.ps_update_streams.all()
assert not module1.active_ps_update_streams.all()
assert not module1.default_ps_update_streams.all()

# cfme-5 and fuse-7 has the unacked stream defined
# differently according to ps_update_streams array
module2 = PsModule.objects.get(name="cfme-5")
assert not module2.ps_update_streams.all()
assert not module2.active_ps_update_streams.all()
assert not module2.default_ps_update_streams.all()

# Sync PS Update Streams and resync Products and Modules
sync_ps_update_streams(ps_update_streams)
sync_ps_products_modules(ps_products, ps_modules)
assert module.ps_update_streams.all()
assert module.active_ps_update_streams.all()
assert module.default_ps_update_streams.all()
assert module1.ps_update_streams.all()
assert module1.active_ps_update_streams.all()
assert module1.default_ps_update_streams.all()
assert module2.ps_update_streams.all()
assert module2.active_ps_update_streams.all()
assert module2.default_ps_update_streams.all()

# check that unacked PS update stream is not omitted
# TODO remove _tmp in version 2.3.4 or above
assert module.unacked_ps_update_stream_tmp
assert module.unacked_ps_update_stream_tmp.first().name == "fuse-7"
assert module1.unacked_ps_update_stream
assert module1.unacked_ps_update_stream.first().name == "fuse-7"
assert module2.unacked_ps_update_stream
assert module2.unacked_ps_update_stream.first().name == "cfme-5"
2 changes: 1 addition & 1 deletion config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@
SPECTACULAR_SETTINGS = {
"TITLE": "OSIDB API",
"DESCRIPTION": "REST API autogenerated docs for the OSIDB and its components",
"VERSION": "2.3.3",
"VERSION": "2.3.4",
"SWAGGER_UI_SETTINGS": {"supportedSubmitMethods": []},
"SERVE_AUTHENTICATION": [
"krb5_auth.auth.KerberosAuthentication",
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Change logging of celery and django to filesystem (OSIDB-418)
- Implement validation for CWE ID chain in a Flaw (OSIDB-357)

## [2.3.4] - 2022-12-15
### Changed
- Make sure the unacked PS update stream is always linked to PS module (OSIDB-637)

## [2.3.3] - 2022-12-13
### Changed
- Link unacked PS update stream to PS module on product definitions sync (OSIDB-629)
Expand Down
2 changes: 1 addition & 1 deletion openapi.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
openapi: 3.0.3
info:
title: OSIDB API
version: 2.3.3
version: 2.3.4
description: REST API autogenerated docs for the OSIDB and its components
paths:
/auth/token:
Expand Down
2 changes: 1 addition & 1 deletion osidb/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
osidb version
"""
__version__ = "2.3.3"
__version__ = "2.3.4"
VERSION = __version__
29 changes: 29 additions & 0 deletions osidb/migrations/0065_fix_unacked_stream_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.2.15 on 2022-12-14 14:16

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
("osidb", "0064_alter_affect_ps_component"),
]

operations = [
migrations.RemoveField(
model_name="psmodule",
name="unacked_ps_update_stream",
),
migrations.AlterField(
model_name="psupdatestream",
name="unacked_to_ps_module",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="unacked_ps_update_stream",
to="osidb.psmodule",
),
),
]
8 changes: 2 additions & 6 deletions osidb/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1625,10 +1625,7 @@ class PsModule(NullStrFieldsMixin, ValidateMixin):
# active_ps_update_streams
# default_ps_update_streams
# aus_ps_update_streams
# TODO remove the next line in version 2.3.4 or above
unacked_ps_update_stream = models.CharField( # noqa: DJ01
max_length=100, blank=True, null=True
)
# unacked_ps_update_stream

ps_product = models.ForeignKey(
PsProduct, on_delete=models.CASCADE, related_name="ps_modules"
Expand Down Expand Up @@ -1689,11 +1686,10 @@ class PsUpdateStream(NullStrFieldsMixin, ValidateMixin):
)
# there is only one unacked PS update stream
# but let us link it the same way so it is unified
# TODO in version 2.3.4 or above change the related_name to unacked_ps_update_stream
unacked_to_ps_module = models.ForeignKey(
PsModule,
on_delete=models.SET_NULL,
related_name="unacked_ps_update_stream_tmp",
related_name="unacked_ps_update_stream",
null=True,
blank=True,
)
Expand Down

0 comments on commit ec532bc

Please sign in to comment.