Skip to content

AAP-45875 Runtime Feature Flags #736

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

Open
wants to merge 12 commits into
base: devel
Choose a base branch
from

Conversation

zkayyali812
Copy link
Contributor

@zkayyali812 zkayyali812 commented Jun 4, 2025

Description

https://issues.redhat.com/browse/AAP-45875

  • What is being changed?
    This change is the foundation for enabling runtime platform feature flags for AAP. This updates the django-ansible-base to be the central location where all platform flags are defined. Components can inherit the ansible_base.feature_flags application to inherit all platform feature flag definitions.
  • Why is this change needed?
    To enable runtime platform feature flags in AAP.
  • How does this change address the issue?
    This change addresses the issue by defining a database flag source, which contains all the feature flags along with their associated metadata.
    These feature flags are installed into each components database at install-time and kept in sync via resource sync (Gateway is the provider)

Before this can be merged, the following should be done -

  1. Confirm expected flag support levels
  2. Confirm each feature flags metadata

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Documentation update
  • Test update

Self-Review Checklist

  • I have performed a self-review of my code
  • I have added relevant comments to complex code sections
  • I have updated documentation where needed
  • I have considered the security impact of these changes
  • I have considered performance implications
  • I have thought about error handling and edge cases
  • I have tested the changes in my local environment

Testing Instructions

Prerequisites

Steps to Test

Recommend testing this through AAP Dev, but it can be tested directly via the test app as well.

  1. Clone aap-dev
  2. enter aap-dev directory and run make configure-sources
  3. Use this PR for the DAB source
  4. Use this PR for the Gateway source - https://github.com/ansible/aap-gateway/pull/795

Expected Results

AAP Deploys as expected with database feature flags.

Notes

This PR is the prerequisite for the following component PRs -
Gateway - https://github.com/ansible/aap-gateway/pull/795
EDA - ansible/eda-server#1346
Galaxy - ansible/galaxy_ng#2615
AWX - ansible/awx#16030

@zkayyali812 zkayyali812 force-pushed the phase2/feature-flags/poc branch 3 times, most recently from 3822dfe to 6b72afd Compare June 4, 2025 19:31
@zkayyali812 zkayyali812 changed the title WIP: Runtime Feature Flags WIP: AAP-45875 Runtime Feature Flags Jun 4, 2025
@zkayyali812 zkayyali812 force-pushed the phase2/feature-flags/poc branch 21 times, most recently from 081fdcc to f492546 Compare June 11, 2025 19:58
@zkayyali812 zkayyali812 force-pushed the phase2/feature-flags/poc branch 2 times, most recently from 3699be8 to 8b6d0bc Compare June 13, 2025 12:21
@zkayyali812 zkayyali812 requested a review from AlanCoding June 16, 2025 16:02
@zkayyali812
Copy link
Contributor Author

This PR was reviewed in the DAB PR review meeting, before it can be merged, the remaining tasks are outstanding -
Confirm expected flag support levels
Confirm each feature flags metadata

@zkayyali812 zkayyali812 force-pushed the phase2/feature-flags/poc branch 5 times, most recently from fedaa23 to 69f6bbb Compare June 18, 2025 19:58
@zkayyali812 zkayyali812 force-pushed the phase2/feature-flags/poc branch from 69f6bbb to 2ef72a1 Compare June 23, 2025 12:48
@zkayyali812 zkayyali812 force-pushed the phase2/feature-flags/poc branch from 9860248 to 5b7f1f9 Compare June 23, 2025 21:49
Copy link

DVCS PR Check Results:

PR appears valid (JIRA key(s) found)

Copy link

@AlanCoding
Copy link
Member

Downstream failures, starting to hit the database for references like this in AWX:

  File "/awx_devel/awx/main/tasks/jobs.py", line 976, in build_env
    if flag_enabled("FEATURE_INDIRECT_NODE_COUNTING_ENABLED"):
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

These are probably expected. This is in the job execution path, so that's not too big of a deal.

@@ -5,55 +5,32 @@ Additional library documentation can be found at https://cfpb.github.io/django-f

## Settings

Add `ansible_base.feature_flags` to your installed apps:
Add `ansible_base.feature_flags` to your installed apps and ensure `ansible_base.resource_registry` as added to enable flag state to sync across the platform:
Copy link
Member

Choose a reason for hiding this comment

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

Don't you also need to register the flag model in the resource registry config?

Just trying to complete the circle for ability for someone to understand. That should be mentioned here if I understand. Or mention briefly how you're doing that automatically, if that's the case.



class FeatureFlagType(SharedResourceTypeSerializer):
"""Serialize list of feature flags"""
Copy link
Member

Choose a reason for hiding this comment

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

Not really for a list.

]
router = AssociationResourceRouter()

router.register(r'feature_flags/states', views.FeatureFlagsStatesView, basename='aap_flags_states')
Copy link
Member

Choose a reason for hiding this comment

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

The serializer for this has an awfully small number of fields. The model has many more fields. Even the management command gives more information.

Were you intending to add some other endpoint which would give the UI the information necessary to render choices and stuff?


def delete_feature_flags():
"""
If a feature flag has been removed from the platform flags list, delete it from the database.
Copy link
Member

Choose a reason for hiding this comment

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

Strange between docstring & method name. Maybe it would flow more smoothly if named purge_feature_flags. "delete" makes me expect a flag name as argument.

class FeatureFlagsStateListView(AnsibleBaseView):
class FeatureFlagsStatesView(AnsibleBaseDjangoAppApiView, ModelViewSet):
"""
A view class for displaying feature flags states
Copy link
Member

Choose a reason for hiding this comment

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

Might be help to explain where they should go to change them?

Makes sense that this is read-only. But it would be really really helpful to direct users to where they need to be.

Copy link
Member

@AlanCoding AlanCoding left a comment

Choose a reason for hiding this comment

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

I'm good with the decisions made here, totally ready to 👍 this

Almost all my comments are to improve documentation, very simple things.

I'm just unclear if the API endpoints (views, serializers) are finished. I'm confused about that, in terms of what the UI needs to be delivered with this, what the response looks like, and if that's planned for later or anything.

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.

2 participants