Skip to content

Commit 1e9b6aa

Browse files
committed
Fix post-migrate call. Replace with manual migrations
1 parent 2ef72a1 commit 1e9b6aa

File tree

13 files changed

+143
-32
lines changed

13 files changed

+143
-32
lines changed

ansible_base/feature_flags/apps.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,4 @@ class FeatureFlagsConfig(AppConfig):
1111
verbose_name = 'Feature Flags'
1212

1313
def ready(self):
14-
try:
15-
create_initial_data()
16-
except Exception:
17-
post_migrate.connect(create_initial_data, sender=self)
14+
post_migrate.connect(create_initial_data, sender=self)

ansible_base/feature_flags/definitions/feature_flags.yaml

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,28 @@
33
visibility: True
44
condition: boolean
55
value: 'False'
6-
support_level: TECHNICAL_PREVIEW
7-
description: TBD
8-
support_url: https://docs.redhat.com/en/documentation/red_hat_ansible_automation_platform/2.5/
6+
support_level: TECHNOLOGY_PREVIEW
7+
description: "Indirect Node Counting parses the event stream of all jobs to identify resources and stores these in the platform database. Example: Job automates VMware, the parser will report back the VMs, Hypervisors that were automated. This feature helps customers and partners report on the automations they are doing beyond an API endpoint."
8+
support_url: https://access.redhat.com/articles/7109910
99
labels:
1010
- controller
1111
- name: FEATURE_EDA_ANALYTICS_ENABLED
1212
ui_name: Event-Driven Ansible Analytics
13-
visibility: True
13+
visibility: False
1414
condition: boolean
1515
value: 'False'
16-
support_level: TECHNICAL_PREVIEW
17-
description: Submit Event-Driven Ansible usage analytics to console.redhat.com
16+
support_level: TECHNOLOGY_PREVIEW
17+
description: Submit Event-Driven Ansible usage analytics to console.redhat.com.
1818
support_url: https://access.redhat.com/solutions/7112810
19+
toggle_type: install-time
1920
labels:
2021
- eda
2122
- name: FEATURE_GATEWAY_IPV6_USAGE_ENABLED
2223
ui_name: Gateway IPv6 Enablement
2324
visibility: False
2425
condition: boolean
2526
value: 'False'
26-
support_level: TECHNICAL_PREVIEW
27+
support_level: TECHNOLOGY_PREVIEW
2728
description: The feature flag represents enabling IPv6 only traffic to be allowed through the gateway component and does not include all components of the platform.
2829
support_url: https://access.redhat.com/articles/7116569
2930
labels:
@@ -40,13 +41,14 @@
4041
labels:
4142
- gateway
4243
- name: FEATURE_DISPATCHERD_ENABLED
43-
ui_name: AAP Dispatcherd
44-
visibility: True
44+
ui_name: AAP Dispatcherd background tasking system
45+
visibility: False
4546
condition: boolean
4647
value: 'False'
47-
support_level: DEVELOPER_PREVIEW
48+
support_level: TECHNOLOGY_PREVIEW
4849
description: A service to run python tasks in subprocesses, designed specifically to work well with pg_notify, but intended to be extensible to other message delivery means.
4950
support_url: ''
51+
toggle_type: install-time
5052
labels:
5153
- eda
5254
- controller

ansible_base/feature_flags/definitions/schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
"description": "The level of support provided for this feature.",
3535
"type": "string",
3636
"enum": [
37-
"TECHNICAL_PREVIEW",
37+
"TECHNOLOGY_PREVIEW",
3838
"DEVELOPER_PREVIEW"
3939
]
4040
},

ansible_base/feature_flags/migrations/0001_initial.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Generated by Django 4.2.21 on 2025-06-17 20:08
1+
# Generated by Django 4.2.21 on 2025-06-24 13:34
2+
# FileHash: 8207dc6b9a446b7d4222d21287e695990b80846c779184388dbd63d32771b400
23

34
import ansible_base.feature_flags.models.aap_flag
45
from django.conf import settings
@@ -26,7 +27,7 @@ class Migration(migrations.Migration):
2627
('condition', models.CharField(default='boolean', help_text='Used to specify a condition, which if met, will enable the feature flag.', max_length=64)),
2728
('value', models.CharField(default='False', help_text='The value used to evaluate the conditional specified.', max_length=127)),
2829
('required', models.BooleanField(default=False, help_text="If multiple conditions are required to be met to enable a feature flag, 'required' can be used to specify the necessary conditionals.")),
29-
('support_level', models.CharField(choices=[('DEVELOPER_PREVIEW', 'Developer Preview'), ('TECHNICAL_PREVIEW', 'Technical Preview')], help_text='The support criteria for the feature flag. Must be one of (DEVELOPER_PREVIEW or TECHNICAL_PREVIEW).', max_length=25)),
30+
('support_level', models.CharField(choices=[('DEVELOPER_PREVIEW', 'Developer Preview'), ('TECHNOLOGY_PREVIEW', 'Technology Preview')], help_text='The support criteria for the feature flag. Must be one of (DEVELOPER_PREVIEW or TECHNOLOGY_PREVIEW).', max_length=25)),
3031
('visibility', models.BooleanField(default=False, help_text='The visibility of the feature flag. If false, flag is hidden.')),
3132
('toggle_type', models.CharField(choices=[('install-time', 'install-time'), ('run-time', 'run-time')], default='run-time', help_text="Details whether a flag is toggle-able at run-time or install-time. (Default: 'run-time').", max_length=20)),
3233
('description', models.CharField(default='', help_text='A detailed description giving an overview of the feature flag.', max_length=500)),
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
### INSTRUCTIONS ###
2+
# If updating the feature_flags.yaml, create a new migration file by copying this one.
3+
# 1. Name the file XXXX_manual_YYYYMMDD.py. For example 0002_manual_20250808.py
4+
# 1. Uncomment the migration below, by uncommenting everything below the FileHash
5+
# 2. Update the dependency to point to the last dependency
6+
# 3. Set the FileHash
7+
###
8+
9+
# FileHash: <FileHash>
10+
11+
# from django.db import migrations
12+
13+
14+
# class Migration(migrations.Migration):
15+
16+
# dependencies = [
17+
# ('dab_feature_flags', '0001_initial'),
18+
# ]
19+
20+
# operations = [
21+
# ]

