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

MGMT-16066: Resource Subscription Server #107

Conversation

irinamihai
Copy link
Collaborator

Description:

  • update the alarm subscription handler to a generic subscription handler that can also be used for resource subscriptions
  • add a new command for the resource subscription server:
    oran-o2ims start infrastructure-inventory-subscription-server
  • update the alarm and resource subscription servers to also set the subscription type

@openshift-ci-robot
Copy link
Collaborator

openshift-ci-robot commented Jun 21, 2024

@irinamihai: This pull request references MGMT-16066 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "4.17.0" version, but no target version was set.

In response to this:

Description:

  • update the alarm subscription handler to a generic subscription handler that can also be used for resource subscriptions
  • add a new command for the resource subscription server:
    oran-o2ims start infrastructure-inventory-subscription-server
  • update the alarm and resource subscription servers to also set the subscription type

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot requested a review from jhernand June 21, 2024 22:19
)

const (
SUBSCRPTION_TYPE_ALARM = "ALARM"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should these be SubscriptionTypeAlarm and SubscriptionTypeInfrastructureInventory to be consistent with the typical naming for constants in Go?

SetLogger(logger).
SetLoggingWrapper(loggingWrapper).
SetCloudID(cloudID).
SetExtensions(extensions...).
SetKubeClient(kubeClient).
SetSubscriptionType("ALARM").
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if the storage should be created outside of the handler and then passed as a parameter instead of forcing the subscription handler to know the type of subscription. Is there any difference in the behaviour other than the namespace/name of the configmap where the subscriptions are stored?

Copy link
Collaborator

@Jennifer-chen-rh Jennifer-chen-rh Jun 24, 2024

Choose a reason for hiding this comment

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

I made the configuration map name and name spaces configurable in my current PR. but not committed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There are also 2 other instances where we need to translate the reponse. The Alarm and Infrastructure subscription responses differ a bit. In decodeSubId and encodeSubId. In these cases the handler needs to know the subscription type so that it translates correctly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@Jennifer-chen-rh , that's great. Would it be ok if we tried to merge the current PR first? Then yours will actually be shorter. The rebase shouldn't be a headache.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure. Mine has more changes and comparatively harder to be a rebase code base.

@@ -206,8 +206,8 @@ func (s *KubeConfigMapStore) ReadAllEntries(ctx context.Context) (result map[str

func (s *KubeConfigMapStore) ProcessChanges(ctx context.Context, dataMap **map[string]data.Object, lock *sync.Mutex) (err error) {
raw_opt := metav1.SingleObject(metav1.ObjectMeta{
Namespace: s.nameSpace,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I made similar change in my current notification server PR.

@irinamihai irinamihai force-pushed the MGMT-16066-resource-sub-server branch from b236434 to 7d13295 Compare June 24, 2024 18:44
@jhernand
Copy link
Collaborator

Looks good to me.

SetCloudID(cloudID).
SetExtensions(extensions...).
SetKubeClient(kubeClient).
SetSubscriptionType("INFRA-ENV").
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should the SubscriptionTypeInfrastructureInventory constant be used here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're right. Initially I saw they were in different packages, but I noticed the service package is already imported here, so I will use it. Thanks!


err = nil

if h.persistStore.Name == AlarmConfigMapName {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: we can consider switch/case here for future expansion

// get consumer name, subscriptions
err = h.jqTool.Evaluate(
`{
"subscriptionId": $subId,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just to keep the convention, maybe we can rename it to something like $resourceSubId

Copy link
Collaborator Author

@irinamihai irinamihai Jun 26, 2024

Choose a reason for hiding this comment

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

I wanted to keep it in line with the O-RAN standard (where it's subscriptionId) and the alarm subscription case that's using alarmSubscriptionId, just as in the standard.
Please let me know if you agree.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh, I was actually referring to the name of the variable ($subId). It just looked a bit weird at first glance since it's generic compared to $alarmSubId. But feel free to ignore, it makes better sense now.

jq.String("$subId", subId),
)
}

if err != nil {
return
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want some log here? If not, seems lines 473-475 are redundant.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll remove these.

jq.String("$alarmSubId", subId),
)

err = nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just for readability?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will remove.

@irinamihai irinamihai force-pushed the MGMT-16066-resource-sub-server branch from 7d13295 to 959a307 Compare June 26, 2024 13:34
err = h.jqTool.Evaluate(
`.alarmSubscriptionId`, input, &output)

err = nil
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comments from encodeSubId - consider to apply also for this func.

Description:
- update the alarm subscription handler to a generic subscription
  handler that can also be used for resource subscriptions
- add a new command for the resource subscription server
- update the alarm and resource subscription servers to also set
  the subscription type
@irinamihai irinamihai force-pushed the MGMT-16066-resource-sub-server branch from 959a307 to 946666e Compare June 26, 2024 14:06
@danielerez
Copy link
Collaborator

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jun 26, 2024
@danielerez
Copy link
Collaborator

/approve

Copy link

openshift-ci bot commented Jun 26, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: danielerez

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 26, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 148c8ea into openshift-kni:main Jun 26, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants