Skip to content

Commit 800b0dc

Browse files
oktalzGopher Bot
authored andcommitted
CLEANUP/MINOR: replace panic with graceful exit on job errors
Replaced panic calls with standard error printing to stderr and os.Exit(1) during CRD and Gateway API installation jobs. This prevents messy stack traces from polluting the logs when an installation step fails, providing cleaner and more user-friendly error output.
1 parent cdb5d1b commit 800b0dc

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

cmd/controller/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,17 @@ func main() {
4949

5050
if hugConfig.JobCheckCRD {
5151
if err := jobs.CRDInstall(hugConfig.External.External); err != nil {
52-
panic(err)
52+
fmt.Fprintln(os.Stderr, err)
53+
os.Exit(1)
5354
}
5455
fmt.Println("CRD refresh job completed successfully")
5556
return
5657
}
5758

5859
if hugConfig.JobGWAPI != "" {
5960
if err := jobs.GWAPIInstall(hugConfig.External.External, hugConfig.JobGWAPI); err != nil {
60-
panic(err)
61+
fmt.Fprintln(os.Stderr, err)
62+
os.Exit(1)
6163
}
6264
fmt.Println("Gateway API CRD installation completed successfully")
6365
return

hug/jobs/gwapi.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ func GWAPIInstall(external bool, version string) error {
5353
return err
5454
}
5555

56-
clientset := apiextensionsclientset.NewForConfigOrDie(config)
56+
clientset, err := apiextensionsclientset.NewForConfig(config)
57+
if err != nil {
58+
return fmt.Errorf("failed to create API extensions client: %w", err)
59+
}
5760

5861
// Parse the multi-document YAML into individual CRD documents
5962
crds := splitYAMLDocuments(data)

0 commit comments

Comments
 (0)