From 2ffc76f7b2bd196f2e586b7fff9ada4867403bcb Mon Sep 17 00:00:00 2001 From: rohith-raju Date: Sat, 3 Sep 2022 09:45:17 +0530 Subject: [PATCH 1/3] propogate changes to nginx-sm --- go.mod | 4 ++-- go.sum | 12 ++++++++---- main.go | 6 ++++-- nginx/nginx.go | 23 ++++++++++++----------- nginx/oam.go | 26 ++++++++++++++++++++++++-- 5 files changed, 50 insertions(+), 21 deletions(-) diff --git a/go.mod b/go.mod index 7aa4e1a..bcdab70 100644 --- a/go.mod +++ b/go.mod @@ -10,8 +10,8 @@ replace ( ) require ( - github.com/layer5io/meshery-adapter-library v0.5.9 - github.com/layer5io/meshkit v0.5.31 + github.com/layer5io/meshery-adapter-library v0.5.10 + github.com/layer5io/meshkit v0.5.37 github.com/layer5io/service-mesh-performance v0.3.4 gopkg.in/yaml.v2 v2.4.0 k8s.io/apimachinery v0.23.5 diff --git a/go.sum b/go.sum index 457b01c..42adb77 100644 --- a/go.sum +++ b/go.sum @@ -862,10 +862,14 @@ github.com/lann/ps v0.0.0-20150810152359-62de8c46ede0/go.mod h1:vmVJ0l/dxyfGW6Fm github.com/layer5io/kuttl v0.4.1-0.20200723152044-916f10574334/go.mod h1:UmrVd7x+bNVKrpmKgTtfRiTKHZeNPcMjQproJ0vGwhE= github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3e34 h1:QaViadDOBCMDUwYx78kfRvHMkzRVnh/GOhm3s2gxoP4= github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3e34/go.mod h1:BQPLwdJt7v7y0fXIejI4whR9zMyX07Wjt5xrbgEmHLw= -github.com/layer5io/meshery-adapter-library v0.5.9 h1:Zp79l4J8kMjML9zAQ4Xu4QiKM5q5HEGcv04Jjg+xWSA= -github.com/layer5io/meshery-adapter-library v0.5.9/go.mod h1:IvURQMnZHa3z0OTcUSPqCHUgTsW2x0/+KjCqpYfMbt0= -github.com/layer5io/meshkit v0.5.31 h1:z6U3Ggp0sJaU47j/l8MClCgmkm7cZwJssYHpk/eorPI= -github.com/layer5io/meshkit v0.5.31/go.mod h1:dt0uOluDzatK6hbJEDAZbUsm7LJNb4nsXXaGUDtYxD0= +github.com/layer5io/meshery-adapter-library v0.5.10 h1:Qgr6vDx2s10mkhtk7Mnz5I73m/9yf2yyjCkPMeB4jmA= +github.com/layer5io/meshery-adapter-library v0.5.10/go.mod h1:Sg6WNN82uRo2kiFDEMc/LM/AJ/Pu6ZmBZGbFxZuC7zc= +github.com/layer5io/meshery-adapter-library v0.5.10 h1:Qgr6vDx2s10mkhtk7Mnz5I73m/9yf2yyjCkPMeB4jmA= +github.com/layer5io/meshery-adapter-library v0.5.10/go.mod h1:Sg6WNN82uRo2kiFDEMc/LM/AJ/Pu6ZmBZGbFxZuC7zc= +github.com/layer5io/meshkit v0.5.37 h1:z6U3Ggp0sJaU47j/l8MClCgmkm7cZwJssYHpk/eorPI= +github.com/layer5io/meshkit v0.5.37/go.mod h1:dt0uOluDzatK6hbJEDAZbUsm7LJNb4nsXXaGUDtYxD0= +github.com/layer5io/meshkit v0.5.37 h1:EO0wXAI+eqAm+4uKSzFd50rDkr6nqQ17m1j0wmv9hQA= +github.com/layer5io/meshkit v0.5.37/go.mod h1:dt0uOluDzatK6hbJEDAZbUsm7LJNb4nsXXaGUDtYxD0= github.com/layer5io/service-mesh-performance v0.3.2-0.20210122142912-a94e0658b021/go.mod h1:W153amv8aHAeIWxO7b7d7Vibt9RhaEVh4Uh+RG+BumQ= github.com/layer5io/service-mesh-performance v0.3.4 h1:aw/elsx0wkry7SyiQRIj31wW7TPCP4YfhINdNOLXVg8= github.com/layer5io/service-mesh-performance v0.3.4/go.mod h1:W153amv8aHAeIWxO7b7d7Vibt9RhaEVh4Uh+RG+BumQ= diff --git a/main.go b/main.go index 23ed9b8..3e4ac70 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,7 @@ import ( "github.com/layer5io/meshery-adapter-library/api/grpc" configprovider "github.com/layer5io/meshery-adapter-library/config/provider" "github.com/layer5io/meshery-nginx/internal/config" + "github.com/layer5io/meshkit/utils/events" ) var ( @@ -85,11 +86,12 @@ func main() { // } // Initialize Handler intance - handler := nginx.New(cfg, log, kubeconfigHandler) + e := events.NewEventStreamer() + handler := nginx.New(cfg, log, kubeconfigHandler, e) handler = adapter.AddLogger(log, handler) service.Handler = handler - service.Channel = make(chan interface{}, 10) + service.EventStreamer = e service.StartedAt = time.Now() service.Version = version service.GitSHA = gitsha diff --git a/nginx/nginx.go b/nginx/nginx.go index 3afb34f..d2fe4dc 100644 --- a/nginx/nginx.go +++ b/nginx/nginx.go @@ -13,6 +13,7 @@ import ( "github.com/layer5io/meshkit/errors" "github.com/layer5io/meshkit/logger" "github.com/layer5io/meshkit/models" + "github.com/layer5io/meshkit/utils/events" "gopkg.in/yaml.v2" ) @@ -22,7 +23,7 @@ type Nginx struct { } // New initializes nginx handler. -func New(c adapterconfig.Handler, l logger.Handler, kc adapterconfig.Handler) adapter.Handler { +func New(c adapterconfig.Handler, l logger.Handler, kc adapterconfig.Handler, e *events.EventStreamer) adapter.Handler { return &Nginx{ Adapter: adapter.Adapter{ Config: c, @@ -33,7 +34,7 @@ func New(c adapterconfig.Handler, l logger.Handler, kc adapterconfig.Handler) ad } // ApplyOperation applies the operation on nginx -func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationRequest, hchan *chan interface{}) error { +func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationRequest) error { err := nginx.CreateKubeconfigs(opReq.K8sConfigs) if err != nil { return err @@ -64,12 +65,12 @@ func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationR version := string(operations[opReq.OperationName].Versions[0]) if stat, err = hh.installNginx(opReq.IsDeleteOperation, version, opReq.Namespace, kubeConfigs); err != nil { summary := fmt.Sprintf("Error while %s NGINX Service Mesh", stat) - hh.streamErr(summary, e, err) + hh.streamErr(summary, ee , err) return } ee.Summary = fmt.Sprintf("NGINX Service Mesh %s successfully", stat) ee.Details = fmt.Sprintf("NGINX Service Mesh is now %s.", stat) - hh.StreamInfo(e) + hh.StreamInfo(ee) }(nginx, e) case internalconfig.LabelNamespace: go func(hh *Nginx, ee *meshes.EventsResponse) { @@ -115,24 +116,24 @@ func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationR stat, err := hh.installSampleApp(opReq.Namespace, opReq.IsDeleteOperation, operations[opReq.OperationName].Templates, kubeConfigs) if err != nil { summary := fmt.Sprintf("Error while %s %s application", stat, appName) - hh.streamErr(summary, e, err) + hh.streamErr(summary, ee, err) return } ee.Summary = fmt.Sprintf("%s application %s successfully", appName, stat) ee.Details = fmt.Sprintf("The %s application is now %s.", appName, stat) - hh.StreamInfo(e) + hh.StreamInfo(ee) }(nginx, e) case common.CustomOperation: go func(hh *Nginx, ee *meshes.EventsResponse) { stat, err := hh.applyCustomOperation(opReq.Namespace, opReq.CustomBody, opReq.IsDeleteOperation, kubeConfigs) if err != nil { summary := fmt.Sprintf("Error while %s custom operation", stat) - hh.streamErr(summary, e, err) + hh.streamErr(summary, ee, err) return } ee.Summary = fmt.Sprintf("Manifest %s successfully", status.Deployed) ee.Details = "" - hh.StreamInfo(e) + hh.StreamInfo(ee) }(nginx, e) default: nginx.streamErr("Invalid operation", e, ErrOpInvalid) @@ -151,7 +152,7 @@ func (nginx *Nginx) CreateKubeconfigs(kubeconfigs []string) error { errs = append(errs, err) continue } - + mesh.SetChannel(hchan) // To have control over what exactly to take in on kubeconfig nginx.KubeconfigHandler.SetKey("kind", kconfig.Kind) nginx.KubeconfigHandler.SetKey("apiVersion", kconfig.APIVersion) @@ -187,11 +188,11 @@ func (nginx *Nginx) CreateKubeconfigs(kubeconfigs []string) error { } -func(nginx *Nginx) streamErr(summary string, e *meshes.EventsResponse, err error) { +func (nginx *Nginx) streamErr(summary string, e *meshes.EventsResponse, err error) { e.Summary = summary e.Details = err.Error() e.ErrorCode = errors.GetCode(err) e.ProbableCause = errors.GetCause(err) e.SuggestedRemediation = errors.GetRemedy(err) nginx.StreamErr(e, err) -} \ No newline at end of file +}p \ No newline at end of file diff --git a/nginx/oam.go b/nginx/oam.go index 0b76297..d568c54 100644 --- a/nginx/oam.go +++ b/nginx/oam.go @@ -5,8 +5,11 @@ import ( "fmt" "strings" + "github.com/google/uuid" "github.com/layer5io/meshery-adapter-library/adapter" + "github.com/layer5io/meshery-adapter-library/meshes" "github.com/layer5io/meshery-nginx/nginx/oam" + "github.com/layer5io/meshery-traefik-mesh/internal/config" "github.com/layer5io/meshkit/models/oam/core/v1alpha1" "gopkg.in/yaml.v2" ) @@ -73,29 +76,48 @@ type CompHandler func(*Nginx, v1alpha1.Component, bool, []string) (string, error func (nginx *Nginx) HandleComponents(comps []v1alpha1.Component, isDel bool, kubeconfigs []string) (string, error) { var errs []error var msgs []string + stat1 := "deploying" + stat2 := "deployed" + if isDel { + stat1 = "removing" + stat2 = "removed" + } compFuncMap := map[string]CompHandler{ "NginxMesh": handleComponentNginxMesh, } for _, comp := range comps { + ee := &meshes.EventsResponse{ + OperationId: uuid.New().String(), + Component: config.ServerConfig["type"], + ComponentName: config.ServerConfig["name"], + } fnc, ok := compFuncMap[comp.Spec.Type] if !ok { msg, err := handleNginxCoreComponents(nginx, comp, isDel, "", "", kubeconfigs) if err != nil { + ee.Summary = fmt.Sprint("Error while %s %s", stat1, comp.Spec.Type) + mesh.streamErr(ee.Summary, ee, err) errs = append(errs, err) continue } - + ee.Summary = fmt.Sprintf("%s %s successfully", comp.Spec.Type, stat2) + ee.Details = fmt.Sprintf("The %s is now %s.", comp.Spec.Type, stat2) + mesh.StreamInfo(ee) msgs = append(msgs, msg) continue } msg, err := fnc(nginx, comp, isDel, kubeconfigs) if err != nil { + ee.Summary = fmt.Sprintf("Error while %s %s", stat1, comp.Spec.Type) + mesh.streamErr(ee.Summary, ee, err) errs = append(errs, err) continue } - + ee.Summary = fmt.Sprintf("%s %s %s successfully", comp.Name, comp.Spec.Type, stat2) + ee.Details = fmt.Sprintf("The %s %s is now %s.", comp.Name, comp.Spec.Type, stat2) + mesh.StreamInfo(ee) msgs = append(msgs, msg) } if err := mergeErrors(errs); err != nil { From 3afaf6464f30995f97ea76efc5eb0fc7510471e5 Mon Sep 17 00:00:00 2001 From: Ruturaj Mohite Date: Sun, 4 Sep 2022 14:42:06 +0530 Subject: [PATCH 2/3] Minor fixes Signed-off-by: Ruturaj Mohite --- go.mod | 10 +++++----- go.sum | 18 +++++++++--------- nginx/nginx.go | 25 +++++++++++-------------- nginx/oam.go | 13 ++++++------- 4 files changed, 31 insertions(+), 35 deletions(-) diff --git a/go.mod b/go.mod index bcdab70..4a7165c 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ replace ( ) require ( + github.com/google/uuid v1.3.0 github.com/layer5io/meshery-adapter-library v0.5.10 github.com/layer5io/meshkit v0.5.37 github.com/layer5io/service-mesh-performance v0.3.4 @@ -38,11 +39,11 @@ require ( github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/chai2010/gettext-go v0.0.0-20160711120539-c6fed771bfd5 // indirect github.com/cockroachdb/apd/v2 v2.0.1 // indirect - github.com/containerd/containerd v1.6.1 // indirect + github.com/containerd/containerd v1.6.6 // indirect github.com/cyphar/filepath-securejoin v0.2.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/docker/cli v20.10.11+incompatible // indirect - github.com/docker/distribution v2.7.1+incompatible // indirect + github.com/docker/distribution v2.8.1+incompatible // indirect github.com/docker/docker v20.10.12+incompatible // indirect github.com/docker/docker-credential-helpers v0.6.4 // indirect github.com/docker/go-connections v0.4.0 // indirect @@ -68,7 +69,6 @@ require ( github.com/google/go-cmp v0.5.8 // indirect github.com/google/gofuzz v1.2.0 // indirect github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/google/uuid v1.3.0 // indirect github.com/googleapis/gnostic v0.5.5 // indirect github.com/gorilla/mux v1.8.0 // indirect github.com/gosuri/uitable v0.0.4 // indirect @@ -109,13 +109,13 @@ require ( github.com/morikuni/aec v1.0.0 // indirect github.com/mpvl/unique v0.0.0-20150818121801-cbe035fff7de // indirect github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.0.2 // indirect + github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 // indirect github.com/pelletier/go-toml v1.9.4 // indirect github.com/pelletier/go-toml/v2 v2.0.0-beta.8 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/pkg/errors v0.9.1 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/prometheus/client_golang v1.11.0 // indirect + github.com/prometheus/client_golang v1.11.1 // indirect github.com/prometheus/client_model v0.2.0 // indirect github.com/prometheus/common v0.30.0 // indirect github.com/prometheus/procfs v0.7.3 // indirect diff --git a/go.sum b/go.sum index 42adb77..62d229e 100644 --- a/go.sum +++ b/go.sum @@ -130,8 +130,8 @@ github.com/Microsoft/hcsshim v0.8.16/go.mod h1:o5/SZqmR7x9JNKsW3pu+nqHm0MF8vbA+V github.com/Microsoft/hcsshim v0.8.20/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= github.com/Microsoft/hcsshim v0.8.21/go.mod h1:+w2gRZ5ReXQhFOrvSQeNfhrYB/dg3oDwTOcER2fw4I4= github.com/Microsoft/hcsshim v0.8.23/go.mod h1:4zegtUJth7lAvFyc6cH2gGQ5B3OFQim01nnU2M8jKDg= -github.com/Microsoft/hcsshim v0.9.2 h1:wB06W5aYFfUB3IvootYAY2WnOmIdgPGfqSI6tufQNnY= github.com/Microsoft/hcsshim v0.9.2/go.mod h1:7pLA8lDk46WKDWlVsENo92gC0XFa8rbKfyFRBqxEbCc= +github.com/Microsoft/hcsshim v0.9.3 h1:k371PzBuRrz2b+ebGuI2nVgVhgsVX60jMfSw80NECxo= github.com/Microsoft/hcsshim/test v0.0.0-20201218223536-d3e5debf77da/go.mod h1:5hlzMzRKMLyo42nCZ9oml8AdTlq/0cvIaBv6tK1RehU= github.com/Microsoft/hcsshim/test v0.0.0-20210227013316-43a75bb4edd3/go.mod h1:mw7qgWloBUl75W/gVH3cQszUg1+gUITj7D6NY7ywVnY= github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= @@ -291,8 +291,9 @@ github.com/containerd/containerd v1.5.0-rc.0/go.mod h1:V/IXoMqNGgBlabz3tHD2TWDoT github.com/containerd/containerd v1.5.1/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g= github.com/containerd/containerd v1.5.7/go.mod h1:gyvv6+ugqY25TiXxcZC3L5yOeYgEw0QMhscqVp1AR9c= github.com/containerd/containerd v1.5.8/go.mod h1:YdFSv5bTFLpG2HIYmfqDpSYYTDX+mc5qtSuYx1YUb/s= -github.com/containerd/containerd v1.6.1 h1:oa2uY0/0G+JX4X7hpGCYvkp9FjUancz56kSNnb1sG3o= github.com/containerd/containerd v1.6.1/go.mod h1:1nJz5xCZPusx6jJU8Frfct988y0NpumIq9ODB0kLtoE= +github.com/containerd/containerd v1.6.6 h1:xJNPhbrmz8xAMDNoVjHy9YHtWwEQNS+CDkcIRh7t8Y0= +github.com/containerd/containerd v1.6.6/go.mod h1:ZoP1geJldzCVY3Tonoz7b1IXk8rIX0Nltt5QE4OMNk0= github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y= @@ -404,8 +405,9 @@ github.com/docker/cli v20.10.11+incompatible h1:tXU1ezXcruZQRrMP8RN2z9N91h+6egZT github.com/docker/cli v20.10.11+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/distribution v0.0.0-20190905152932-14b96e55d84c/go.mod h1:0+TTO4EOBfRPhZXAeF1Vu+W3hHZ8eLp8PgKVZlcvtFY= github.com/docker/distribution v2.7.1-0.20190205005809-0d3efadf0154+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= -github.com/docker/distribution v2.7.1+incompatible h1:a5mlkVzth6W5A4fOsS3D2EO5BUmsJpcB+cRlLU7cSug= github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= +github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= +github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w= github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v1.4.2-0.20190916154449-92cc603036dd/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker v1.4.2-0.20190924003213-a8608b5b67c7/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= @@ -864,10 +866,6 @@ github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3 github.com/layer5io/learn-layer5/smi-conformance v0.0.0-20210317075357-06b4f88b3e34/go.mod h1:BQPLwdJt7v7y0fXIejI4whR9zMyX07Wjt5xrbgEmHLw= github.com/layer5io/meshery-adapter-library v0.5.10 h1:Qgr6vDx2s10mkhtk7Mnz5I73m/9yf2yyjCkPMeB4jmA= github.com/layer5io/meshery-adapter-library v0.5.10/go.mod h1:Sg6WNN82uRo2kiFDEMc/LM/AJ/Pu6ZmBZGbFxZuC7zc= -github.com/layer5io/meshery-adapter-library v0.5.10 h1:Qgr6vDx2s10mkhtk7Mnz5I73m/9yf2yyjCkPMeB4jmA= -github.com/layer5io/meshery-adapter-library v0.5.10/go.mod h1:Sg6WNN82uRo2kiFDEMc/LM/AJ/Pu6ZmBZGbFxZuC7zc= -github.com/layer5io/meshkit v0.5.37 h1:z6U3Ggp0sJaU47j/l8MClCgmkm7cZwJssYHpk/eorPI= -github.com/layer5io/meshkit v0.5.37/go.mod h1:dt0uOluDzatK6hbJEDAZbUsm7LJNb4nsXXaGUDtYxD0= github.com/layer5io/meshkit v0.5.37 h1:EO0wXAI+eqAm+4uKSzFd50rDkr6nqQ17m1j0wmv9hQA= github.com/layer5io/meshkit v0.5.37/go.mod h1:dt0uOluDzatK6hbJEDAZbUsm7LJNb4nsXXaGUDtYxD0= github.com/layer5io/service-mesh-performance v0.3.2-0.20210122142912-a94e0658b021/go.mod h1:W153amv8aHAeIWxO7b7d7Vibt9RhaEVh4Uh+RG+BumQ= @@ -1039,8 +1037,9 @@ github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3I github.com/opencontainers/image-spec v1.0.0/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.0.2-0.20211117181255-693428a734f5/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= -github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM= github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= +github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799 h1:rc3tiVYb5z54aKaDfakKn0dDjIyPpTtszkjuMzyt7ec= +github.com/opencontainers/image-spec v1.0.3-0.20211202183452-c5a74bcca799/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/runc v0.0.0-20190115041553-12f6a991201f/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v0.1.1/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= github.com/opencontainers/runc v1.0.0-rc8.0.20190926000215-3e425f80a8c9/go.mod h1:qT5XzbpPznkRYVz/mWwUaVBUv2rmF59PVA73FjuZG0U= @@ -1096,8 +1095,9 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQP1xR9D75/vuwEF3g= github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0 h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s= +github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= github.com/prometheus/client_model v0.0.0-20171117100541-99fa1f4be8e5/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= diff --git a/nginx/nginx.go b/nginx/nginx.go index d2fe4dc..0d8b90d 100644 --- a/nginx/nginx.go +++ b/nginx/nginx.go @@ -29,6 +29,7 @@ func New(c adapterconfig.Handler, l logger.Handler, kc adapterconfig.Handler, e Config: c, Log: l, KubeconfigHandler: kc, + EventStreamer: e, }, } } @@ -40,7 +41,6 @@ func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationR return err } kubeConfigs := opReq.K8sConfigs - nginx.SetChannel(hchan); operations := make(adapter.Operations) err = nginx.Config.GetObject(adapter.OperationsKey, &operations) @@ -51,12 +51,11 @@ func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationR stat := status.Deploying e := &meshes.EventsResponse{ - OperationId: opReq.OperationID, - Summary: status.Deploying, - Details: status.None, - Component: internalconfig.ServerConfig["type"], + OperationId: opReq.OperationID, + Summary: status.Deploying, + Details: status.None, + Component: internalconfig.ServerConfig["type"], ComponentName: internalconfig.ServerConfig["name"], - } switch opReq.OperationName { @@ -65,7 +64,7 @@ func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationR version := string(operations[opReq.OperationName].Versions[0]) if stat, err = hh.installNginx(opReq.IsDeleteOperation, version, opReq.Namespace, kubeConfigs); err != nil { summary := fmt.Sprintf("Error while %s NGINX Service Mesh", stat) - hh.streamErr(summary, ee , err) + hh.streamErr(summary, ee, err) return } ee.Summary = fmt.Sprintf("NGINX Service Mesh %s successfully", stat) @@ -81,12 +80,12 @@ func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationR } if err != nil { summary := fmt.Sprintf("Error while labelling %s", opReq.Namespace) - hh.streamErr(summary, e, err) + hh.streamErr(summary, ee, err) return } ee.Summary = fmt.Sprintf("Label updated on %s namespace", opReq.Namespace) ee.Details = fmt.Sprintf("NGINX-INJECTION label %s on %s namespace", operation, opReq.Namespace) - hh.StreamInfo(e) + hh.StreamInfo(ee) }(nginx, e) case common.SmiConformanceOperation: go func(hh *Nginx, ee *meshes.EventsResponse) { @@ -103,12 +102,12 @@ func (nginx *Nginx) ApplyOperation(ctx context.Context, opReq adapter.OperationR }) if err != nil { summary := fmt.Sprintf("Error while %s %s test", status.Running, name) - hh.streamErr(summary, e, err) + hh.streamErr(summary, ee, err) return } ee.Summary = fmt.Sprintf("%s test %s successfully", name, status.Completed) ee.Details = "" - hh.StreamInfo(e) + hh.StreamInfo(ee) }(nginx, e) case common.BookInfoOperation, common.HTTPBinOperation, common.ImageHubOperation, common.EmojiVotoOperation: go func(hh *Nginx, ee *meshes.EventsResponse) { @@ -152,7 +151,6 @@ func (nginx *Nginx) CreateKubeconfigs(kubeconfigs []string) error { errs = append(errs, err) continue } - mesh.SetChannel(hchan) // To have control over what exactly to take in on kubeconfig nginx.KubeconfigHandler.SetKey("kind", kconfig.Kind) nginx.KubeconfigHandler.SetKey("apiVersion", kconfig.APIVersion) @@ -187,7 +185,6 @@ func (nginx *Nginx) CreateKubeconfigs(kubeconfigs []string) error { return mergeErrors(errs) } - func (nginx *Nginx) streamErr(summary string, e *meshes.EventsResponse, err error) { e.Summary = summary e.Details = err.Error() @@ -195,4 +192,4 @@ func (nginx *Nginx) streamErr(summary string, e *meshes.EventsResponse, err erro e.ProbableCause = errors.GetCause(err) e.SuggestedRemediation = errors.GetRemedy(err) nginx.StreamErr(e, err) -}p \ No newline at end of file +} diff --git a/nginx/oam.go b/nginx/oam.go index d568c54..0c14c32 100644 --- a/nginx/oam.go +++ b/nginx/oam.go @@ -8,15 +8,14 @@ import ( "github.com/google/uuid" "github.com/layer5io/meshery-adapter-library/adapter" "github.com/layer5io/meshery-adapter-library/meshes" + "github.com/layer5io/meshery-nginx/internal/config" "github.com/layer5io/meshery-nginx/nginx/oam" - "github.com/layer5io/meshery-traefik-mesh/internal/config" "github.com/layer5io/meshkit/models/oam/core/v1alpha1" "gopkg.in/yaml.v2" ) // ProcessOAM will handles the grpc invocation for handling OAM objects -func (nginx *Nginx) ProcessOAM(ctx context.Context, oamReq adapter.OAMRequest, hchan *chan interface{}) (string, error) { - nginx.SetChannel(hchan) +func (nginx *Nginx) ProcessOAM(ctx context.Context, oamReq adapter.OAMRequest) (string, error) { err := nginx.CreateKubeconfigs(oamReq.K8sConfigs) if err != nil { return "", err @@ -97,13 +96,13 @@ func (nginx *Nginx) HandleComponents(comps []v1alpha1.Component, isDel bool, kub msg, err := handleNginxCoreComponents(nginx, comp, isDel, "", "", kubeconfigs) if err != nil { ee.Summary = fmt.Sprint("Error while %s %s", stat1, comp.Spec.Type) - mesh.streamErr(ee.Summary, ee, err) + nginx.streamErr(ee.Summary, ee, err) errs = append(errs, err) continue } ee.Summary = fmt.Sprintf("%s %s successfully", comp.Spec.Type, stat2) ee.Details = fmt.Sprintf("The %s is now %s.", comp.Spec.Type, stat2) - mesh.StreamInfo(ee) + nginx.StreamInfo(ee) msgs = append(msgs, msg) continue } @@ -111,13 +110,13 @@ func (nginx *Nginx) HandleComponents(comps []v1alpha1.Component, isDel bool, kub msg, err := fnc(nginx, comp, isDel, kubeconfigs) if err != nil { ee.Summary = fmt.Sprintf("Error while %s %s", stat1, comp.Spec.Type) - mesh.streamErr(ee.Summary, ee, err) + nginx.streamErr(ee.Summary, ee, err) errs = append(errs, err) continue } ee.Summary = fmt.Sprintf("%s %s %s successfully", comp.Name, comp.Spec.Type, stat2) ee.Details = fmt.Sprintf("The %s %s is now %s.", comp.Name, comp.Spec.Type, stat2) - mesh.StreamInfo(ee) + nginx.StreamInfo(ee) msgs = append(msgs, msg) } if err := mergeErrors(errs); err != nil { From 53b2e4ed8b33d81a1eb7c4274614281f1c857ef8 Mon Sep 17 00:00:00 2001 From: Ruturaj Mohite <53974118+gr455@users.noreply.github.com> Date: Sun, 4 Sep 2022 14:57:24 +0530 Subject: [PATCH 3/3] Update oam.go Signed-off-by: Ruturaj Mohite <53974118+gr455@users.noreply.github.com> --- nginx/oam.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nginx/oam.go b/nginx/oam.go index 0c14c32..8e48614 100644 --- a/nginx/oam.go +++ b/nginx/oam.go @@ -95,7 +95,7 @@ func (nginx *Nginx) HandleComponents(comps []v1alpha1.Component, isDel bool, kub if !ok { msg, err := handleNginxCoreComponents(nginx, comp, isDel, "", "", kubeconfigs) if err != nil { - ee.Summary = fmt.Sprint("Error while %s %s", stat1, comp.Spec.Type) + ee.Summary = fmt.Sprintf("Error while %s %s", stat1, comp.Spec.Type) nginx.streamErr(ee.Summary, ee, err) errs = append(errs, err) continue