Skip to content

Commit

Permalink
skipper: improve createDataClients errors (#3260)
Browse files Browse the repository at this point in the history
* add context message to returned errors
* remove duplicate logging - errors will be logged by the caller (main)

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov authored and Pushpalanka committed Oct 11, 2024
1 parent 130daa4 commit 1cc36ab
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions skipper.go
Original file line number Diff line number Diff line change
Expand Up @@ -1038,8 +1038,7 @@ func createDataClients(o Options, cr *certregistry.CertRegistry) ([]routing.Data
for _, rf := range strings.Split(o.RoutesFile, ",") {
f, err := eskipfile.Open(rf)
if err != nil {
log.Error("error while opening eskip file", err)
return nil, err
return nil, fmt.Errorf("error while opening eskip file: %w", err)
}

clients = append(clients, f)
Expand All @@ -1060,8 +1059,7 @@ func createDataClients(o Options, cr *certregistry.CertRegistry) ([]routing.Data
HTTPTimeout: o.SourcePollTimeout,
})
if err != nil {
log.Errorf("error while loading routes from url %s: %s", url, err)
return nil, err
return nil, fmt.Errorf("error while loading routes from url %s: %w", url, err)
}
clients = append(clients, client)
}
Expand All @@ -1070,8 +1068,7 @@ func createDataClients(o Options, cr *certregistry.CertRegistry) ([]routing.Data
if o.InlineRoutes != "" {
ir, err := routestring.New(o.InlineRoutes)
if err != nil {
log.Error("error while parsing inline routes", err)
return nil, err
return nil, fmt.Errorf("error while parsing inline routes: %w", err)
}

clients = append(clients, ir)
Expand All @@ -1089,7 +1086,7 @@ func createDataClients(o Options, cr *certregistry.CertRegistry) ([]routing.Data
})

if err != nil {
return nil, err
return nil, fmt.Errorf("error while creating etcd client: %w", err)
}

clients = append(clients, etcdClient)
Expand All @@ -1101,7 +1098,7 @@ func createDataClients(o Options, cr *certregistry.CertRegistry) ([]routing.Data

kubernetesClient, err := kubernetes.New(kops)
if err != nil {
return nil, err
return nil, fmt.Errorf("error while creating kubernetes data client: %w", err)
}
clients = append(clients, kubernetesClient)
}
Expand Down

0 comments on commit 1cc36ab

Please sign in to comment.