Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better logging for backend components #3939

Merged
merged 13 commits into from
Apr 18, 2023
1 change: 1 addition & 0 deletions litmus-portal/graphql-server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ require (
github.com/golang/protobuf v1.5.2
github.com/google/uuid v1.3.0
github.com/gorilla/websocket v1.5.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/jinzhu/copier v0.3.5
github.com/kelseyhightower/envconfig v1.4.0
github.com/litmuschaos/chaos-operator v0.0.0-20230109130222-de7c74a937a9
Expand Down
12 changes: 4 additions & 8 deletions litmus-portal/graphql-server/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,9 @@ github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfc
github.com/coreos/prometheus-operator v0.34.0/go.mod h1:Li6rMllG/hYIyXfMuvUwhyC+hqwJVHdsDdP21hypT1M=
github.com/coreos/prometheus-operator v0.38.1-0.20200424145508-7e176fda06cc/go.mod h1:erio69w1R/aC14D5nfvAXSlE8FT8jt2Hnavc50Dp33A=
github.com/coreos/rkt v1.30.0/go.mod h1:O634mlH6U7qk87poQifK6M2rsFNt+FyUTWNMnP1hF1U=
github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk=
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
github.com/cpuguy83/go-md2man/v2 v2.0.1 h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=
github.com/cpuguy83/go-md2man/v2 v2.0.1/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -1000,6 +998,8 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmg
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0/go.mod h1:f5nM7jw/oeRSadq3xCzHAvxcr8HZnzsqU6ILg/0NiiE=
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDaL56wXCB/5+wF6uHfaI=
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
github.com/grpc-ecosystem/grpc-gateway v1.9.4/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY=
Expand Down Expand Up @@ -1629,10 +1629,8 @@ github.com/rubenv/sql-migrate v0.0.0-20191025130928-9355dd04f4b3/go.mod h1:WS0rl
github.com/rubenv/sql-migrate v0.0.0-20200212082348-64f95ea68aa3/go.mod h1:rtQlpHw+eR6UrqaS3kX1VYeaCxzCVdimDS7g5Ln4pPc=
github.com/rubiojr/go-vhd v0.0.0-20200706105327-02e210299021/go.mod h1:DM5xW0nvfNNm2uytzsvhI3OnX8uzaRAg8UX/CnDqbto=
github.com/russross/blackfriday v0.0.0-20170610170232-067529f716f4/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
Expand Down Expand Up @@ -1782,10 +1780,8 @@ github.com/ultraware/funlen v0.0.1/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lP
github.com/ultraware/funlen v0.0.2/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
github.com/urfave/cli v0.0.0-20171014202726-7bc6a0acffa5/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.2 h1:gsqYFH8bb9ekPA12kRo0hfjngWQjkJPlN9R0N78BoUo=
github.com/urfave/cli v1.22.2/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
Expand Down Expand Up @@ -1923,6 +1919,7 @@ go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
go.uber.org/zap v1.14.1/go.mod h1:Mb2vm2krFEG5DV0W9qcHBYFtp/Wku1cvYaqPsS/WYfc=
go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo=
go.uber.org/zap v1.18.1/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.19.0/go.mod h1:xg/QME4nWcxGxrpdeYfq7UvYrLh66cuVKdrbD1XF/NI=
go.uber.org/zap v1.19.1/go.mod h1:j3DNczoxDZroyBnOT1L/Q79cfUMGZxlv/9dzN7SM1rI=
go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw=
Expand Down Expand Up @@ -2026,7 +2023,6 @@ golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20170114055629-f2499483f923/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -2286,6 +2282,7 @@ golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211029165221-6e7872819dc8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down Expand Up @@ -2437,7 +2434,6 @@ golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.6-0.20210820212750-d4cc65f0b2ff/go.mod h1:YD9qOF0M9xpSpdWTBbzEl5e/RnCefISl8E5Noe10jFM=
golang.org/x/tools v0.1.8/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
golang.org/x/tools v0.1.11/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
6 changes: 3 additions & 3 deletions litmus-portal/graphql-server/graph/analytics.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
analyticsOps "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/analytics/ops"
"github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/authorization"
data_store "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/data-store"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)

