forked from radius-project/radius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of user-defined-types (radius-project#7686)
This change implements the skeleton of user-defined types. The changes here enable the following: - Users can author a resource of type `System.Resources/resourceProviders` to create a user-defined-type. - Users can use the UCP API to register and query `resourceProviders`. - Users can use the UCP API to execute the full lifecycle of a user-defined-type. Right now the user-defined-type RP will use our default operation (synchronous) controllers to implement the resource lifecycle. There is no background processing. The next step will include the ability to execute asynchronous operations like recipes. - This pull request fixes a bug in Radius and has an approved issue (issue link required). - This pull request adds or changes features of Radius and has an approved issue (issue link required). Part of: radius-project#6688 **note: This change is going into a feature-branch where we can iterate on the user-defined-type design before integrating it with main. The PR is an FYI 😆.** --------- Signed-off-by: ytimocin <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: willdavsmith <[email protected]> Signed-off-by: Ryan Nowak <[email protected]> Co-authored-by: Yetkin Timocin <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Will Smith <[email protected]> Signed-off-by: Ryan Nowak <[email protected]>
- Loading branch information
1 parent
d154add
commit 2b127e7
Showing
59 changed files
with
2,821 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"log" | ||
"os" | ||
|
||
"github.com/go-logr/logr" | ||
"github.com/spf13/cobra" | ||
runtimelog "sigs.k8s.io/controller-runtime/pkg/log" | ||
|
||
"github.com/radius-project/radius/pkg/armrpc/hostoptions" | ||
"github.com/radius-project/radius/pkg/dynamicrp" | ||
"github.com/radius-project/radius/pkg/dynamicrp/server" | ||
"github.com/radius-project/radius/pkg/ucp/hosting" | ||
"github.com/radius-project/radius/pkg/ucp/ucplog" | ||
) | ||
|
||
var rootCmd = &cobra.Command{ | ||
Use: "dynamic-rp", | ||
Short: "Dyanamic Resource Provider server", | ||
Long: `Server process for the Dynamic Resource Provider (UCP).`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
configFilePath := cmd.Flag("config-file").Value.String() | ||
bs, err := os.ReadFile(configFilePath) | ||
if err != nil { | ||
return fmt.Errorf("failed to read config file %s: %w", configFilePath, err) | ||
} | ||
|
||
config, err := dynamicrp.LoadConfig(bs) | ||
if err != nil { | ||
return fmt.Errorf("failed to parse config file %s: %w", configFilePath, err) | ||
} | ||
|
||
options, err := dynamicrp.NewOptions(cmd.Context(), config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
logger, flush, err := ucplog.NewLogger(ucplog.LoggerName, &options.Config.Logging) | ||
if err != nil { | ||
log.Fatal(err) //nolint:forbidigo // this is OK inside the main function. | ||
} | ||
defer flush() | ||
|
||
// Must set the logger before using controller-runtime. | ||
runtimelog.SetLogger(logger) | ||
|
||
host, err := server.NewServer(options) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
ctx := logr.NewContext(cmd.Context(), logger) | ||
|
||
return hosting.RunWithInterrupts(ctx, host) | ||
}, | ||
} | ||
|
||
func Execute() { | ||
// Let users override the configuration via `--config-file`. | ||
rootCmd.Flags().String("config-file", fmt.Sprintf("dynamicrp-%s.yaml", hostoptions.Environment()), "The service configuration file.") | ||
|
||
cobra.CheckErr(rootCmd.ExecuteContext(context.Background())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# This is an example of configuration file. | ||
environment: | ||
name: Dev | ||
roleLocation: "global" | ||
storageProvider: | ||
provider: "etcd" | ||
etcd: | ||
inmemory: true | ||
queueProvider: | ||
provider: inmemory | ||
name: radius | ||
profilerProvider: | ||
enabled: true | ||
port: 6060 | ||
secretProvider: | ||
provider: etcd | ||
etcd: | ||
inmemory: true | ||
metricsProvider: | ||
prometheus: | ||
enabled: true | ||
path: "/metrics" | ||
port: 9090 | ||
featureFlags: | ||
- "PLACEHOLDER" | ||
server: | ||
host: "0.0.0.0" | ||
port: 8080 | ||
enableArmAuth: false | ||
workerServer: | ||
maxOperationConcurrency: 10 | ||
maxOperationRetryCount: 2 | ||
ucp: | ||
kind: kubernetes | ||
# Logging configuration | ||
logging: | ||
level: "info" | ||
json: false | ||
bicep: | ||
deleteRetryCount: 20 | ||
deleteRetryDelaySeconds: 60 | ||
terraform: | ||
path: "/terraform" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
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. | ||
*/ | ||
|
||
package main | ||
|
||
import "github.com/radius-project/radius/cmd/dynamic-rp/cmd" | ||
|
||
func main() { | ||
cmd.Execute() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.