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

Add the /apis endpoint call with expand false flag. #2934

Closed
wants to merge 20 commits into from

Conversation

VirajSalaka
Copy link
Contributor

@VirajSalaka VirajSalaka commented May 20, 2022

Purpose

Since the /apis endpoint call was a costly operation (due to API Manager DB operations), this was removed from the choreo branch. As a result of that, switching an API to Blocked Lifecycle state did not function.
With this PR, the /apis endpoint call will be added again. Hence the fore-mentioned limitation will be removed.

In this case, the /apis endpoint will be called with the query parameter expand=false so that it would return default APIs and blocked APIs only. This call is made during the startup. Then onwards, the blocked APIs and default APIs are identified using message events.

In addition, the unnecessary properties within the protobuf files are removed too.

Issues

Fixes #

Automation tests

  • Unit tests added: Yes/No
  • Integration tests added: Yes/No

Tested environments

Not Tested


Maintainers: Check before merge

  • Assigned 'Type' label
  • Assigned the project
  • Validated respective github issues
  • Assigned milestone to the github issue(s)

@VirajSalaka VirajSalaka force-pushed the apis-ep-fix-r branch 3 times, most recently from bce83b3 to 51bc34c Compare May 26, 2022 07:58
@VirajSalaka VirajSalaka marked this pull request as ready for review May 31, 2022 05:06
if xdsAPIList != nil {
xds.UpdateEnforcerAPIList(env, xdsAPIList)
}
}
return
}
// TODO: (VirajSalaka) Temporarily removed.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let's remove this unused.

@@ -511,12 +510,13 @@ func MarshalAPIMetataAndReturnList(apiList *types.APIList, initialAPIUUIDListMap
// DeleteAPIAndReturnList removes the API from internal maps and returns the marshalled API List.
// If the apiUUID is not found in the internal map under the provided environment, then it would return a
// nil value. Hence it is required to check if the return value is nil, prior to updating the XDS cache.
func DeleteAPIAndReturnList(apiUUID, organizationUUID string, gatewayLabel string) *subscription.APIList {
func DeleteAPIAndReturnList(apiUUID string, gatewayLabel string) *subscription.APIList {
if _, ok := APIListMap[gatewayLabel]; !ok {
logger.LoggerXds.Debugf("No API Metadata is available under gateway Environment : %s", gatewayLabel)
return nil
}
delete(APIListMap[gatewayLabel], apiUUID)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check for apiUUID and return nil if it is not found.

@@ -511,12 +510,13 @@ func MarshalAPIMetataAndReturnList(apiList *types.APIList, initialAPIUUIDListMap
// DeleteAPIAndReturnList removes the API from internal maps and returns the marshalled API List.
// If the apiUUID is not found in the internal map under the provided environment, then it would return a
// nil value. Hence it is required to check if the return value is nil, prior to updating the XDS cache.
func DeleteAPIAndReturnList(apiUUID, organizationUUID string, gatewayLabel string) *subscription.APIList {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Check if we can unify the APIList and APIs

// But if the API is a default version, those APIs needs to be kept. But with the lifecycle state != BLOCKED.
if status != blockedStatus && !apiEntry.IsDefaultVersion {
return DeleteAPIAndReturnList(apiUUID, gatewayLabel)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment out the possibilities the code could reach this far

APIListMap[gatewayLabel][apiUUID] = &subscription.APIs{
Uuid: apiUUID,
LcState: status,
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can return the List straightaway.

logger.LoggerXds.Debugf("No API Metadata for API ID: %s is available under gateway Environment : %s",
apiUUID, gatewayLabel)
return nil
if apiEntry, ok := APIListMap[gatewayLabel][apiUUID]; !ok {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See the possiblities of improving the readability of the code.

@@ -0,0 +1,107 @@
/*
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Move Admin API related DTOs to a single folder within models directory.

}
}
}
// Set<String> set = apiMap.keySet()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove This as it simply returns null

@VirajSalaka VirajSalaka force-pushed the apis-ep-fix-r branch 5 times, most recently from 9c9987e to c42b9c7 Compare June 5, 2022 18:42
@VirajSalaka
Copy link
Contributor Author

closing the PR as #2985 covers the same implementation but in more organized manner in terms of commits.

@VirajSalaka VirajSalaka closed this Jul 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants