Skip to content

Commit

Permalink
Merge branch 'main' into youngp/add-basemanifest-ut
Browse files Browse the repository at this point in the history
  • Loading branch information
youngbupark committed Sep 10, 2023
2 parents 87d56a3 + 2606ade commit 6439cba
Show file tree
Hide file tree
Showing 208 changed files with 7,806 additions and 2,568 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/purge-aws-test-resources.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# ------------------------------------------------------------
# Copyright 2023 The Radius Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------

name: Purge AWS test resources
on:
workflow_dispatch:
schedule:
# Run at 12:00AM PST every day.
- cron: "0 7 * * 0-6"

env:
AWS_REGION: us-west-2
AWS_RESOURCE_TYPES: 'AWS::Kinesis::Stream,AWS::S3::Bucket,AWS::RDS::DBInstance,AWS::RDS::DBSubnetGroup,AWS::MemoryDB::Cluster,AWS::MemoryDB::SubnetGroup'
jobs:
purge_aws_resources:
name: AWS resources clean-ups
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.FUNCTEST_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.FUNCTEST_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
- name: Filter and delete resources
run: |
for resource_type in ${${{env.AWS_RESOURCE_TYPES}}//,/ }
do
aws cloudcontrol list-resources --type-name "$resource_type" --query "ResourceDescriptions[].Identifier" --output text | tr '\t' '\n' | while read identifier
do
aws cloudcontrol delete-resource --type-name "$resource_type" --identifier "$identifier"
done
done
2 changes: 1 addition & 1 deletion build/generate.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ generate-tsp-installed:
@echo "$(ARROW) OK"

.PHONY: generate-openapi-spec
generate-openapi-spec:
generate-openapi-spec: # Generates all Radius OpenAPI specs from TypeSpec.
@echo "Generating openapi specs from typespec models."
cd typespec/UCP && npx$(CMD_EXT) tsp compile .
cd typespec/Applications.Core && npx$(CMD_EXT) tsp compile .
Expand Down
114 changes: 57 additions & 57 deletions cmd/applications-rp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,75 +18,57 @@ package main

import (
"context"
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"

"github.com/go-logr/logr"
"github.com/spf13/pflag"
etcdclient "go.etcd.io/etcd/client/v3"
runtimelog "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/radius-project/radius/pkg/armrpc/builder"
"github.com/radius-project/radius/pkg/armrpc/hostoptions"
"github.com/radius-project/radius/pkg/corerp/backend"
"github.com/radius-project/radius/pkg/corerp/frontend"
metricsservice "github.com/radius-project/radius/pkg/metrics/service"
profilerservice "github.com/radius-project/radius/pkg/profiler/service"
"github.com/radius-project/radius/pkg/recipes/controllerconfig"
"github.com/radius-project/radius/pkg/server"
"github.com/radius-project/radius/pkg/trace"

"github.com/radius-project/radius/pkg/logging"
pr_backend "github.com/radius-project/radius/pkg/portableresources/backend"
pr_frontend "github.com/radius-project/radius/pkg/portableresources/frontend"
"github.com/radius-project/radius/pkg/ucp/data"
"github.com/radius-project/radius/pkg/ucp/dataprovider"
"github.com/radius-project/radius/pkg/ucp/hosting"
"github.com/radius-project/radius/pkg/ucp/ucplog"

"github.com/go-logr/logr"
etcdclient "go.etcd.io/etcd/client/v3"
runtimelog "sigs.k8s.io/controller-runtime/pkg/log"
corerp_setup "github.com/radius-project/radius/pkg/corerp/setup"
)

const serviceName = "applications.core"

func newPortableResourceHosts(configFile string, enableAsyncWorker bool) ([]hosting.Service, *hostoptions.HostOptions, error) {
hostings := []hosting.Service{}
options, err := hostoptions.NewHostOptionsFromEnvironment(configFile)
if err != nil {
return nil, nil, err
}
hostings = append(hostings, pr_frontend.NewService(options))
if enableAsyncWorker {
hostings = append(hostings, pr_backend.NewService(options))
}

return hostings, &options, nil
}
const serviceName = "radius"

func main() {
var configFile string
var enableAsyncWorker bool

var runPortableResource bool
var portableResourceConfigFile string

defaultConfig := fmt.Sprintf("radius-%s.yaml", hostoptions.Environment())
flag.StringVar(&configFile, "config-file", defaultConfig, "The service configuration file.")
flag.BoolVar(&enableAsyncWorker, "enable-asyncworker", true, "Flag to run async request process worker (for private preview and dev/test purpose).")

flag.BoolVar(&runPortableResource, "run-portableresource", true, "Flag to run portable resources RPs(for private preview and dev/test purpose).")
defaultPortableRsConfig := fmt.Sprintf("portableresource-%s.yaml", hostoptions.Environment())
flag.StringVar(&portableResourceConfigFile, "portableresource-config", defaultPortableRsConfig, "The service configuration file for portable resource providers.")

pflag.StringVar(&configFile, "config-file", defaultConfig, "The service configuration file.")
if configFile == "" {
log.Fatal("config-file is empty.") //nolint:forbidigo // this is OK inside the main function.
}

flag.Parse()
var portableResourceConfigFile string
defaultPortableRsConfig := fmt.Sprintf("portableresource-%s.yaml", hostoptions.Environment())
pflag.StringVar(&portableResourceConfigFile, "portableresource-config", defaultPortableRsConfig, "The service configuration file for portable resource providers.")

pflag.Parse()

options, err := hostoptions.NewHostOptionsFromEnvironment(configFile)
if err != nil {
log.Fatal(err) //nolint:forbidigo // this is OK inside the main function.
}
hostingSvc := []hosting.Service{frontend.NewService(options)}

hostingSvc := []hosting.Service{}

metricOptions := metricsservice.NewHostOptionsFromEnvironment(*options.Config)
metricOptions.Config.ServiceName = serviceName
Expand All @@ -99,7 +81,7 @@ func main() {
hostingSvc = append(hostingSvc, profilerservice.NewService(profilerOptions))
}

logger, flush, err := ucplog.NewLogger(logging.AppCoreLoggerName, &options.Config.Logging)
logger, flush, err := ucplog.NewLogger(serviceName, &options.Config.Logging)
if err != nil {
log.Fatal(err) //nolint:forbidigo // this is OK inside the main function.
}
Expand All @@ -108,22 +90,10 @@ func main() {
// Must set the logger before using controller-runtime.
runtimelog.SetLogger(logger)

if enableAsyncWorker {
logger.Info("Enable AsyncRequestProcessWorker.")
hostingSvc = append(hostingSvc, backend.NewService(options))
}

// Configure Portable Resources to run it with Applications.Core RP.
var portableResourceOpts *hostoptions.HostOptions
if runPortableResource && portableResourceConfigFile != "" {
logger.Info("Run Service for Portable Resource Providers.")
var portableResourceSvcs []hosting.Service
var err error
portableResourceSvcs, portableResourceOpts, err = newPortableResourceHosts(portableResourceConfigFile, enableAsyncWorker)
if err != nil {
log.Fatal(err) //nolint:forbidigo // this is OK inside the main function.
}
hostingSvc = append(hostingSvc, portableResourceSvcs...)
// Load portable resource config.
prOptions, err := hostoptions.NewHostOptionsFromEnvironment(portableResourceConfigFile)
if err != nil {
log.Fatal(err) //nolint:forbidigo // this is OK inside the main function.
}

if options.Config.StorageProvider.Provider == dataprovider.TypeETCD &&
Expand All @@ -135,13 +105,31 @@ func main() {
client := hosting.NewAsyncValue[etcdclient.Client]()
options.Config.StorageProvider.ETCD.Client = client
options.Config.SecretProvider.ETCD.Client = client
if portableResourceOpts != nil {
portableResourceOpts.Config.StorageProvider.ETCD.Client = client
portableResourceOpts.Config.SecretProvider.ETCD.Client = client
}

// Portable resource options
prOptions.Config.StorageProvider.ETCD.Client = client
prOptions.Config.SecretProvider.ETCD.Client = client

hostingSvc = append(hostingSvc, data.NewEmbeddedETCDService(data.EmbeddedETCDServiceOptions{ClientConfigSink: client}))
}

builders, err := builders(options)
if err != nil {
log.Fatal(err) //nolint:forbidigo // this is OK inside the main function.
}

hostingSvc = append(
hostingSvc,
server.NewAPIService(options, builders),
server.NewAsyncWorker(options, builders),

// Configure Portable Resources to run it with Applications.Core RP.
//
// This is temporary until we migrate these resources to use the new registration model.
pr_frontend.NewService(prOptions),
pr_backend.NewService(prOptions),
)

loggerValues := []any{}
host := &hosting.Host{
Services: hostingSvc,
Expand Down Expand Up @@ -190,3 +178,15 @@ func main() {
panic(err)
}
}

func builders(options hostoptions.HostOptions) ([]builder.Builder, error) {
config, err := controllerconfig.New(options)
if err != nil {
return nil, err
}

return []builder.Builder{
corerp_setup.SetupNamespace(config).GenerateBuilder(),
// Add resource provider builders...
}, nil
}
1 change: 1 addition & 0 deletions cmd/applications-rp/portableresource-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ storageProvider:
inmemory: true
queueProvider:
provider: inmemory
name: radiusportable
profilerProvider:
enabled: true
port: 6060
Expand Down
1 change: 1 addition & 0 deletions cmd/applications-rp/portableresource-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ storageProvider:
namespace: 'radius-testing'
queueProvider:
provider: "apiserver"
name: radiusportable
apiserver:
context: ''
namespace: 'radius-testing'
Expand Down
1 change: 1 addition & 0 deletions cmd/applications-rp/radius-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ storageProvider:
masterKey: set-me-in-a-different-way
queueProvider:
provider: inmemory
name: radius
profilerProvider:
enabled: true
port: 6060
Expand Down
1 change: 1 addition & 0 deletions cmd/applications-rp/radius-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ storageProvider:
inmemory: true
queueProvider:
provider: inmemory
name: radius
profilerProvider:
enabled: true
port: 6060
Expand Down
1 change: 1 addition & 0 deletions cmd/applications-rp/radius-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ storageProvider:
namespace: 'radius-testing'
queueProvider:
provider: "apiserver"
name: radius
apiserver:
context: ''
namespace: 'radius-testing'
Expand Down
1 change: 1 addition & 0 deletions cmd/ucpd/ucp-self-hosted-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ secretProvider:

queueProvider:
provider: "apiserver"
name: 'ucp'
apiserver:
context: ''
namespace: 'radius-testing'
Expand Down
2 changes: 2 additions & 0 deletions deploy/Chart/templates/rp/configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ data:
namespace: "radius-system"
queueProvider:
provider: "apiserver"
name: "radius"
apiserver:
context: ""
namespace: "radius-system"
Expand Down Expand Up @@ -66,6 +67,7 @@ data:
namespace: "radius-system"
queueProvider:
provider: "apiserver"
name: "radiusportable"
apiserver:
context: ""
namespace: "radius-system"
Expand Down
1 change: 0 additions & 1 deletion deploy/Chart/templates/rp/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ spec:
image: "{{ .Values.rp.image }}:{{ .Values.rp.tag | default $appversion }}"
args:
- --config-file=/etc/config/radius-self-host.yaml
- --run-portableresource
- --portableresource-config=/etc/config/portableresource-self-host.yaml
env:
- name: SKIP_ARM
Expand Down
6 changes: 5 additions & 1 deletion deploy/Chart/templates/ucp/configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ data:
provider: kubernetes
queueProvider:
provider: inmemory
provider: "apiserver"
name: "ucp"
apiserver:
context: ""
namespace: "radius-system"
profilerProvider:
enabled: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ storageProvider:
namespace: "radius-system"
queueProvider:
provider: "apiserver"
name: "radius"
apiserver:
context: ""
namespace: "radius-system"
Expand Down
2 changes: 1 addition & 1 deletion docs/ucp/aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ Many AWS resources have a generated name and the resource schema does not necess
To address this issue, we will introduce state storage in UCP. The user will specify a friendly name for the resource in the bicep file that is unique in the deployment scope (which will be the Radius resource group). UCP will create a mapping between the friendly name and the actual AWS resource deployed. After this point, UCP will use this mapping to determine if the resource with the particular friendly name is being created or updated.
The details of this design can be found at: https://microsoft.sharepoint.com/:w:/t/radiuscoreteam/Ef0J0DM89-1Foyb36i4_a_EBn4zW61Dk8paVfJ9p9RUDOg?e=9tnaV1
The details of this design can be found at: https://github.com/radius-project/design-notes/pull/21
9 changes: 0 additions & 9 deletions docs/ucp/references.md

This file was deleted.

2 changes: 1 addition & 1 deletion docs/ucp/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ UCP uses a Plane resource to support ids that come from different types of syste
A resource group is used to organize user resources. Note that even though conceptually this is similar to an Azure resource group but it is not the same and is a UCP resource independent of Azure.

### Credentials
A user can configure provider credentials in UCP. Currently Azure and AWS credentials are supported. Please refer to [Credential Design Document](https://microsoft.sharepoint.com/:w:/t/radiuscoreteam/EVAuQrRK6tRIqiOZmjnyxjoBUfaa2jF2uiV-jhibg5qB5A?e=2t2hef) for details.
A user can configure provider credentials in UCP. Currently Azure and AWS credentials are supported and can be managed using "rad credential" CLI commands.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ require (
github.com/wI2L/jsondiff v0.2.0
go.etcd.io/etcd/client/v3 v3.5.9
go.etcd.io/etcd/server/v3 v3.5.9
go.mongodb.org/mongo-driver v1.12.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.42.0
go.opentelemetry.io/contrib/instrumentation/runtime v0.42.0
go.opentelemetry.io/otel v1.16.0
Expand Down Expand Up @@ -98,6 +97,7 @@ require (
github.com/tidwall/gjson v1.14.0 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
go.mongodb.org/mongo-driver v1.12.0 // indirect
)

require (
Expand Down
2 changes: 1 addition & 1 deletion grafana/radius-resource-provider-dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -1922,7 +1922,7 @@
},
"editorMode": "code",
"exemplar": false,
"expr": "(sum(rate(recipe_operation_duration_count{operation_state=\"failed\"}[$__rate_interval])) by (recipe_template_path, operation_type)) / (sum(rate(recipe_operation_duration_count[$__rate_interval])) by (recipe_template_path, operation_type))",
"expr": "(sum(rate(recipe_operation_duration_count{operation_state!=\"success\"}[$__rate_interval])) by (recipe_template_path, operation_type)) / (sum(rate(recipe_operation_duration_count[$__rate_interval])) by (recipe_template_path, operation_type))",
"format": "time_series",
"instant": false,
"interval": "",
Expand Down
Loading

0 comments on commit 6439cba

Please sign in to comment.