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

feat: use event producer config #33269

Closed
wants to merge 9 commits into from

Conversation

rgraber
Copy link
Contributor

@rgraber rgraber commented Sep 15, 2023

Left as draft because this should not be merged until Arch BOM is ready to test on stage.

Original PR description from @navinkarkera. This PR has all the changes of his PR here but events are disabled by default and the latest release of the openedx-events library is used. Got into some git troubles, hence the new PR.

Description

Replace openedx_event signal handlers with new producer config to push to event bus.

Supporting information

Testing instructions

  • Setup master devstack.
  • Get lms and cms up using make {lms,cms}-up
  • Go to cms shell using make cms-shell
  • Run pip install -r requirements/edx/development.txt to install new openedx_events version.
  • Exit from cms-shell and see cms logs using make cms-logs.
  • Go to studio and delete an xblock or publish a section/subsection.
  • This should push the corresponding event to event bus and print below message:
    edx.devstack.cms  | 2023-07-28 13:43:57,201 INFO 515 [edx_event_bus_redis.internal.producer] [user 3] [ip 172.18.0.1] producer.py:82 - Message delivered to Redis event bus: topic=dev-content-authoring-xblock-lifecycle, message_id=cccfef82-2d4c-11ee-9c7a-0242ac12000c, signal=<OpenEdxPublicSignal: org.openedx.content_authoring.xblock.published.v1>, redis_msg_id=b'1690551837201-0'
    
  • Play with the EVENT_BUS_PRODUCER_CONFIG by toggling the flag and triggering the event.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

@rgraber rgraber marked this pull request as ready for review September 15, 2023 18:36
@rgraber rgraber marked this pull request as draft September 15, 2023 18:40
@rgraber rgraber changed the title feat: start with events disabled feat: use event producer config Sep 15, 2023
Copy link
Contributor

@robrap robrap left a comment

Choose a reason for hiding this comment

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

Thank you.

# in the LMS and CMS.
# .. toggle_tickets: 'https://github.com/openedx/edx-platform/pull/31813'
FEATURES['ENABLE_SEND_XBLOCK_EVENTS_OVER_BUS'] = True
FEATURES['ENABLE_SEND_ENROLLMENT_EVENTS_OVER_BUS'] = True
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. What about other references to this? https://github.com/search?q=repo%3Aopenedx%2Fedx-platform%20ENABLE_SEND_ENROLLMENT_EVENTS_OVER_BUS&type=code ?
  2. Can you search for all four of these settings and ensure you got all occurrences in the repo?

"""
Publish `CERTIFICATE_CREATED` events to the event bus.
"""
if SEND_CERTIFICATE_CREATED_SIGNAL.is_enabled():
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you could share the private PR for edx-internal settings so we can cross-reference that the old settings are being replaced by the new, and that they match values (enabled vs disabled)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Share it where? I don't think it makes sense to link it on a public PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you don't want to add private links here, maybe we just add more details to the deployment plan document?

@@ -440,78 +433,3 @@ def test_verified_to_audit(self):
) as mock_allowlist_task:
self.verified_enrollment.change_mode('audit')
mock_allowlist_task.assert_not_called()


class CertificateEventBusTests(ModuleStoreTestCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

[non-blocking question] I can't think of anything, but I'm wondering how we might ensure that people would know that a signal is in use by the event bus, and that it can't just be deleted or refactored? Maybe I should create a separate issue for this?

# .. setting_default: {}
# .. setting_description: Dictionary of event_types mapped to lists of dictionaries containing topic related configuration.
# Each topic configuration dictionary contains
# * a topic/stream name called `topic` where the event will be pushed to.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I think * topic: a topic/stream ... would be a format that is quicker to read.

# .. setting_description: Dictionary of event_types mapped to lists of dictionaries containing topic related configuration.
# Each topic configuration dictionary contains
# * a topic/stream name called `topic` where the event will be pushed to.
# * a flag called `enabled` denoting whether the event will be published to the topic.
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. Can we use toggle instead of flag?
  2. Can we mention that each toggle should be annotated following: https://edx.readthedocs.io/projects/edx-toggles/en/latest/how_to/documenting_new_feature_toggles.html?

# Note: The topic names should not include environment prefix as it will be dynamically added based on
# EVENT_BUS_TOPIC_PREFIX setting.
EVENT_BUS_PRODUCER_CONFIG = {
'org.openedx.learning.certificate.created.v1': [
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The best I can think of is "temporary" but we also don't have a removal date, which is required. opt_in, maybe? or open_edx?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it seems dependent on openedx/openedx-events#265

Copy link
Contributor

Choose a reason for hiding this comment

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

Good questions.

  1. Because the toggle is a permanent feature of the config, let's not call it temporary.
  2. I think opt_in works fine. Note that these options should be going away anyway.
  3. We have a strange situation where we will think we might be changing the default after some roll-out period, and this is dependent on the ticket you linked. Maybe just have some comment around this at the top of the config, noting that we need to work this out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking more I think we may still want to keep 'ENABLE_SEND_XBLOCK_EVENTS_OVER_BUS' since it actually gates several events which presumably should be launched or held back as a group. We can use the value of it to set the value in the config map. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Beginning to wonder if the entire map should be derived, with different settings for each event, at least in edx-platform. It's not a perfect solution because of the proliferation of settings, but it I think it's better than having some of them be set in the map and some derived from elsewhere. Less risk of someone trying to only enable or disable one event and not realizing they need to recreate the entire rest of the map in settings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If someone wants to add or change a topic it will still require setting the entire map, which is frustrating. But I think a better-than-before approach would just be to have enabled/disabled extracted as a different setting for each event and then derive the map from that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you concerned with a single topic, or the entire setting? We could also use KEYS_WITH_MERGED_VALUES.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The entire setting. If they wanted to change a single topic, they'd have to copy over the entire config dict and set all the derived settings correctly, which is non obvious. Keys with merged values looks like it may be our friend here.

Copy link
Contributor

Choose a reason for hiding this comment

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

With keys with merged values, do you feel more comfortable using derived settings on a per-topic basis? Feel free to answer with actual code changes for where you are landing.

@rgraber
Copy link
Contributor Author

rgraber commented Oct 16, 2023

replaced by #33458

@rgraber rgraber closed this Oct 16, 2023
@nedbat nedbat deleted the rsgraber/use-producer-config-disable branch January 8, 2024 15:02
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.

3 participants