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

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

View file

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

View file

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

View file

@ -15,14 +15,11 @@ import (
// CreateAppInstance creates a new application instance in the specified region // CreateAppInstance creates a new application instance in the specified region
// Maps to POST /auth/ctrl/CreateAppInst // Maps to POST /auth/ctrl/CreateAppInst
func (c *Client) CreateAppInstance(ctx context.Context, input *NewAppInstanceInput) error { 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() transport := c.getTransport()
url := c.BaseURL + "/api/v1/auth/ctrl/CreateAppInst" 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 { if err != nil {
return fmt.Errorf("CreateAppInstance failed: %w", err) return fmt.Errorf("CreateAppInstance failed: %w", err)
} }

View file

@ -16,7 +16,6 @@ type Client struct {
AuthProvider AuthProvider AuthProvider AuthProvider
RetryOpts RetryOptions RetryOpts RetryOptions
Logger Logger Logger Logger
CreateAppInstanceTimeout time.Duration
} }
// RetryOptions configures retry behavior for API calls // 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 // NewClient creates a new EdgeXR SDK client
func NewClient(baseURL string, options ...Option) *Client { func NewClient(baseURL string, options ...Option) *Client {
client := &Client{ client := &Client{
@ -96,7 +88,6 @@ func NewClient(baseURL string, options ...Option) *Client {
HTTPClient: &http.Client{Timeout: 30 * time.Second}, HTTPClient: &http.Client{Timeout: 30 * time.Second},
AuthProvider: NewNoAuthProvider(), AuthProvider: NewNoAuthProvider(),
RetryOpts: DefaultRetryOptions(), RetryOpts: DefaultRetryOptions(),
CreateAppInstanceTimeout: 10 * time.Minute,
} }
for _, opt := range options { for _, opt := range options {
@ -114,7 +105,6 @@ func NewClientWithCredentials(baseURL, username, password string, options ...Opt
HTTPClient: &http.Client{Timeout: 30 * time.Second}, HTTPClient: &http.Client{Timeout: 30 * time.Second},
AuthProvider: NewUsernamePasswordProvider(baseURL, username, password, nil), AuthProvider: NewUsernamePasswordProvider(baseURL, username, password, nil),
RetryOpts: DefaultRetryOptions(), RetryOpts: DefaultRetryOptions(),
CreateAppInstanceTimeout: 10 * time.Minute,
} }
for _, opt := range options { for _, opt := range options {

View file

@ -2,7 +2,7 @@
# How does it differ from the EdgeXR API? # How does it differ from the EdgeXR API?
kind: edgeconnect-deployment kind: edgeconnect-deployment
metadata: 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" appVersion: "1.0.0"
organization: "edp2" organization: "edp2"
spec: spec:
@ -15,7 +15,7 @@ spec:
infraTemplate: infraTemplate:
- region: "EU" - region: "EU"
cloudletOrg: "TelekomOP" cloudletOrg: "TelekomOP"
cloudletName: "Hamburg" cloudletName: "Munich"
flavorName: "EU.small" flavorName: "EU.small"
network: network:
outboundConnections: outboundConnections: