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

SWATCH-2276: Expose the OrgConfigRepository.findSyncEnabledOrgs #3177

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

Sgitario
Copy link
Contributor

Jira issue: SWATCH-2276

Description

Expose the OrgConfigRepository.findSyncEnabledOrgs via Kafka topics. Added request/response model in swatch-core that will also be used by the swatch-contracts service.

Testing

  1. start kafka and rest of the services
  2. start the tally service:
DEV_MODE=true SPRING_PROFILES_ACTIVE=worker ./gradlew :bootRun
  1. send request to the topic: platform.rhsm-subscriptions.enabled-orgs-for-tasks:
{"target_topic": "wrong"}
  1. verify this message is ignored because the target topic is invalid

you should see the following trace in the tally service logs:

2024-03-22 10:30:32,560 [thread=rhsm-subscriptions-enabled-orgs-processor-0-C-1] [WARN ] [org.candlepin.subscriptions.tally.tasks.EnabledOrgsMessageConsumer] - Ignoring enabled organizations request for target topic 'wrong' because it's not allowed. List of allowed target topics are: '[platform.rhsm-subscriptions.subscription-prune-task, platform.rhsm-subscriptions.subscription-sync-task]'
  1. create an enabled org in database:
INSERT INTO public.org_config(org_id, opt_in_type, created, updated)
VALUES('123456', 'DB', now(), now());
  1. send a valid request to the same topic than step 3:
{"target_topic": "platform.rhsm-subscriptions.subscription-sync-task"}
  1. now, you should see the following logs in the tally service:
2024-03-22 10:36:56,600 [thread=rhsm-subscriptions-enabled-orgs-processor-0-C-1] [INFO ] [org.candlepin.subscriptions.tally.tasks.EnabledOrgsMessageConsumer] - Sending all enabled organizations to topic 'platform.rhsm-subscriptions.subscription-sync-task'
2024-03-22 10:36:56,702 [thread=kafka-producer-network-thread | producer-1] [WARN ] [org.apache.kafka.clients.NetworkClient] - [Producer clientId=producer-1] Error while fetching metadata with correlation id 1 : {platform.rhsm-subscriptions.subscription-sync-task=UNKNOWN_TOPIC_OR_PARTITION}
2024-03-22 10:36:57,003 [thread=rhsm-subscriptions-enabled-orgs-processor-0-C-1] [INFO ] [org.candlepin.subscriptions.tally.tasks.EnabledOrgsMessageConsumer] - Sent 1 messages with the organization ID to topic 'platform.rhsm-subscriptions.subscription-sync-task'

Note that the second trace is expected because the topic has not been created yet.

  1. check the topic "platform.rhsm-subscriptions.subscription-sync-task" contains the expected org id:
    http://localhost:3030/#/cluster/default/topic/n/platform.rhsm-subscriptions.subscription-sync-task/

content:

Key
Value
org_id 123456

@Sgitario Sgitario added QE Pull request should be approved by QE before merge Dev Pull requests that need developer review labels Mar 22, 2024
@kartikshahc kartikshahc self-assigned this Mar 22, 2024
@kartikshahc kartikshahc self-requested a review March 22, 2024 12:57
@Sgitario
Copy link
Contributor Author

/retest

Expose the OrgConfigRepository.findSyncEnabledOrgs via Kafka topics. 
Added request/response model in swatch-core that will also be used by the swatch-contracts service.
@kartikshahc
Copy link
Contributor

I saw the error platform.rhsm-subscriptions.subscription-sync-task=UNKNOWN_TOPIC_OR_PARTITION for the first time since it created topic and then I didn't see the error which is good.
All steps works as indicated. Code LGTM

@Sgitario
Copy link
Contributor Author

I saw the error platform.rhsm-subscriptions.subscription-sync-task=UNKNOWN_TOPIC_OR_PARTITION for the first time since it created topic and then I didn't see the error which is good. All steps works as indicated. Code LGTM

This is expected because this topic is consumed by another service.

@kartikshahc kartikshahc added Dev/approved Pull requests that have been approved by all assigned developers and removed Dev Pull requests that need developer review labels Mar 26, 2024
@Sgitario Sgitario added QE Unneeded Pull request does not need QE approval and removed QE Pull request should be approved by QE before merge labels Mar 27, 2024
@Sgitario Sgitario merged commit 9c7d4d6 into main Mar 27, 2024
5 checks passed
@Sgitario Sgitario deleted the jcarvaja/SWATCH-2276 branch March 27, 2024 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dev/approved Pull requests that have been approved by all assigned developers QE Unneeded Pull request does not need QE approval
Projects
None yet
2 participants