func (r *mutationResolver) CreateDataSource(ctx context.Context, datasource *model.DSInput) (*model.DSResponse, error) {
Expand Down Expand Up @@ -166,13 +166,13 @@ func (r *queryResolver) ListPortalDashboardData(ctx context.Context, projectID s
func (r *subscriptionResolver) ViewDashboard(ctx context.Context, dashboardID *string, promQueries []*model.PromQueryInput, dashboardQueryMap []*model.QueryMapForPanelGroup, dataVariables model.DataVars) (<-chan *model.DashboardPromResponse, error) {
dashboardData := make(chan *model.DashboardPromResponse)
viewID := uuid.New()
logrus.Printf("Dashboard view %v created\n", viewID.String())
log.Infof("dashboard view %v created\n", viewID.String())
data_store.Store.Mutex.Lock()
data_store.Store.DashboardData[viewID.String()] = dashboardData
data_store.Store.Mutex.Unlock()
go func() {
<-ctx.Done()
logrus.Printf("Closed dashboard view %v\n", viewID.String())
log.Infof("closed dashboard view %v\n", viewID.String())
if _, ok := data_store.Store.DashboardData[viewID.String()]; ok {
analyticsOps.UpdateViewedAt(dashboardID, viewID.String())

Expand Down
20 changes: 10 additions & 10 deletions litmus-portal/graphql-server/graph/cluster.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
clusterHandler "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/cluster/handler"
data_store "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/data-store"
dbOperationsCluster "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/database/mongodb/cluster"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"go.mongodb.org/mongo-driver/bson"
)

Expand Down Expand Up @@ -103,7 +103,7 @@ func (r *queryResolver) GetManifest(ctx context.Context, projectID string, clust
}

func (r *subscriptionResolver) GetClusterEvents(ctx context.Context, projectID string) (<-chan *model.ClusterEventResponse, error) {
logrus.Print("NEW EVENT ", projectID)
log.Info("new cluster event ", projectID)
clusterEvent := make(chan *model.ClusterEventResponse, 1)

data_store.Store.Mutex.Lock()
Expand All @@ -118,17 +118,17 @@ func (r *subscriptionResolver) GetClusterEvents(ctx context.Context, projectID s
}

func (r *subscriptionResolver) ClusterConnect(ctx context.Context, clusterInfo model.ClusterIdentity) (<-chan *model.ClusterActionResponse, error) {
logrus.Print("NEW CLUSTER CONNECT: ", clusterInfo.ClusterID)
log.Info("new cluster connect: ", clusterInfo.ClusterID)
clusterAction := make(chan *model.ClusterActionResponse, 1)
verifiedCluster, err := cluster.VerifyCluster(clusterInfo)
if err != nil {
logrus.Print("VALIDATION FAILED: ", clusterInfo.ClusterID)
log.Error("validation failed: ", clusterInfo.ClusterID)
return clusterAction, err
}
data_store.Store.Mutex.Lock()
if _, ok := data_store.Store.ConnectedCluster[clusterInfo.ClusterID]; ok {
data_store.Store.Mutex.Unlock()
return clusterAction, errors.New("CLUSTER ALREADY CONNECTED")
return clusterAction, errors.New("cluster already connected")
}
data_store.Store.ConnectedCluster[clusterInfo.ClusterID] = clusterAction
data_store.Store.Mutex.Unlock()
Expand All @@ -149,7 +149,7 @@ func (r *subscriptionResolver) ClusterConnect(ctx context.Context, clusterInfo m

err = dbOperationsCluster.UpdateCluster(query, update)
if err != nil {
logrus.Print("Error", err)
log.Error(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
log.Error(err)
log.Fatal(err)

}
}()

Expand All @@ -170,31 +170,31 @@ func (r *subscriptionResolver) ClusterConnect(ctx context.Context, clusterInfo m
}

func (r *subscriptionResolver) GetPodLog(ctx context.Context, request model.PodLogRequest) (<-chan *model.PodLogResponse, error) {
logrus.Print("NEW LOG REQUEST: ", request.ClusterID, request.PodName)
log.Info("new log request: ", request.ClusterID, request.PodName)
workflowLog := make(chan *model.PodLogResponse, 1)
reqID := uuid.New()
data_store.Store.Mutex.Lock()
data_store.Store.WorkflowLog[reqID.String()] = workflowLog
data_store.Store.Mutex.Unlock()
go func() {
<-ctx.Done()
logrus.Print("CLOSED LOG LISTENER: ", request.ClusterID, request.PodName)
log.Info("closed log listener: ", request.ClusterID, request.PodName)
delete(data_store.Store.WorkflowLog, reqID.String())
}()
go wfHandler.GetLogs(reqID.String(), request, *data_store.Store)
return workflowLog, nil
}

func (r *subscriptionResolver) GetKubeObject(ctx context.Context, request model.KubeObjectRequest) (<-chan *model.KubeObjectResponse, error) {
logrus.Print("NEW KUBEOBJECT REQUEST", request.ClusterID)
log.Info("new KubeObj request", request.ClusterID)
kubeObjData := make(chan *model.KubeObjectResponse)
reqID := uuid.New()
data_store.Store.Mutex.Lock()
data_store.Store.KubeObjectData[reqID.String()] = kubeObjData
data_store.Store.Mutex.Unlock()
go func() {
<-ctx.Done()
logrus.Println("Closed KubeObj Listener")
log.Info("closed KubeObj Listener")
delete(data_store.Store.KubeObjectData, reqID.String())
}()
go wfHandler.GetKubeObjData(reqID.String(), request, *data_store.Store)
Expand Down
17 changes: 11 additions & 6 deletions litmus-portal/graphql-server/graph/image_registry.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/litmuschaos/litmus/litmus-portal/graphql-server/graph/model"
"github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/authorization"
imageRegistryOps "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/image_registry/ops"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)

func (r *mutationResolver) CreateImageRegistry(ctx context.Context, projectID string, imageRegistryInfo model.ImageRegistryInput) (*model.ImageRegistryResponse, error) {
Expand All @@ -22,7 +22,8 @@ func (r *mutationResolver) CreateImageRegistry(ctx context.Context, projectID st

ciResponse, err := imageRegistryOps.CreateImageRegistry(ctx, projectID, imageRegistryInfo)
if err != nil {
logrus.Error(err)
log.Error(err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you convert all

if err != nil 

condition logs to log.Fatal?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @S-ayanide,
log.Fatal called os.Exit(1) so that process will exit with status set to 1. Is it okay?

https://pkg.go.dev/github.com/sirupsen/logrus#Fatal

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that is the expectation, if something in the middle goes wrong we'd want to terminate that function with a Fatal message.

@amityt correct me if I'm wrong.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No log.Fatal is not required here. It will impact the complete server. Rather a return statement can be added here in this error block.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use log.Fatal() to exit the process, k8s Deployment obj restarts the pod automatically. IMO, It's an unnecessary task. Moreover, all of the logs are deleted so we cannot analyze what is the problem.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, log.Fatal() should not be used here. 👍🏼

return nil, err
}
return ciResponse, err
}
Expand All @@ -37,7 +38,8 @@ func (r *mutationResolver) UpdateImageRegistry(ctx context.Context, imageRegistr

uiRegistry, err := imageRegistryOps.UpdateImageRegistry(ctx, imageRegistryID, projectID, imageRegistryInfo)
if err != nil {
logrus.Error(err)
log.Error(err)
namkyu1999 marked this conversation as resolved.
Show resolved Hide resolved
return nil, err
}

return uiRegistry, err
Expand All @@ -53,7 +55,8 @@ func (r *mutationResolver) DeleteImageRegistry(ctx context.Context, imageRegistr

diRegistry, err := imageRegistryOps.DeleteImageRegistry(ctx, imageRegistryID, projectID)
if err != nil {
logrus.Error(err)
log.Error(err)
namkyu1999 marked this conversation as resolved.
Show resolved Hide resolved
return "", err
}

return diRegistry, err
Expand All @@ -69,7 +72,8 @@ func (r *queryResolver) ListImageRegistry(ctx context.Context, projectID string)

imageRegistries, err := imageRegistryOps.ListImageRegistries(ctx, projectID)
if err != nil {
logrus.Error(err)
log.Error(err)
namkyu1999 marked this conversation as resolved.
Show resolved Hide resolved
return nil, err
}

return imageRegistries, err
Expand All @@ -85,7 +89,8 @@ func (r *queryResolver) GetImageRegistry(ctx context.Context, imageRegistryID st

imageRegistry, err := imageRegistryOps.GetImageRegistry(ctx, imageRegistryID, projectID)
if err != nil {
logrus.Error(err)
log.Error(err)
namkyu1999 marked this conversation as resolved.
Show resolved Hide resolved
return nil, err
}

return imageRegistry, err
Expand Down
8 changes: 4 additions & 4 deletions litmus-portal/graphql-server/graph/workflow.resolvers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/authorization"
wfHandler "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/chaos-workflow/handler"
data_store "github.com/litmuschaos/litmus/litmus-portal/graphql-server/pkg/data-store"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
)

func (r *mutationResolver) CreateChaosWorkFlow(ctx context.Context, request model.ChaosWorkFlowRequest) (*model.ChaosWorkFlowResponse, error) {
Expand All @@ -36,7 +36,7 @@ func (r *mutationResolver) ReRunChaosWorkFlow(ctx context.Context, projectID str
username, err := authorization.GetUsername(tkn)

if err != nil {
logrus.Print("Error getting username: ", err)
log.Error("error getting username: ", err)
return "", err
}

Expand Down Expand Up @@ -113,14 +113,14 @@ func (r *queryResolver) ListWorkflowRuns(ctx context.Context, request model.List
}

func (r *subscriptionResolver) GetWorkflowEvents(ctx context.Context, projectID string) (<-chan *model.WorkflowRun, error) {
logrus.Print("NEW WORKFLOW EVENT LISTENER: ", projectID)
log.Info("new workflow event listener: ", projectID)
workflowEvent := make(chan *model.WorkflowRun, 1)
data_store.Store.Mutex.Lock()
data_store.Store.WorkflowEventPublish[projectID] = append(data_store.Store.WorkflowEventPublish[projectID], workflowEvent)
data_store.Store.Mutex.Unlock()
go func() {
<-ctx.Done()
logrus.Print("CLOSED WORKFLOW LISTENER: ", projectID)
log.Info("closed workflow listener: ", projectID)
}()
return workflowEvent, nil
}
Expand Down