chore(http-timeout): removed timeout functionality when calling the API as it was not needed and malfunctional
All checks were successful
test / test (push) Successful in 1m19s
ci / goreleaser (push) Successful in 1m22s

This commit is contained in:
Stephan Lo 2025-10-17 12:01:47 +02:00
parent a037228b4b
commit 85a7db0d7c
5 changed files with 20 additions and 43 deletions

View file

@ -53,7 +53,6 @@ func newSDKClient() *edgeconnect.Client {
baseURL := viper.GetString("base_url")
username := viper.GetString("username")
password := viper.GetString("password")
createAppInstanceTimeout := viper.GetInt("create_app_instance_timeout")
err := validateBaseURL(baseURL)
if err != nil {
@ -61,20 +60,15 @@ func newSDKClient() *edgeconnect.Client {
os.Exit(1)
}
// Convert timeout from minutes to duration
timeout := time.Duration(createAppInstanceTimeout) * time.Minute
if username != "" && password != "" {
return edgeconnect.NewClientWithCredentials(baseURL, username, password,
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
edgeconnect.WithCreateAppInstanceTimeout(timeout),
)
}
// Fallback to no auth for now - in production should require auth
return edgeconnect.NewClient(baseURL,
edgeconnect.WithHTTPClient(&http.Client{Timeout: 30 * time.Second}),
edgeconnect.WithCreateAppInstanceTimeout(timeout),
)
}

View file

@ -13,7 +13,6 @@ var (
baseURL string
username string
password string
createAppInstanceTimeout int // timeout in minutes
)
// rootCmd represents the base command when called without any subcommands
@ -40,12 +39,10 @@ func init() {
rootCmd.PersistentFlags().StringVar(&baseURL, "base-url", "", "base URL for the Edge Connect API")
rootCmd.PersistentFlags().StringVar(&username, "username", "", "username for authentication")
rootCmd.PersistentFlags().StringVar(&password, "password", "", "password for authentication")
rootCmd.PersistentFlags().IntVar(&createAppInstanceTimeout, "create-app-instance-timeout", 10, "timeout in minutes for CreateAppInstance operations")
viper.BindPFlag("base_url", rootCmd.PersistentFlags().Lookup("base-url"))
viper.BindPFlag("username", rootCmd.PersistentFlags().Lookup("username"))
viper.BindPFlag("password", rootCmd.PersistentFlags().Lookup("password"))
viper.BindPFlag("create_app_instance_timeout", rootCmd.PersistentFlags().Lookup("create-app-instance-timeout"))
}
func initConfig() {
@ -54,7 +51,6 @@ func initConfig() {
viper.BindEnv("base_url", "EDGE_CONNECT_BASE_URL")
viper.BindEnv("username", "EDGE_CONNECT_USERNAME")
viper.BindEnv("password", "EDGE_CONNECT_PASSWORD")
viper.BindEnv("create_app_instance_timeout", "EDGE_CONNECT_CREATE_APP_INSTANCE_TIMEOUT")
if cfgFile != "" {
viper.SetConfigFile(cfgFile)

View file

@ -15,14 +15,11 @@ import (
// CreateAppInstance creates a new application instance in the specified region
// Maps to POST /auth/ctrl/CreateAppInst
func (c *Client) CreateAppInstance(ctx context.Context, input *NewAppInstanceInput) error {
// Apply CreateAppInstance-specific timeout
timeoutCtx, cancel := context.WithTimeout(ctx, c.CreateAppInstanceTimeout)
defer cancel()
transport := c.getTransport()
url := c.BaseURL + "/api/v1/auth/ctrl/CreateAppInst"
resp, err := transport.Call(timeoutCtx, "POST", url, input)
resp, err := transport.Call(ctx, "POST", url, input)
if err != nil {
return fmt.Errorf("CreateAppInstance failed: %w", err)
}

View file

@ -16,7 +16,6 @@ type Client struct {
AuthProvider AuthProvider
RetryOpts RetryOptions
Logger Logger
CreateAppInstanceTimeout time.Duration
}
// RetryOptions configures retry behavior for API calls
@ -82,13 +81,6 @@ func WithLogger(logger Logger) Option {
}
}
// WithCreateAppInstanceTimeout sets the timeout for CreateAppInstance operations
func WithCreateAppInstanceTimeout(timeout time.Duration) Option {
return func(c *Client) {
c.CreateAppInstanceTimeout = timeout
}
}
// NewClient creates a new EdgeXR SDK client
func NewClient(baseURL string, options ...Option) *Client {
client := &Client{
@ -96,7 +88,6 @@ func NewClient(baseURL string, options ...Option) *Client {
HTTPClient: &http.Client{Timeout: 30 * time.Second},
AuthProvider: NewNoAuthProvider(),
RetryOpts: DefaultRetryOptions(),
CreateAppInstanceTimeout: 10 * time.Minute,
}
for _, opt := range options {
@ -114,7 +105,6 @@ func NewClientWithCredentials(baseURL, username, password string, options ...Opt
HTTPClient: &http.Client{Timeout: 30 * time.Second},
AuthProvider: NewUsernamePasswordProvider(baseURL, username, password, nil),
RetryOpts: DefaultRetryOptions(),
CreateAppInstanceTimeout: 10 * time.Minute,
}
for _, opt := range options {

View file

@ -2,7 +2,7 @@
# How does it differ from the EdgeXR API?
kind: edgeconnect-deployment
metadata:
name: "edge-app-test" # name could be used for appName
name: "edge-app-demo" # name could be used for appName
appVersion: "1.0.0"
organization: "edp2"
spec:
@ -15,7 +15,7 @@ spec:
infraTemplate:
- region: "EU"
cloudletOrg: "TelekomOP"
cloudletName: "Hamburg"
cloudletName: "Munich"
flavorName: "EU.small"
network:
outboundConnections: