@@ -238,7 +238,6 @@ func (h *handlers) installDevApp(ctx *fiber.Ctx) error {
238238
239239 token := ctx .Locals ("auth_token" ).(string )
240240
241-
242241 name , ok := app ["name" ]
243242 if ! ok {
244243 klog .Error ("app name is empty, " , app )
@@ -257,6 +256,7 @@ func (h *handlers) installDevApp(ctx *fiber.Ctx) error {
257256 }()
258257 err = UpdateDevAppState (username , name , deploying )
259258 if err != nil {
259+ klog .Errorf ("failed to update dev app state name=%s,err=%v" , name , err )
260260 return ctx .JSON (fiber.Map {
261261 "code" : http .StatusBadRequest ,
262262 "message" : fmt .Sprintf ("update app state err %v" , err ),
@@ -269,7 +269,7 @@ func (h *handlers) installDevApp(ctx *fiber.Ctx) error {
269269
270270 err = command .Lint ().WithDir (BaseDir ).Run (context .TODO (), username , name )
271271 if err != nil {
272-
272+ klog . Errorf ( "failed to lint app=%s, err=%v" , name , err )
273273 return ctx .JSON (fiber.Map {
274274 "code" : http .StatusBadRequest ,
275275 "message" : err .Error (),
@@ -299,6 +299,7 @@ func (h *handlers) installDevApp(ctx *fiber.Ctx) error {
299299 klog .Info ("preinstall, create a labeled namespace for webhook" )
300300 _ , err = container .CreateOrUpdateDevNamespace (ctx .Context (), h .kubeConfig , username , devName )
301301 if err != nil {
302+ klog .Errorf ("failed to check namespace %v" , err )
302303 return ctx .JSON (fiber.Map {
303304 "code" : http .StatusBadRequest ,
304305 "message" : fmt .Sprintf ("Check namespace failed: %v" , err ),
@@ -329,6 +330,7 @@ func (h *handlers) installDevApp(ctx *fiber.Ctx) error {
329330
330331 err = UpdateDevAppState (username , name , deployed )
331332 if err != nil {
333+ klog .Errorf ("failed to update app=%s state to deployed %v" , name , err )
332334 return ctx .JSON (fiber.Map {
333335 "code" : http .StatusBadRequest ,
334336 "message" : fmt .Sprintf ("update app state to deployed err %v" , err ),
@@ -354,6 +356,7 @@ func (h *handlers) downloadDevAppChart(ctx *fiber.Ctx) error {
354356
355357 buf , err := command .PackageChart ().WithDir (BaseDir ).Run (app )
356358 if err != nil {
359+ klog .Errorf ("failed to package app=%s chart %v" , app , err )
357360 return ctx .JSON (fiber.Map {
358361 "code" : http .StatusBadRequest ,
359362 "message" : fmt .Sprintf ("Package chart Failed: %v" , err ),
@@ -515,6 +518,7 @@ func (h *handlers) deleteDevApp(ctx *fiber.Ctx) error {
515518
516519 err = command .DeleteChart ().WithDir (BaseDir ).Run (name )
517520 if err != nil {
521+ klog .Errorf ("failed to delete chart %s, err=%v" , name , err )
518522 return ctx .JSON (fiber.Map {
519523 "code" : http .StatusBadRequest ,
520524 "message" : fmt .Sprintf ("Delete Chart Failed: %v" , err ),
@@ -610,6 +614,7 @@ func (h *handlers) lintDevAppChart(ctx *fiber.Ctx) error {
610614
611615 err := command .Lint ().WithDir (BaseDir ).Run (ctx .Context (), username , app )
612616 if err != nil {
617+ klog .Errorf ("failed to lint app %s, err=%v" , app , err )
613618 return ctx .JSON (fiber.Map {
614619 "code" : http .StatusBadRequest ,
615620 "message" : fmt .Sprintf ("Lint Failed: %v" , err ),
@@ -643,6 +648,7 @@ func (h *handlers) uninstall(ctx *fiber.Ctx) error {
643648 devName := name + "-dev"
644649 res , err := uninstall (devName , token )
645650 if err != nil {
651+ klog .Errorf ("failed to uninstall %s, err=%v" , devName , err )
646652 return ctx .JSON (fiber.Map {
647653 "code" : http .StatusBadRequest ,
648654 "message" : fmt .Sprintf ("Uninstall Failed: %v" , err ),
@@ -684,6 +690,7 @@ func (h *handlers) createAppByArchive(ctx *fiber.Ctx) error {
684690 uniqueId := strings .ReplaceAll (uuid .NewString (), "-" , "" )
685691 err = UnArchive (filepath .Join ("/tmp" , file .Filename ), filepath .Join ("/tmp" , uniqueId ))
686692 if err != nil {
693+ klog .Errorf ("failed to unarchive file %s, err=%v" , filepath .Join ("/tmp" , file .Filename ), err )
687694 return ctx .JSON (fiber.Map {
688695 "code" : http .StatusBadRequest ,
689696 "message" : fmt .Sprintf ("UnArchive failed: %v" , err ),
@@ -692,6 +699,7 @@ func (h *handlers) createAppByArchive(ctx *fiber.Ctx) error {
692699
693700 cfg , err := readCfgFromFile (username , filepath .Join ("/tmp" , uniqueId ))
694701 if err != nil {
702+ klog .Errorf ("failed to read cfg from file %v" , err )
695703 return ctx .JSON (fiber.Map {
696704 "code" : http .StatusBadRequest ,
697705 "message" : fmt .Sprintf ("Read cfg frome file failed: %v" , err ),
@@ -706,6 +714,7 @@ func (h *handlers) createAppByArchive(ctx *fiber.Ctx) error {
706714
707715 err = command .Lint ().WithDir (filepath .Dir (chartDir )).Run (context .TODO (), username , filepath .Base (chartDir ))
708716 if err != nil {
717+ klog .Errorf ("lint failed %v" , err )
709718 return ctx .JSON (fiber.Map {
710719 "code" : http .StatusBadRequest ,
711720 "message" : fmt .Sprintf ("Lint failed: %v" , err ),
@@ -753,6 +762,7 @@ func (h *handlers) createAppByArchive(ctx *fiber.Ctx) error {
753762 }
754763 appID , err = InsertDevApp (& appData )
755764 if err != nil {
765+ klog .Errorf ("failed to insert app %s,err=%v" , cfg .Metadata .Name , err )
756766 return ctx .JSON (fiber.Map {
757767 "code" : http .StatusBadRequest ,
758768 "message" : fmt .Sprintf ("Insert app failed: %v" , err ),
@@ -767,6 +777,7 @@ func (h *handlers) createAppByArchive(ctx *fiber.Ctx) error {
767777 if err != nil {
768778 klog .Error (e )
769779 }
780+ klog .Errorf ("failed to copy app dir %v" , err )
770781 return ctx .JSON (fiber.Map {
771782 "code" : http .StatusBadRequest ,
772783 "message" : fmt .Sprintf ("Copy app withdir failed: %v" , err ),
@@ -1035,6 +1046,7 @@ func (h *handlers) fillApp(ctx *fiber.Ctx) error {
10351046 }
10361047 appId , err := UpdateDevApp (username , cfg .Name , updates )
10371048 if err != nil {
1049+ klog .Errorf ("failed to update dev app %s, err=%v" , cfg .Name , err )
10381050 return ctx .JSON (fiber.Map {
10391051 "code" : http .StatusBadRequest ,
10401052 "message" : fmt .Sprintf ("update app err %v" , err ),
@@ -1077,6 +1089,7 @@ func (h *handlers) fillAppWithExample(ctx *fiber.Ctx) error {
10771089 var app App
10781090 err := ctx .BodyParser (& app )
10791091 if err != nil {
1092+ klog .Errorf ("failed to parse body %v" , err )
10801093 return ctx .JSON (fiber.Map {
10811094 "code" : http .StatusBadRequest ,
10821095 "message" : fmt .Sprintf ("Bad Request: %v" , err ),
@@ -1104,6 +1117,7 @@ func (h *handlers) fillAppWithExample(ctx *fiber.Ctx) error {
11041117
11051118 appId , err := UpdateDevApp (username , name , updates )
11061119 if err != nil {
1120+ klog .Errorf ("failed to update app %s, err=%v" , name , err )
11071121 return ctx .JSON (fiber.Map {
11081122 "code" : http .StatusBadRequest ,
11091123 "message" : fmt .Sprintf ("update app err %v" , err ),
@@ -1169,6 +1183,7 @@ func (h *handlers) fillAppWithDevContainer(ctx *fiber.Ctx) error {
11691183
11701184 appId , err := UpdateDevApp (username , name , updates )
11711185 if err != nil {
1186+ klog .Errorf ("failed to update dev app %w,err=%v" , name , err )
11721187 return ctx .JSON (fiber.Map {
11731188 "code" : http .StatusBadRequest ,
11741189 "message" : fmt .Sprintf ("update app err %v" , err ),
@@ -1177,6 +1192,7 @@ func (h *handlers) fillAppWithDevContainer(ctx *fiber.Ctx) error {
11771192
11781193 containers , err := GetAppContainersInChart (username , name )
11791194 if err != nil || len (containers ) == 0 {
1195+ klog .Errorf ("failed to get app containers in chart err=%v, len(containers)=%d" , err , len (containers ))
11801196 return ctx .JSON (fiber.Map {
11811197 "code" : http .StatusBadRequest ,
11821198 "message" : fmt .Sprintf ("get bind containers err %v" , err ),
@@ -1194,6 +1210,7 @@ func (h *handlers) fillAppWithDevContainer(ctx *fiber.Ctx) error {
11941210 }
11951211 err = BindContainer (bindData )
11961212 if err != nil {
1213+ klog .Errorf ("failed to bind container app=%s,err=%v" , name , err )
11971214 e := h .db .DB .Where ("app_id = ?" , appId ).Delete (& model.DevAppContainers {}).Error
11981215 if e != nil && ! errors .Is (e , gorm .ErrRecordNotFound ) {
11991216 klog .Errorf ("delete devAppContainer app_id=%d err %v" , appId , e )
0 commit comments