ansible_base/feature_flags/models/aap_flag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ def __str__(self):
4747
support_level = models.CharField(
4848
max_length=25,
4949
null=False,
50-
help_text=_("The support criteria for the feature flag. Must be one of (DEVELOPER_PREVIEW or TECHNICAL_PREVIEW)."),
51-
choices=(('DEVELOPER_PREVIEW', 'Developer Preview'), ('TECHNICAL_PREVIEW', 'Technical Preview')),
50+
help_text=_("The support criteria for the feature flag. Must be one of (DEVELOPER_PREVIEW or TECHNOLOGY_PREVIEW)."),
51+
choices=(('DEVELOPER_PREVIEW', 'Developer Preview'), ('TECHNOLOGY_PREVIEW', 'Technology Preview')),
5252
blank=False,
5353
)
5454
visibility = models.BooleanField(

ansible_base/feature_flags/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def create_initial_data(**kwargs): # NOSONAR
2828
"""
2929
Loads in platform feature flags when the server starts
3030
"""
31-
delete_feature_flags()
31+
purge_feature_flags()
3232
load_feature_flags()
3333

3434

@@ -76,9 +76,9 @@ def load_feature_flags():
7676
logger.error(error_msg)
7777

7878

79-
def delete_feature_flags():
79+
def purge_feature_flags():
8080
"""
81-
If a feature flag has been removed from the platform flags list, delete it from the database.
81+
If a feature flag has been removed from the platform flags list, purge it from the database.
8282
"""
8383
from ansible_base.resource_registry.signals.handlers import no_reverse_sync
8484

ansible_base/feature_flags/views.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414

1515
class FeatureFlagsStatesView(AnsibleBaseDjangoAppApiView, ModelViewSet):
1616
"""
17-
A view class for displaying feature flags states
17+
A view class for displaying feature flags states.
18+
To add/update/remove a feature flag, see the instructions in
19+
`docs/apps/feature_flags.md`
1820
"""
1921

2022
queryset = AAPFlag.objects.order_by('id')

ansible_base/resource_registry/shared_types.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,6 @@ class TeamType(SharedResourceTypeSerializer):
7878

7979

8080
class FeatureFlagType(SharedResourceTypeSerializer):
81-
"""Serialize list of feature flags"""
82-
8381
RESOURCE_TYPE = "aapflag"
8482
UNIQUE_FIELDS = (
8583
"name",

docs/apps/feature_flags.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ INSTALLED_APPS = [
1818
## Detail
1919

2020
By adding the `ansible_base.feature_flags` app to your application, all Ansible Automation Platform feature flags will be loaded and available in your component.
21-
To receive flag state updates, ensure the following definition is available in your components `RESOURCE_LIST` -
21+
To receive flag state updates, ensure the following definition is available in your components `RESOURCE_LIST` -
2222

2323
```python
2424
from ansible_base.feature_flags.models import AAPFlag
@@ -48,9 +48,9 @@ urlpatterns = [
4848
]
4949
```
5050

51-
## Adding Feature Flags
51+
## Adding/updating/removing feature flags
5252

53-
To add a feature flag to the platform, specify it in the following [file](../../ansible_base/feature_flags/definitions/feature_flags.yaml)
53+
To add/update/remove a feature flag to the platform, ensure its configuration is specified correctly it in the following [file](../../ansible_base/feature_flags/definitions/feature_flags.yaml)
5454

5555
An example flag could resemble -
5656

@@ -73,3 +73,11 @@ Validate this file against the json schema by running `check-jsonschema` -
7373
pip install check-jsonschema
7474
check-jsonschema --schemafile ansible_base/feature_flags/definitions/schema.json ansible_base/feature_flags/definitions/feature_flags.yaml
7575
```
76+
77+
After adding/updating/removing a feature flag, make a manual migration. This can be done by -
78+
79+
1. Copying this [example-migration](../../ansible_base/feature_flags/migrations/example_migration).
80+
2. Name the file XXXX_manual_YYYYMMDD.py. For example 0002_manual_20250808.py
81+
3. Uncomment the migration, by uncommenting everything below the FileHash
82+
4. Update the dependency in the migration to point to the previous migration
83+
5. Set the **FileHash** in the migration file

0 commit comments

Comments
 (0)