Skip to content

Commit

Permalink
Merge pull request #3494 from slahirucd7/choreo
Browse files Browse the repository at this point in the history
[Choreo] Code refactoring and base image version upgrades
  • Loading branch information
slahirucd7 authored Feb 22, 2024
2 parents 900154a + f16aeee commit de22055
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 24 deletions.
15 changes: 3 additions & 12 deletions adapter/cmd/adapter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,14 @@
package main

import (
"os"

logger "github.com/sirupsen/logrus"
"github.com/wso2/product-microgateway/adapter/config"
_ "github.com/wso2/product-microgateway/adapter/pkg/logging"
"github.com/wso2/product-microgateway/adapter/internal/adapter"
_ "github.com/wso2/product-microgateway/adapter/pkg/logging"
)

func main() {

var file string
if len(os.Args) > 1 {
file = os.Args[1]
logger.Debug(file)
}
startMicroGateway(os.Args)
startMicroGateway()
}

func initServer() error {
Expand All @@ -43,8 +35,7 @@ func initServer() error {

// startMicroGateway reads the configuration files and then start the adapter components.
// Commandline arguments needs to be provided as args
func startMicroGateway(args []string) {

func startMicroGateway() {
logger.Info("Starting Choreo Connect Adapter")
err := initServer()
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion adapter/internal/adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,11 @@ func Run(conf *config.Config) {
logger.LoggerMgw.Error("Error reading the log configs. ", errC)
}

logger.LoggerMgw.Info("Starting adapter ....")
if conf.GlobalAdapter.Enabled {
logger.LoggerMgw.Infof("Preparing adapter in partition: %s to serve dynamic configurations via xDS....", conf.GlobalAdapter.LocalLabel)
} else {
logger.LoggerMgw.Info("Preparing adapter to serve dynamic configurations via xDS....")
}
cache := xds.GetXdsCache()
rateLimiterCache := xds.GetRateLimiterCache()
enforcerCache := xds.GetEnforcerCache()
Expand Down
2 changes: 1 addition & 1 deletion adapter/internal/discovery/xds/rate_limiter_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (r *rateLimitPolicyCache) AddAPILevelRateLimitPolicies(apiID string, mgwSwa
if level == envoyconf.RateLimitPolicyAPILevel {
rlPolicyConfig, err := getRateLimitPolicy(policies, mgwSwagger.RateLimitPolicy)
if err != nil {
loggers.LoggerXds.Errorf("Error generating rate limit configuration for API: %q", apiID)
loggers.LoggerXds.Errorf("Error generating API level rate limit configuration for API: %q", apiID)
return err
}

Expand Down
4 changes: 0 additions & 4 deletions adapter/internal/discovery/xds/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ var (
enforcerApplicationMap map[string][]types.Resource
enforcerAPIListMap map[string][]types.Resource
enforcerApplicationPolicyMap map[string][]types.Resource
enforcerSubscriptionPolicyMap map[string][]types.Resource
enforcerApplicationKeyMappingMap map[string][]types.Resource
enforcerRevokedTokensMap map[string][]types.Resource
enforcerThrottleData *throttle.ThrottleData
Expand Down Expand Up @@ -182,7 +181,6 @@ func init() {
enforcerApplicationMap = make(map[string][]types.Resource)
enforcerAPIListMap = make(map[string][]types.Resource)
enforcerApplicationPolicyMap = make(map[string][]types.Resource)
enforcerSubscriptionPolicyMap = make(map[string][]types.Resource)
enforcerApplicationKeyMappingMap = make(map[string][]types.Resource)
enforcerRevokedTokensMap = make(map[string][]types.Resource)
enforcerThrottleData = &throttle.ThrottleData{}
Expand Down Expand Up @@ -694,7 +692,6 @@ func deleteAPI(apiIdentifier string, environments []string, organizationID strin
} else {
toBeDelEnvs, toBeKeptEnvs = getEnvironmentsToBeDeleted(existingLabels, environments)
}

if conf.Adapter.IsIntelligentRoutingEnabled && strings.HasPrefix(api.GetVersion(), "v") {
updateRoutingRulesOnAPIDelete(organizationID, apiIdentifier, api)
}
Expand Down Expand Up @@ -1084,7 +1081,6 @@ func UpdateEnforcerSubscriptionPolicies(subscriptionPolicies *subscription.Subsc
if err != nil {
logger.LoggerXds.Error(err)
}
enforcerSubscriptionPolicyMap[label] = subscriptionPolicyList

conf, _ := config.ReadConfigs()
for _, env := range conf.ControlPlane.EnvironmentLabels {
Expand Down
2 changes: 1 addition & 1 deletion adapter/internal/messaging/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ func ProcessEvents(config *config.Config) {

go handleNotification()
go handleKMConfiguration()
go handleThrottleData()
go handleThrottleData() // TODO: Remove this since it's not being used now
go handleTokenRevocation()
}
2 changes: 1 addition & 1 deletion adapter/src/main/resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
# -----------------------------------------------------------------------

FROM alpine:3.17.3
FROM alpine:3.19.1
LABEL maintainer="WSO2 Docker Maintainers <wso2.com>"

RUN apk update && apk upgrade --no-cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ option java_multiple_files = true;

// SubscriptionPolicy data model
message SubscriptionPolicy {
int32 id = 1;
int32 id = 1;
int32 tenantId = 2;
string name = 3;
string quotaType = 4;
Expand All @@ -21,5 +21,5 @@ message SubscriptionPolicy {
string rateLimitTimeUnit = 8;
bool stopOnQuotaReach = 9;
string tenantDomain = 10;
int64 timestamp = 11;
int64 timestamp = 11;
}
2 changes: 1 addition & 1 deletion enforcer-parent/enforcer/src/main/resources/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
# -----------------------------------------------------------------------

FROM adoptopenjdk/openjdk11:jre-11.0.18_10-alpine
FROM adoptopenjdk/openjdk11:jre-11.0.22_7-alpine
LABEL maintainer="WSO2 Docker Maintainers <wso2.com>"

RUN apk update && apk upgrade --no-cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
# -----------------------------------------------------------------------

FROM adoptopenjdk/openjdk11:jre-11.0.20_8
FROM adoptopenjdk/openjdk11:jre-11.0.22_7-ubuntu

WORKDIR /home/app

Expand Down

0 comments on commit de22055

Please sign in to comment.