From 60692abf92f91616542db17ef0c7ac6d467b02b6 Mon Sep 17 00:00:00 2001 From: yodigos Date: Sun, 25 Aug 2024 12:54:07 +0300 Subject: [PATCH 01/10] Added Version to NGINX --- cli/cmd/install.go | 2 ++ .../instrumentation/instrumentlang/nginx.go | 10 ++++++++ .../pkg/kube/runtime_details/inspection.go | 2 +- procdiscovery/pkg/inspectors/langdetect.go | 11 +++++++-- procdiscovery/pkg/inspectors/nginx/nginx.go | 23 +++++++++++++++++++ 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 odiglet/pkg/instrumentation/instrumentlang/nginx.go diff --git a/cli/cmd/install.go b/cli/cmd/install.go index b0bb83201..06dde16e8 100644 --- a/cli/cmd/install.go +++ b/cli/cmd/install.go @@ -184,6 +184,7 @@ func otelSdkConfigCommunity() map[common.ProgrammingLanguage]common.OtelSdk { common.GoProgrammingLanguage: common.OtelSdkEbpfCommunity, common.DotNetProgrammingLanguage: common.OtelSdkNativeCommunity, common.JavascriptProgrammingLanguage: common.OtelSdkNativeCommunity, + common.NginxProgrammingLanguage: common.OtelSdkNativeCommunity, } } @@ -194,6 +195,7 @@ func otelSdkConfigCloud() map[common.ProgrammingLanguage]common.OtelSdk { common.GoProgrammingLanguage: common.OtelSdkEbpfEnterprise, common.DotNetProgrammingLanguage: common.OtelSdkNativeCommunity, common.JavascriptProgrammingLanguage: common.OtelSdkNativeCommunity, + common.NginxProgrammingLanguage: common.OtelSdkNativeCommunity, } } diff --git a/odiglet/pkg/instrumentation/instrumentlang/nginx.go b/odiglet/pkg/instrumentation/instrumentlang/nginx.go new file mode 100644 index 000000000..a7c344d74 --- /dev/null +++ b/odiglet/pkg/instrumentation/instrumentlang/nginx.go @@ -0,0 +1,10 @@ +package instrumentlang + +import ( + "github.com/odigos-io/odigos/common" + "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1" +) + +func Nginx(deviceId string, uniqueDestinationSignals map[common.ObservabilitySignal]struct{}) *v1beta1.ContainerAllocateResponse { + return &v1beta1.ContainerAllocateResponse{} +} diff --git a/odiglet/pkg/kube/runtime_details/inspection.go b/odiglet/pkg/kube/runtime_details/inspection.go index 5260cb598..82d3969a5 100644 --- a/odiglet/pkg/kube/runtime_details/inspection.go +++ b/odiglet/pkg/kube/runtime_details/inspection.go @@ -96,7 +96,7 @@ func runtimeInspection(pods []corev1.Pod, ignoredContainers []string) ([]odigosv var detectErr error for _, proc := range processes { - programLanguageDetails, detectErr = inspectors.DetectLanguage(proc) + programLanguageDetails, detectErr = inspectors.DetectLanguage(proc, pod.Status.PodIP) if detectErr == nil && programLanguageDetails.Language != common.UnknownProgrammingLanguage { inspectProc = &proc break diff --git a/procdiscovery/pkg/inspectors/langdetect.go b/procdiscovery/pkg/inspectors/langdetect.go index 5fd1d81d8..f641952f1 100644 --- a/procdiscovery/pkg/inspectors/langdetect.go +++ b/procdiscovery/pkg/inspectors/langdetect.go @@ -2,13 +2,13 @@ package inspectors import ( "fmt" - "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/nginx" "github.com/odigos-io/odigos/common" "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/dotnet" "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/golang" "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/java" "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/mysql" + "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/nginx" "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/nodejs" "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/python" "github.com/odigos-io/odigos/procdiscovery/pkg/process" @@ -39,7 +39,7 @@ var inspectorsList = []inspector{ // DetectLanguage returns the detected language for the process or // common.UnknownProgrammingLanguage if the language could not be detected, in which case error == nil // if error or language detectors disagree common.UnknownProgrammingLanguage is also returned -func DetectLanguage(process process.Details) (common.ProgramLanguageDetails, error) { +func DetectLanguage(process process.Details, podIp string) (common.ProgramLanguageDetails, error) { detectedProgramLanguageDetails := common.ProgramLanguageDetails{ Language: common.UnknownProgrammingLanguage, } @@ -62,5 +62,12 @@ func DetectLanguage(process process.Details) (common.ProgramLanguageDetails, err } } + if detectedProgramLanguageDetails.Language == common.NginxProgrammingLanguage { + runtimeVersion, err := nginx.GetNginxVersion(podIp) + if err == nil { + detectedProgramLanguageDetails.RuntimeVersion = runtimeVersion + } + } + return detectedProgramLanguageDetails, nil } diff --git a/procdiscovery/pkg/inspectors/nginx/nginx.go b/procdiscovery/pkg/inspectors/nginx/nginx.go index bb3722cc9..c0fa90964 100644 --- a/procdiscovery/pkg/inspectors/nginx/nginx.go +++ b/procdiscovery/pkg/inspectors/nginx/nginx.go @@ -1,6 +1,8 @@ package nginx import ( + "net/http" + "regexp" "strings" "github.com/odigos-io/odigos/common" @@ -22,3 +24,24 @@ func (j *NginxInspector) Inspect(p *process.Details) (common.ProgramLanguageDeta return programLanguageDetails, false } + +func GetNginxVersion(podIP string) (string, error) { + resp, err := http.Get("http://" + podIP) + if err != nil { + return "", nil + } + defer resp.Body.Close() + + serverHeader := resp.Header.Get("Server") + if serverHeader == "" { + return "", nil + } + + re := regexp.MustCompile(`nginx/(\d+\.\d+\.\d+)`) + match := re.FindStringSubmatch(serverHeader) + if len(match) != 2 { + return "", nil + } + + return match[1], nil +} From 4bda109bd27c69297ad1ecf72abc4ad7b1398097 Mon Sep 17 00:00:00 2001 From: yodigos Date: Sun, 25 Aug 2024 15:50:38 +0300 Subject: [PATCH 02/10] Separated Version with Inspect language --- procdiscovery/pkg/inspectors/dotnet/dotnet.go | 12 +++++----- procdiscovery/pkg/inspectors/golang/golang.go | 22 +++++++++++++------ procdiscovery/pkg/inspectors/java/java.go | 19 ++++++++-------- procdiscovery/pkg/inspectors/langdetect.go | 17 +++++--------- procdiscovery/pkg/inspectors/mysql/mysql.go | 12 +++++----- procdiscovery/pkg/inspectors/nginx/nginx.go | 17 +++++++++----- procdiscovery/pkg/inspectors/nodejs/nodejs.go | 19 ++++++++-------- procdiscovery/pkg/inspectors/python/python.go | 18 ++++++++------- 8 files changed, 77 insertions(+), 59 deletions(-) diff --git a/procdiscovery/pkg/inspectors/dotnet/dotnet.go b/procdiscovery/pkg/inspectors/dotnet/dotnet.go index ad5d0bb4a..21cd56557 100644 --- a/procdiscovery/pkg/inspectors/dotnet/dotnet.go +++ b/procdiscovery/pkg/inspectors/dotnet/dotnet.go @@ -16,16 +16,18 @@ const ( dotnet = "DOTNET" ) -func (d *DotnetInspector) Inspect(p *process.Details) (common.ProgramLanguageDetails, bool) { - var programLanguageDetails common.ProgramLanguageDetails +func (d *DotnetInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { data, err := os.ReadFile(fmt.Sprintf("/proc/%d/environ", p.ProcessID)) if err == nil { environ := string(data) if strings.Contains(environ, aspnet) || strings.Contains(environ, dotnet) { - programLanguageDetails.Language = common.DotNetProgrammingLanguage - return programLanguageDetails, true + return common.DotNetProgrammingLanguage, true } } - return programLanguageDetails, false + return "", false +} + +func (d *DotnetInspector) GetRuntimeVersion(p *process.Details, podIp string) string { + return "" } diff --git a/procdiscovery/pkg/inspectors/golang/golang.go b/procdiscovery/pkg/inspectors/golang/golang.go index 3bc04d421..dac2a0482 100644 --- a/procdiscovery/pkg/inspectors/golang/golang.go +++ b/procdiscovery/pkg/inspectors/golang/golang.go @@ -10,18 +10,26 @@ import ( type GolangInspector struct{} -func (g *GolangInspector) Inspect(p *process.Details) (common.ProgramLanguageDetails, bool) { - var programLanguageDetails common.ProgramLanguageDetails +func (g *GolangInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) - buildInfo, err := buildinfo.ReadFile(file) + _, err := buildinfo.ReadFile(file) if err != nil { - return programLanguageDetails, false + return "", false } - programLanguageDetails.Language = common.GoProgrammingLanguage + return common.GoProgrammingLanguage, true +} + +func (g *GolangInspector) GetRuntimeVersion(p *process.Details, podIp string) string { + var runtimeVersion string + file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) + buildInfo, err := buildinfo.ReadFile(file) + if err != nil { + return "" + } if buildInfo != nil { - programLanguageDetails.RuntimeVersion = buildInfo.GoVersion + runtimeVersion = buildInfo.GoVersion } - return programLanguageDetails, true + return runtimeVersion } diff --git a/procdiscovery/pkg/inspectors/java/java.go b/procdiscovery/pkg/inspectors/java/java.go index 8a275a3ff..d1497e904 100644 --- a/procdiscovery/pkg/inspectors/java/java.go +++ b/procdiscovery/pkg/inspectors/java/java.go @@ -11,17 +11,18 @@ type JavaInspector struct{} const processName = "java" -func (j *JavaInspector) Inspect(proc *process.Details) (common.ProgramLanguageDetails, bool) { - var programLanguageDetails common.ProgramLanguageDetails - +func (j *JavaInspector) Inspect(proc *process.Details) (common.ProgrammingLanguage, bool) { if strings.Contains(proc.ExeName, processName) || strings.Contains(proc.CmdLine, processName) { - programLanguageDetails.Language = common.JavaProgrammingLanguage - if value, exists := proc.GetDetailedEnvsValue(process.JavaVersionConst); exists { - programLanguageDetails.RuntimeVersion = value - } + return common.JavaProgrammingLanguage, true + } + + return "", false +} - return programLanguageDetails, true +func (j *JavaInspector) GetRuntimeVersion(proc *process.Details, podIp string) string { + if value, exists := proc.GetDetailedEnvsValue(process.JavaVersionConst); exists { + return value } - return programLanguageDetails, false + return "" } diff --git a/procdiscovery/pkg/inspectors/langdetect.go b/procdiscovery/pkg/inspectors/langdetect.go index f641952f1..05446d696 100644 --- a/procdiscovery/pkg/inspectors/langdetect.go +++ b/procdiscovery/pkg/inspectors/langdetect.go @@ -23,7 +23,8 @@ func (e ErrLanguageDetectionConflict) Error() string { } type inspector interface { - Inspect(process *process.Details) (common.ProgramLanguageDetails, bool) + Inspect(process *process.Details) (common.ProgrammingLanguage, bool) + GetRuntimeVersion(process *process.Details, podIp string) string } var inspectorsList = []inspector{ @@ -45,10 +46,11 @@ func DetectLanguage(process process.Details, podIp string) (common.ProgramLangua } for _, i := range inspectorsList { - languageDetails, detected := i.Inspect(&process) + languageDetected, detected := i.Inspect(&process) if detected { if detectedProgramLanguageDetails.Language == common.UnknownProgrammingLanguage { - detectedProgramLanguageDetails = languageDetails + detectedProgramLanguageDetails.Language = languageDetected + detectedProgramLanguageDetails.RuntimeVersion = i.GetRuntimeVersion(&process, podIp) continue } return common.ProgramLanguageDetails{ @@ -56,18 +58,11 @@ func DetectLanguage(process process.Details, podIp string) (common.ProgramLangua }, ErrLanguageDetectionConflict{ languages: [2]common.ProgrammingLanguage{ detectedProgramLanguageDetails.Language, - languageDetails.Language, + languageDetected, }, } } } - if detectedProgramLanguageDetails.Language == common.NginxProgrammingLanguage { - runtimeVersion, err := nginx.GetNginxVersion(podIp) - if err == nil { - detectedProgramLanguageDetails.RuntimeVersion = runtimeVersion - } - } - return detectedProgramLanguageDetails, nil } diff --git a/procdiscovery/pkg/inspectors/mysql/mysql.go b/procdiscovery/pkg/inspectors/mysql/mysql.go index ae141a8b6..e8ac43894 100644 --- a/procdiscovery/pkg/inspectors/mysql/mysql.go +++ b/procdiscovery/pkg/inspectors/mysql/mysql.go @@ -13,12 +13,14 @@ type MySQLInspector struct{} const MySQLProcessName = "mysqld" -func (j *MySQLInspector) Inspect(p *process.Details) (common.ProgramLanguageDetails, bool) { - var programLanguageDetails common.ProgramLanguageDetails +func (j *MySQLInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { if strings.HasSuffix(p.ExeName, MySQLProcessName) || strings.HasSuffix(p.CmdLine, MySQLProcessName) { - programLanguageDetails.Language = common.MySQLProgrammingLanguage - return programLanguageDetails, true + return common.MySQLProgrammingLanguage, true } - return programLanguageDetails, false + return "", false +} + +func (j *MySQLInspector) GetRuntimeVersion(p *process.Details, podIp string) string { + return "" } diff --git a/procdiscovery/pkg/inspectors/nginx/nginx.go b/procdiscovery/pkg/inspectors/nginx/nginx.go index c0fa90964..c44ac0e1a 100644 --- a/procdiscovery/pkg/inspectors/nginx/nginx.go +++ b/procdiscovery/pkg/inspectors/nginx/nginx.go @@ -15,14 +15,21 @@ type NginxInspector struct{} const NginxProcessName = "nginx" -func (j *NginxInspector) Inspect(p *process.Details) (common.ProgramLanguageDetails, bool) { - var programLanguageDetails common.ProgramLanguageDetails +func (j *NginxInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { if strings.Contains(p.CmdLine, NginxProcessName) || strings.Contains(p.ExeName, NginxProcessName) { - programLanguageDetails.Language = common.NginxProgrammingLanguage - return programLanguageDetails, true + return common.NginxProgrammingLanguage, true } - return programLanguageDetails, false + return "", false +} + +func (j *NginxInspector) GetRuntimeVersion(p *process.Details, podIp string) string { + version, err := GetNginxVersion(podIp) + if err != nil { + return "" + } + + return version } func GetNginxVersion(podIP string) (string, error) { diff --git a/procdiscovery/pkg/inspectors/nodejs/nodejs.go b/procdiscovery/pkg/inspectors/nodejs/nodejs.go index 378617a94..39fc71cd3 100644 --- a/procdiscovery/pkg/inspectors/nodejs/nodejs.go +++ b/procdiscovery/pkg/inspectors/nodejs/nodejs.go @@ -11,17 +11,18 @@ type NodejsInspector struct{} const nodeProcessName = "node" -func (n *NodejsInspector) Inspect(proc *process.Details) (common.ProgramLanguageDetails, bool) { - var programLanguageDetails common.ProgramLanguageDetails - +func (n *NodejsInspector) Inspect(proc *process.Details) (common.ProgrammingLanguage, bool) { if strings.Contains(proc.ExeName, nodeProcessName) || strings.Contains(proc.CmdLine, nodeProcessName) { - programLanguageDetails.Language = common.JavascriptProgrammingLanguage - if value, exists := proc.GetDetailedEnvsValue(process.NodeVersionConst); exists { - programLanguageDetails.RuntimeVersion = value - } + return common.JavascriptProgrammingLanguage, true + } + + return "", false +} - return programLanguageDetails, true +func (n *NodejsInspector) GetRuntimeVersion(proc *process.Details, podIp string) string { + if version, exists := proc.GetDetailedEnvsValue(process.NodeVersionConst); exists { + return version } - return programLanguageDetails, false + return "" } diff --git a/procdiscovery/pkg/inspectors/python/python.go b/procdiscovery/pkg/inspectors/python/python.go index dcdad063a..ae9d34242 100644 --- a/procdiscovery/pkg/inspectors/python/python.go +++ b/procdiscovery/pkg/inspectors/python/python.go @@ -11,16 +11,18 @@ type PythonInspector struct{} const pythonProcessName = "python" -func (p *PythonInspector) Inspect(proc *process.Details) (common.ProgramLanguageDetails, bool) { - var programLanguageDetails common.ProgramLanguageDetails +func (p *PythonInspector) Inspect(proc *process.Details) (common.ProgrammingLanguage, bool) { if strings.Contains(proc.ExeName, pythonProcessName) || strings.Contains(proc.CmdLine, pythonProcessName) { - programLanguageDetails.Language = common.PythonProgrammingLanguage - if value, exists := proc.GetDetailedEnvsValue(process.PythonVersionConst); exists { - programLanguageDetails.RuntimeVersion = value - } + return common.PythonProgrammingLanguage, true + } + + return "", false +} - return programLanguageDetails, true +func (p *PythonInspector) GetRuntimeVersion(proc *process.Details, podIp string) string { + if value, exists := proc.GetDetailedEnvsValue(process.PythonVersionConst); exists { + return value } - return programLanguageDetails, false + return "" } From 22b72649d2e9b4bc50c0871af93ccb0d644ea80c Mon Sep 17 00:00:00 2001 From: yodigos Date: Sun, 25 Aug 2024 15:53:44 +0300 Subject: [PATCH 03/10] Separated Version with Inspect language --- odiglet/cmd/main.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/odiglet/cmd/main.go b/odiglet/cmd/main.go index ed735216c..4fcd9d295 100644 --- a/odiglet/cmd/main.go +++ b/odiglet/cmd/main.go @@ -127,6 +127,9 @@ func startDeviceManager(clientset *kubernetes.Clientset) { common.DotNetProgrammingLanguage: { common.OtelSdkNativeCommunity: instrumentlang.DotNet, }, + common.NginxProgrammingLanguage: { + common.OtelSdkNativeCommunity: instrumentlang.Nginx, + }, } lister, err := instrumentation.NewLister(ctx, clientset, otelSdkLsf) From d2539ae703b825d6b33e0347abcd564f0defefe6 Mon Sep 17 00:00:00 2001 From: yodigos Date: Sun, 25 Aug 2024 18:52:36 +0300 Subject: [PATCH 04/10] Separated Version with Inspect language --- odiglet/pkg/kube/runtime_details/inspection.go | 3 ++- odiglet/pkg/kube/utils/utils.go | 8 ++++++++ procdiscovery/pkg/inspectors/dotnet/dotnet.go | 2 +- procdiscovery/pkg/inspectors/golang/golang.go | 2 +- procdiscovery/pkg/inspectors/java/java.go | 2 +- procdiscovery/pkg/inspectors/langdetect.go | 6 +++--- procdiscovery/pkg/inspectors/mysql/mysql.go | 2 +- procdiscovery/pkg/inspectors/nginx/nginx.go | 11 +++++++---- procdiscovery/pkg/inspectors/nodejs/nodejs.go | 2 +- procdiscovery/pkg/inspectors/python/python.go | 2 +- 10 files changed, 26 insertions(+), 14 deletions(-) diff --git a/odiglet/pkg/kube/runtime_details/inspection.go b/odiglet/pkg/kube/runtime_details/inspection.go index 82d3969a5..7cbbb7ba7 100644 --- a/odiglet/pkg/kube/runtime_details/inspection.go +++ b/odiglet/pkg/kube/runtime_details/inspection.go @@ -96,7 +96,8 @@ func runtimeInspection(pods []corev1.Pod, ignoredContainers []string) ([]odigosv var detectErr error for _, proc := range processes { - programLanguageDetails, detectErr = inspectors.DetectLanguage(proc, pod.Status.PodIP) + containerURL := kubeutils.GetPodExternalURL(pod.Status.PodIP, container.Ports) + programLanguageDetails, detectErr = inspectors.DetectLanguage(proc, containerURL) if detectErr == nil && programLanguageDetails.Language != common.UnknownProgrammingLanguage { inspectProc = &proc break diff --git a/odiglet/pkg/kube/utils/utils.go b/odiglet/pkg/kube/utils/utils.go index f28258fcd..48c066e44 100644 --- a/odiglet/pkg/kube/utils/utils.go +++ b/odiglet/pkg/kube/utils/utils.go @@ -50,3 +50,11 @@ func GetResourceAttributes(podWorkload *workload.PodWorkload, podName string) [] return attrs } + +func GetPodExternalURL(ip string, ports []corev1.ContainerPort) string { + if ports != nil && len(ports) > 0 { + return ip + ":" + string(ports[0].ContainerPort) + } + + return "" +} diff --git a/procdiscovery/pkg/inspectors/dotnet/dotnet.go b/procdiscovery/pkg/inspectors/dotnet/dotnet.go index 21cd56557..3a50bd6b0 100644 --- a/procdiscovery/pkg/inspectors/dotnet/dotnet.go +++ b/procdiscovery/pkg/inspectors/dotnet/dotnet.go @@ -28,6 +28,6 @@ func (d *DotnetInspector) Inspect(p *process.Details) (common.ProgrammingLanguag return "", false } -func (d *DotnetInspector) GetRuntimeVersion(p *process.Details, podIp string) string { +func (d *DotnetInspector) GetRuntimeVersion(p *process.Details, containerURL string) string { return "" } diff --git a/procdiscovery/pkg/inspectors/golang/golang.go b/procdiscovery/pkg/inspectors/golang/golang.go index dac2a0482..6bd7a8a63 100644 --- a/procdiscovery/pkg/inspectors/golang/golang.go +++ b/procdiscovery/pkg/inspectors/golang/golang.go @@ -20,7 +20,7 @@ func (g *GolangInspector) Inspect(p *process.Details) (common.ProgrammingLanguag return common.GoProgrammingLanguage, true } -func (g *GolangInspector) GetRuntimeVersion(p *process.Details, podIp string) string { +func (g *GolangInspector) GetRuntimeVersion(p *process.Details, containerURL string) string { var runtimeVersion string file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) buildInfo, err := buildinfo.ReadFile(file) diff --git a/procdiscovery/pkg/inspectors/java/java.go b/procdiscovery/pkg/inspectors/java/java.go index d1497e904..255e33a7c 100644 --- a/procdiscovery/pkg/inspectors/java/java.go +++ b/procdiscovery/pkg/inspectors/java/java.go @@ -19,7 +19,7 @@ func (j *JavaInspector) Inspect(proc *process.Details) (common.ProgrammingLangua return "", false } -func (j *JavaInspector) GetRuntimeVersion(proc *process.Details, podIp string) string { +func (j *JavaInspector) GetRuntimeVersion(proc *process.Details, containerURL string) string { if value, exists := proc.GetDetailedEnvsValue(process.JavaVersionConst); exists { return value } diff --git a/procdiscovery/pkg/inspectors/langdetect.go b/procdiscovery/pkg/inspectors/langdetect.go index 05446d696..5387c2dcb 100644 --- a/procdiscovery/pkg/inspectors/langdetect.go +++ b/procdiscovery/pkg/inspectors/langdetect.go @@ -24,7 +24,7 @@ func (e ErrLanguageDetectionConflict) Error() string { type inspector interface { Inspect(process *process.Details) (common.ProgrammingLanguage, bool) - GetRuntimeVersion(process *process.Details, podIp string) string + GetRuntimeVersion(process *process.Details, containerURL string) string } var inspectorsList = []inspector{ @@ -40,7 +40,7 @@ var inspectorsList = []inspector{ // DetectLanguage returns the detected language for the process or // common.UnknownProgrammingLanguage if the language could not be detected, in which case error == nil // if error or language detectors disagree common.UnknownProgrammingLanguage is also returned -func DetectLanguage(process process.Details, podIp string) (common.ProgramLanguageDetails, error) { +func DetectLanguage(process process.Details, containerURL string) (common.ProgramLanguageDetails, error) { detectedProgramLanguageDetails := common.ProgramLanguageDetails{ Language: common.UnknownProgrammingLanguage, } @@ -50,7 +50,7 @@ func DetectLanguage(process process.Details, podIp string) (common.ProgramLangua if detected { if detectedProgramLanguageDetails.Language == common.UnknownProgrammingLanguage { detectedProgramLanguageDetails.Language = languageDetected - detectedProgramLanguageDetails.RuntimeVersion = i.GetRuntimeVersion(&process, podIp) + detectedProgramLanguageDetails.RuntimeVersion = i.GetRuntimeVersion(&process, containerURL) continue } return common.ProgramLanguageDetails{ diff --git a/procdiscovery/pkg/inspectors/mysql/mysql.go b/procdiscovery/pkg/inspectors/mysql/mysql.go index e8ac43894..940e35ba8 100644 --- a/procdiscovery/pkg/inspectors/mysql/mysql.go +++ b/procdiscovery/pkg/inspectors/mysql/mysql.go @@ -21,6 +21,6 @@ func (j *MySQLInspector) Inspect(p *process.Details) (common.ProgrammingLanguage return "", false } -func (j *MySQLInspector) GetRuntimeVersion(p *process.Details, podIp string) string { +func (j *MySQLInspector) GetRuntimeVersion(p *process.Details, containerURL string) string { return "" } diff --git a/procdiscovery/pkg/inspectors/nginx/nginx.go b/procdiscovery/pkg/inspectors/nginx/nginx.go index c44ac0e1a..3d9cb9094 100644 --- a/procdiscovery/pkg/inspectors/nginx/nginx.go +++ b/procdiscovery/pkg/inspectors/nginx/nginx.go @@ -13,7 +13,10 @@ import ( // but in order to avoid huge refactoring we are adding it as a language for now type NginxInspector struct{} -const NginxProcessName = "nginx" +const ( + NginxProcessName = "nginx" + NginxVersionRegex = "`nginx/(\\d+\\.\\d+\\.\\d+)`" +) func (j *NginxInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { if strings.Contains(p.CmdLine, NginxProcessName) || strings.Contains(p.ExeName, NginxProcessName) { @@ -23,8 +26,8 @@ func (j *NginxInspector) Inspect(p *process.Details) (common.ProgrammingLanguage return "", false } -func (j *NginxInspector) GetRuntimeVersion(p *process.Details, podIp string) string { - version, err := GetNginxVersion(podIp) +func (j *NginxInspector) GetRuntimeVersion(p *process.Details, containerURL string) string { + version, err := GetNginxVersion(containerURL) if err != nil { return "" } @@ -44,7 +47,7 @@ func GetNginxVersion(podIP string) (string, error) { return "", nil } - re := regexp.MustCompile(`nginx/(\d+\.\d+\.\d+)`) + re := regexp.MustCompile(NginxVersionRegex) match := re.FindStringSubmatch(serverHeader) if len(match) != 2 { return "", nil diff --git a/procdiscovery/pkg/inspectors/nodejs/nodejs.go b/procdiscovery/pkg/inspectors/nodejs/nodejs.go index 39fc71cd3..293db462e 100644 --- a/procdiscovery/pkg/inspectors/nodejs/nodejs.go +++ b/procdiscovery/pkg/inspectors/nodejs/nodejs.go @@ -19,7 +19,7 @@ func (n *NodejsInspector) Inspect(proc *process.Details) (common.ProgrammingLang return "", false } -func (n *NodejsInspector) GetRuntimeVersion(proc *process.Details, podIp string) string { +func (n *NodejsInspector) GetRuntimeVersion(proc *process.Details, containerURL string) string { if version, exists := proc.GetDetailedEnvsValue(process.NodeVersionConst); exists { return version } diff --git a/procdiscovery/pkg/inspectors/python/python.go b/procdiscovery/pkg/inspectors/python/python.go index ae9d34242..caaaea7c0 100644 --- a/procdiscovery/pkg/inspectors/python/python.go +++ b/procdiscovery/pkg/inspectors/python/python.go @@ -19,7 +19,7 @@ func (p *PythonInspector) Inspect(proc *process.Details) (common.ProgrammingLang return "", false } -func (p *PythonInspector) GetRuntimeVersion(proc *process.Details, podIp string) string { +func (p *PythonInspector) GetRuntimeVersion(proc *process.Details, containerURL string) string { if value, exists := proc.GetDetailedEnvsValue(process.PythonVersionConst); exists { return value } From c5baba16e11a001ea1b8416c4d18c882729b5632 Mon Sep 17 00:00:00 2001 From: yodigos Date: Mon, 26 Aug 2024 15:10:32 +0300 Subject: [PATCH 05/10] Separated Version with Inspect language --- common/go.mod | 2 ++ common/go.sum | 1 + common/lang_detection.go | 12 ++++++++++- .../pkg/kube/runtime_details/inspection.go | 7 ++++++- odiglet/pkg/kube/utils/utils.go | 3 ++- procdiscovery/go.mod | 1 + procdiscovery/go.sum | 1 + procdiscovery/pkg/inspectors/dotnet/dotnet.go | 4 ---- procdiscovery/pkg/inspectors/golang/golang.go | 21 +++++++++++-------- procdiscovery/pkg/inspectors/java/java.go | 11 +++++++--- procdiscovery/pkg/inspectors/langdetect.go | 15 ++++++++----- procdiscovery/pkg/inspectors/mysql/mysql.go | 4 ---- procdiscovery/pkg/inspectors/nginx/nginx.go | 15 ++++++------- procdiscovery/pkg/inspectors/nodejs/nodejs.go | 9 ++++---- procdiscovery/pkg/inspectors/python/python.go | 7 ++++--- 15 files changed, 71 insertions(+), 42 deletions(-) diff --git a/common/go.mod b/common/go.mod index ab6f1b689..ba8b6fdaf 100644 --- a/common/go.mod +++ b/common/go.mod @@ -26,4 +26,6 @@ require ( golang.org/x/sys v0.18.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect + ) diff --git a/common/go.sum b/common/go.sum index 2ea659c44..a573b5489 100644 --- a/common/go.sum +++ b/common/go.sum @@ -15,6 +15,7 @@ github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I= github.com/goccy/go-yaml v1.11.3/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= diff --git a/common/lang_detection.go b/common/lang_detection.go index c5bd4f135..31831e5fa 100644 --- a/common/lang_detection.go +++ b/common/lang_detection.go @@ -1,8 +1,10 @@ package common +import "github.com/hashicorp/go-version" + type ProgramLanguageDetails struct { Language ProgrammingLanguage - RuntimeVersion string + RuntimeVersion *version.Version } // +kubebuilder:validation:Enum=java;python;go;dotnet;javascript;mysql;nginx;unknown;ignored @@ -23,3 +25,11 @@ const ( // Ignored is used when the odigos is configured to ignore the process/container IgnoredProgrammingLanguage ProgrammingLanguage = "ignored" ) + +func GetVersion(versionString string) *version.Version { + runtimeVersion, err := version.NewVersion(versionString) + if err != nil { + return nil + } + return runtimeVersion +} diff --git a/odiglet/pkg/kube/runtime_details/inspection.go b/odiglet/pkg/kube/runtime_details/inspection.go index 7cbbb7ba7..62704091e 100644 --- a/odiglet/pkg/kube/runtime_details/inspection.go +++ b/odiglet/pkg/kube/runtime_details/inspection.go @@ -120,10 +120,15 @@ func runtimeInspection(pods []corev1.Pod, ignoredContainers []string) ([]odigosv } } + runtimeVersion := "" + if programLanguageDetails.RuntimeVersion != nil { + runtimeVersion = programLanguageDetails.RuntimeVersion.String() + } + resultsMap[container.Name] = odigosv1.RuntimeDetailsByContainer{ ContainerName: container.Name, Language: programLanguageDetails.Language, - RuntimeVersion: programLanguageDetails.RuntimeVersion, + RuntimeVersion: runtimeVersion, EnvVars: envs, } } diff --git a/odiglet/pkg/kube/utils/utils.go b/odiglet/pkg/kube/utils/utils.go index 48c066e44..b729bc28d 100644 --- a/odiglet/pkg/kube/utils/utils.go +++ b/odiglet/pkg/kube/utils/utils.go @@ -2,6 +2,7 @@ package utils import ( "context" + "fmt" "github.com/odigos-io/odigos/k8sutils/pkg/workload" "github.com/odigos-io/odigos/odiglet/pkg/env" @@ -53,7 +54,7 @@ func GetResourceAttributes(podWorkload *workload.PodWorkload, podName string) [] func GetPodExternalURL(ip string, ports []corev1.ContainerPort) string { if ports != nil && len(ports) > 0 { - return ip + ":" + string(ports[0].ContainerPort) + return fmt.Sprintf("http://%s:%d", ip, ports[0].ContainerPort) } return "" diff --git a/procdiscovery/go.mod b/procdiscovery/go.mod index 62ee3da1f..ee176d0bf 100644 --- a/procdiscovery/go.mod +++ b/procdiscovery/go.mod @@ -6,6 +6,7 @@ require github.com/odigos-io/odigos/common v1.0.48 require ( github.com/go-logr/logr v1.4.1 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect ) diff --git a/procdiscovery/go.sum b/procdiscovery/go.sum index 035887296..992a1ba22 100644 --- a/procdiscovery/go.sum +++ b/procdiscovery/go.sum @@ -4,6 +4,7 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= diff --git a/procdiscovery/pkg/inspectors/dotnet/dotnet.go b/procdiscovery/pkg/inspectors/dotnet/dotnet.go index 3a50bd6b0..b58724773 100644 --- a/procdiscovery/pkg/inspectors/dotnet/dotnet.go +++ b/procdiscovery/pkg/inspectors/dotnet/dotnet.go @@ -27,7 +27,3 @@ func (d *DotnetInspector) Inspect(p *process.Details) (common.ProgrammingLanguag return "", false } - -func (d *DotnetInspector) GetRuntimeVersion(p *process.Details, containerURL string) string { - return "" -} diff --git a/procdiscovery/pkg/inspectors/golang/golang.go b/procdiscovery/pkg/inspectors/golang/golang.go index 6bd7a8a63..e1923b80f 100644 --- a/procdiscovery/pkg/inspectors/golang/golang.go +++ b/procdiscovery/pkg/inspectors/golang/golang.go @@ -3,13 +3,16 @@ package golang import ( "debug/buildinfo" "fmt" - + "github.com/hashicorp/go-version" "github.com/odigos-io/odigos/common" "github.com/odigos-io/odigos/procdiscovery/pkg/process" + "regexp" ) type GolangInspector struct{} +const GolangVersionRegex = `go(\d+\.\d+\.\d+)` + func (g *GolangInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) _, err := buildinfo.ReadFile(file) @@ -20,16 +23,16 @@ func (g *GolangInspector) Inspect(p *process.Details) (common.ProgrammingLanguag return common.GoProgrammingLanguage, true } -func (g *GolangInspector) GetRuntimeVersion(p *process.Details, containerURL string) string { - var runtimeVersion string +func (g *GolangInspector) GetRuntimeVersion(p *process.Details, containerURL string) *version.Version { file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) buildInfo, err := buildinfo.ReadFile(file) - if err != nil { - return "" - } - if buildInfo != nil { - runtimeVersion = buildInfo.GoVersion + if err != nil || buildInfo == nil { + return nil } - return runtimeVersion + re := regexp.MustCompile(GolangVersionRegex) + match := re.FindStringSubmatch(buildInfo.GoVersion) + + return common.GetVersion(match[1]) + } diff --git a/procdiscovery/pkg/inspectors/java/java.go b/procdiscovery/pkg/inspectors/java/java.go index 255e33a7c..2a6941922 100644 --- a/procdiscovery/pkg/inspectors/java/java.go +++ b/procdiscovery/pkg/inspectors/java/java.go @@ -1,6 +1,8 @@ package java import ( + "github.com/hashicorp/go-version" + "regexp" "strings" "github.com/odigos-io/odigos/common" @@ -10,6 +12,7 @@ import ( type JavaInspector struct{} const processName = "java" +const JavaVersionRegex = `\d+\.\d+\.\d+\+\d+` func (j *JavaInspector) Inspect(proc *process.Details) (common.ProgrammingLanguage, bool) { if strings.Contains(proc.ExeName, processName) || strings.Contains(proc.CmdLine, processName) { @@ -19,10 +22,12 @@ func (j *JavaInspector) Inspect(proc *process.Details) (common.ProgrammingLangua return "", false } -func (j *JavaInspector) GetRuntimeVersion(proc *process.Details, containerURL string) string { +func (j *JavaInspector) GetRuntimeVersion(proc *process.Details, containerURL string) *version.Version { if value, exists := proc.GetDetailedEnvsValue(process.JavaVersionConst); exists { - return value + re := regexp.MustCompile(JavaVersionRegex) + javaVersion := re.FindString(value) + return common.GetVersion(javaVersion) } - return "" + return nil } diff --git a/procdiscovery/pkg/inspectors/langdetect.go b/procdiscovery/pkg/inspectors/langdetect.go index 5387c2dcb..0277ee1c8 100644 --- a/procdiscovery/pkg/inspectors/langdetect.go +++ b/procdiscovery/pkg/inspectors/langdetect.go @@ -2,7 +2,7 @@ package inspectors import ( "fmt" - + "github.com/hashicorp/go-version" "github.com/odigos-io/odigos/common" "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/dotnet" "github.com/odigos-io/odigos/procdiscovery/pkg/inspectors/golang" @@ -22,12 +22,15 @@ func (e ErrLanguageDetectionConflict) Error() string { return fmt.Sprintf("language detection conflict between %v and %v", e.languages[0], e.languages[1]) } -type inspector interface { +type LanguageInspector interface { Inspect(process *process.Details) (common.ProgrammingLanguage, bool) - GetRuntimeVersion(process *process.Details, containerURL string) string } -var inspectorsList = []inspector{ +type VersionInspector interface { + GetRuntimeVersion(process *process.Details, containerURL string) *version.Version +} + +var inspectorsList = []LanguageInspector{ &golang.GolangInspector{}, &java.JavaInspector{}, &python.PythonInspector{}, @@ -50,7 +53,9 @@ func DetectLanguage(process process.Details, containerURL string) (common.Progra if detected { if detectedProgramLanguageDetails.Language == common.UnknownProgrammingLanguage { detectedProgramLanguageDetails.Language = languageDetected - detectedProgramLanguageDetails.RuntimeVersion = i.GetRuntimeVersion(&process, containerURL) + if v, ok := i.(VersionInspector); ok { + detectedProgramLanguageDetails.RuntimeVersion = v.GetRuntimeVersion(&process, containerURL) + } continue } return common.ProgramLanguageDetails{ diff --git a/procdiscovery/pkg/inspectors/mysql/mysql.go b/procdiscovery/pkg/inspectors/mysql/mysql.go index 940e35ba8..11766e069 100644 --- a/procdiscovery/pkg/inspectors/mysql/mysql.go +++ b/procdiscovery/pkg/inspectors/mysql/mysql.go @@ -20,7 +20,3 @@ func (j *MySQLInspector) Inspect(p *process.Details) (common.ProgrammingLanguage return "", false } - -func (j *MySQLInspector) GetRuntimeVersion(p *process.Details, containerURL string) string { - return "" -} diff --git a/procdiscovery/pkg/inspectors/nginx/nginx.go b/procdiscovery/pkg/inspectors/nginx/nginx.go index 3d9cb9094..04f3d82d4 100644 --- a/procdiscovery/pkg/inspectors/nginx/nginx.go +++ b/procdiscovery/pkg/inspectors/nginx/nginx.go @@ -1,6 +1,7 @@ package nginx import ( + "github.com/hashicorp/go-version" "net/http" "regexp" "strings" @@ -15,7 +16,7 @@ type NginxInspector struct{} const ( NginxProcessName = "nginx" - NginxVersionRegex = "`nginx/(\\d+\\.\\d+\\.\\d+)`" + NginxVersionRegex = `nginx/(\d+\.\d+\.\d+)` ) func (j *NginxInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { @@ -26,17 +27,17 @@ func (j *NginxInspector) Inspect(p *process.Details) (common.ProgrammingLanguage return "", false } -func (j *NginxInspector) GetRuntimeVersion(p *process.Details, containerURL string) string { - version, err := GetNginxVersion(containerURL) +func (j *NginxInspector) GetRuntimeVersion(p *process.Details, containerURL string) *version.Version { + nginxVersion, err := GetNginxVersion(containerURL) if err != nil { - return "" + return nil } - return version + return common.GetVersion(nginxVersion) } -func GetNginxVersion(podIP string) (string, error) { - resp, err := http.Get("http://" + podIP) +func GetNginxVersion(containerURL string) (string, error) { + resp, err := http.Get(containerURL) if err != nil { return "", nil } diff --git a/procdiscovery/pkg/inspectors/nodejs/nodejs.go b/procdiscovery/pkg/inspectors/nodejs/nodejs.go index 293db462e..7c3d3ac24 100644 --- a/procdiscovery/pkg/inspectors/nodejs/nodejs.go +++ b/procdiscovery/pkg/inspectors/nodejs/nodejs.go @@ -1,6 +1,7 @@ package nodejs import ( + "github.com/hashicorp/go-version" "strings" "github.com/odigos-io/odigos/common" @@ -19,10 +20,10 @@ func (n *NodejsInspector) Inspect(proc *process.Details) (common.ProgrammingLang return "", false } -func (n *NodejsInspector) GetRuntimeVersion(proc *process.Details, containerURL string) string { - if version, exists := proc.GetDetailedEnvsValue(process.NodeVersionConst); exists { - return version +func (n *NodejsInspector) GetRuntimeVersion(proc *process.Details, containerURL string) *version.Version { + if value, exists := proc.GetDetailedEnvsValue(process.NodeVersionConst); exists { + return common.GetVersion(value) } - return "" + return nil } diff --git a/procdiscovery/pkg/inspectors/python/python.go b/procdiscovery/pkg/inspectors/python/python.go index caaaea7c0..0d970a21d 100644 --- a/procdiscovery/pkg/inspectors/python/python.go +++ b/procdiscovery/pkg/inspectors/python/python.go @@ -1,6 +1,7 @@ package python import ( + "github.com/hashicorp/go-version" "strings" "github.com/odigos-io/odigos/common" @@ -19,10 +20,10 @@ func (p *PythonInspector) Inspect(proc *process.Details) (common.ProgrammingLang return "", false } -func (p *PythonInspector) GetRuntimeVersion(proc *process.Details, containerURL string) string { +func (p *PythonInspector) GetRuntimeVersion(proc *process.Details, containerURL string) *version.Version { if value, exists := proc.GetDetailedEnvsValue(process.PythonVersionConst); exists { - return value + return common.GetVersion(value) } - return "" + return nil } From d1e8e4b3de253c7edf289f7d5643e55600e15b83 Mon Sep 17 00:00:00 2001 From: yodigos Date: Tue, 27 Aug 2024 06:39:29 +0300 Subject: [PATCH 06/10] Separated Version with Inspect language --- common/go.mod | 2 +- common/go.sum | 1 + procdiscovery/go.mod | 6 ++++-- procdiscovery/go.sum | 1 + 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/common/go.mod b/common/go.mod index ba8b6fdaf..7f19c8f22 100644 --- a/common/go.mod +++ b/common/go.mod @@ -19,6 +19,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fatih/color v1.10.0 // indirect github.com/go-logr/logr v1.4.1 + github.com/hashicorp/go-version v1.7.0 github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-isatty v0.0.12 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect @@ -26,6 +27,5 @@ require ( golang.org/x/sys v0.18.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - github.com/hashicorp/go-version v1.7.0 // indirect ) diff --git a/common/go.sum b/common/go.sum index a573b5489..90cb9e3c8 100644 --- a/common/go.sum +++ b/common/go.sum @@ -15,6 +15,7 @@ github.com/goccy/go-yaml v1.11.3 h1:B3W9IdWbvrUu2OYQGwvU1nZtvMQJPBKgBUuweJjLj6I= github.com/goccy/go-yaml v1.11.3/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= diff --git a/procdiscovery/go.mod b/procdiscovery/go.mod index ee176d0bf..0f45dfce2 100644 --- a/procdiscovery/go.mod +++ b/procdiscovery/go.mod @@ -2,11 +2,13 @@ module github.com/odigos-io/odigos/procdiscovery go 1.22.0 -require github.com/odigos-io/odigos/common v1.0.48 +require ( + github.com/hashicorp/go-version v1.7.0 + github.com/odigos-io/odigos/common v1.0.48 +) require ( github.com/go-logr/logr v1.4.1 // indirect - github.com/hashicorp/go-version v1.7.0 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect ) diff --git a/procdiscovery/go.sum b/procdiscovery/go.sum index 992a1ba22..1c8022b29 100644 --- a/procdiscovery/go.sum +++ b/procdiscovery/go.sum @@ -4,6 +4,7 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= From ee09906b4bb0301e55ed09f1aaf2cf4d346cc608 Mon Sep 17 00:00:00 2001 From: yodigos Date: Tue, 27 Aug 2024 11:36:09 +0300 Subject: [PATCH 07/10] Separated Version with Inspect language --- api/go.mod | 1 + api/go.sum | 2 ++ autoscaler/go.mod | 1 + autoscaler/go.sum | 2 ++ destinations/go.mod | 1 + destinations/go.sum | 2 ++ instrumentor/go.mod | 1 + instrumentor/go.sum | 2 ++ k8sutils/go.mod | 1 + k8sutils/go.sum | 2 ++ scheduler/go.mod | 1 + scheduler/go.sum | 2 ++ 12 files changed, 18 insertions(+) diff --git a/api/go.mod b/api/go.mod index bb587b9d2..8eb5572f1 100644 --- a/api/go.mod +++ b/api/go.mod @@ -16,6 +16,7 @@ require ( require ( github.com/fxamacker/cbor/v2 v2.7.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect github.com/x448/float16 v0.8.4 // indirect golang.org/x/sync v0.7.0 // indirect diff --git a/api/go.sum b/api/go.sum index dd357eaac..5a2fcb28c 100644 --- a/api/go.sum +++ b/api/go.sum @@ -44,6 +44,8 @@ github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2 github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= diff --git a/autoscaler/go.mod b/autoscaler/go.mod index 100a38fe4..352ae9a23 100644 --- a/autoscaler/go.mod +++ b/autoscaler/go.mod @@ -43,6 +43,7 @@ require ( github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect diff --git a/autoscaler/go.sum b/autoscaler/go.sum index bd4e64a46..e3f32bbcf 100644 --- a/autoscaler/go.sum +++ b/autoscaler/go.sum @@ -69,6 +69,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= diff --git a/destinations/go.mod b/destinations/go.mod index 470afa3df..e152ff071 100644 --- a/destinations/go.mod +++ b/destinations/go.mod @@ -9,6 +9,7 @@ require ( require ( github.com/go-logr/logr v1.4.1 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/kr/text v0.2.0 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect diff --git a/destinations/go.sum b/destinations/go.sum index 0e8df85b0..8466da382 100644 --- a/destinations/go.sum +++ b/destinations/go.sum @@ -5,6 +5,8 @@ github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= diff --git a/instrumentor/go.mod b/instrumentor/go.mod index 85761ded8..01f179564 100644 --- a/instrumentor/go.mod +++ b/instrumentor/go.mod @@ -24,6 +24,7 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/goccy/go-yaml v1.11.3 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/mattn/go-colorable v0.1.8 // indirect github.com/mattn/go-isatty v0.0.12 // indirect github.com/nxadm/tail v1.4.8 // indirect diff --git a/instrumentor/go.sum b/instrumentor/go.sum index 17afd90ae..d512635d9 100644 --- a/instrumentor/go.sum +++ b/instrumentor/go.sum @@ -81,6 +81,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= diff --git a/k8sutils/go.mod b/k8sutils/go.mod index 4110fe88d..08afd20e5 100644 --- a/k8sutils/go.mod +++ b/k8sutils/go.mod @@ -26,6 +26,7 @@ require ( github.com/google/gnostic-models v0.6.8 // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/uuid v1.6.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/imdario/mergo v0.3.6 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect diff --git a/k8sutils/go.sum b/k8sutils/go.sum index 9034bf39a..47a576bf9 100644 --- a/k8sutils/go.sum +++ b/k8sutils/go.sum @@ -48,6 +48,8 @@ github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af h1:kmjWCqn2qkEml422C2 github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= diff --git a/scheduler/go.mod b/scheduler/go.mod index 3d6f2a6fc..d626226dd 100644 --- a/scheduler/go.mod +++ b/scheduler/go.mod @@ -39,6 +39,7 @@ require ( github.com/google/gofuzz v1.2.0 // indirect github.com/google/uuid v1.6.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect + github.com/hashicorp/go-version v1.7.0 // indirect github.com/imdario/mergo v0.3.12 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect diff --git a/scheduler/go.sum b/scheduler/go.sum index 3cd14627c..280cc6714 100644 --- a/scheduler/go.sum +++ b/scheduler/go.sum @@ -81,6 +81,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0= github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k= +github.com/hashicorp/go-version v1.7.0 h1:5tqGy27NaOTB8yJKUZELlFAS/LTKJkrmONwQKeRZfjY= +github.com/hashicorp/go-version v1.7.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/imdario/mergo v0.3.12 h1:b6R2BslTbIEToALKP7LxUvijTsNI9TAe80pLWN2g/HU= github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= From 8aed7583827ca21d40b71ce952f4310b0f6af8c7 Mon Sep 17 00:00:00 2001 From: yodigos Date: Tue, 27 Aug 2024 12:42:50 +0300 Subject: [PATCH 08/10] Separated Version with Inspect language --- tests/e2e/helm-chart/assert-runtime-detected.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/e2e/helm-chart/assert-runtime-detected.yaml b/tests/e2e/helm-chart/assert-runtime-detected.yaml index dfc26e8a2..ea82fa426 100644 --- a/tests/e2e/helm-chart/assert-runtime-detected.yaml +++ b/tests/e2e/helm-chart/assert-runtime-detected.yaml @@ -30,7 +30,7 @@ spec: runtimeDetails: - containerName: frontend language: java - runtimeVersion: jdk-17.0.11+9 + runtimeVersion: 17.0.11+9 --- apiVersion: odigos.io/v1alpha1 kind: InstrumentedApplication @@ -64,7 +64,7 @@ spec: runtimeDetails: - containerName: membership language: go - runtimeVersion: go1.21.4 + runtimeVersion: 1.21.4 --- apiVersion: odigos.io/v1alpha1 kind: InstrumentedApplication From 0f7c9567e4b90f1488f8f2e3d1f46bc3cf26cfd5 Mon Sep 17 00:00:00 2001 From: yodigos Date: Wed, 28 Aug 2024 18:16:52 +0300 Subject: [PATCH 09/10] PR Fix --- odiglet/pkg/kube/runtime_details/inspection.go | 2 +- procdiscovery/pkg/inspectors/golang/golang.go | 18 ++++++++++-------- procdiscovery/pkg/inspectors/java/java.go | 3 ++- procdiscovery/pkg/inspectors/nginx/nginx.go | 3 ++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/odiglet/pkg/kube/runtime_details/inspection.go b/odiglet/pkg/kube/runtime_details/inspection.go index 62704091e..aa3f98c65 100644 --- a/odiglet/pkg/kube/runtime_details/inspection.go +++ b/odiglet/pkg/kube/runtime_details/inspection.go @@ -120,7 +120,7 @@ func runtimeInspection(pods []corev1.Pod, ignoredContainers []string) ([]odigosv } } - runtimeVersion := "" + var runtimeVersion string if programLanguageDetails.RuntimeVersion != nil { runtimeVersion = programLanguageDetails.RuntimeVersion.String() } diff --git a/procdiscovery/pkg/inspectors/golang/golang.go b/procdiscovery/pkg/inspectors/golang/golang.go index e1923b80f..f3e18f424 100644 --- a/procdiscovery/pkg/inspectors/golang/golang.go +++ b/procdiscovery/pkg/inspectors/golang/golang.go @@ -9,29 +9,31 @@ import ( "regexp" ) -type GolangInspector struct{} +type GolangInspector struct { + *buildinfo.BuildInfo +} const GolangVersionRegex = `go(\d+\.\d+\.\d+)` +var re = regexp.MustCompile(GolangVersionRegex) + func (g *GolangInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) - _, err := buildinfo.ReadFile(file) + buildInfo, err := buildinfo.ReadFile(file) if err != nil { return "", false } + g.BuildInfo = buildInfo + return common.GoProgrammingLanguage, true } func (g *GolangInspector) GetRuntimeVersion(p *process.Details, containerURL string) *version.Version { - file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) - buildInfo, err := buildinfo.ReadFile(file) - if err != nil || buildInfo == nil { + if g.BuildInfo == nil { return nil } - - re := regexp.MustCompile(GolangVersionRegex) - match := re.FindStringSubmatch(buildInfo.GoVersion) + match := re.FindStringSubmatch(g.BuildInfo.GoVersion) return common.GetVersion(match[1]) diff --git a/procdiscovery/pkg/inspectors/java/java.go b/procdiscovery/pkg/inspectors/java/java.go index 2a6941922..92e7196fb 100644 --- a/procdiscovery/pkg/inspectors/java/java.go +++ b/procdiscovery/pkg/inspectors/java/java.go @@ -14,6 +14,8 @@ type JavaInspector struct{} const processName = "java" const JavaVersionRegex = `\d+\.\d+\.\d+\+\d+` +var re = regexp.MustCompile(JavaVersionRegex) + func (j *JavaInspector) Inspect(proc *process.Details) (common.ProgrammingLanguage, bool) { if strings.Contains(proc.ExeName, processName) || strings.Contains(proc.CmdLine, processName) { return common.JavaProgrammingLanguage, true @@ -24,7 +26,6 @@ func (j *JavaInspector) Inspect(proc *process.Details) (common.ProgrammingLangua func (j *JavaInspector) GetRuntimeVersion(proc *process.Details, containerURL string) *version.Version { if value, exists := proc.GetDetailedEnvsValue(process.JavaVersionConst); exists { - re := regexp.MustCompile(JavaVersionRegex) javaVersion := re.FindString(value) return common.GetVersion(javaVersion) } diff --git a/procdiscovery/pkg/inspectors/nginx/nginx.go b/procdiscovery/pkg/inspectors/nginx/nginx.go index 04f3d82d4..85b8fdc64 100644 --- a/procdiscovery/pkg/inspectors/nginx/nginx.go +++ b/procdiscovery/pkg/inspectors/nginx/nginx.go @@ -19,6 +19,8 @@ const ( NginxVersionRegex = `nginx/(\d+\.\d+\.\d+)` ) +var re = regexp.MustCompile(NginxVersionRegex) + func (j *NginxInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { if strings.Contains(p.CmdLine, NginxProcessName) || strings.Contains(p.ExeName, NginxProcessName) { return common.NginxProgrammingLanguage, true @@ -48,7 +50,6 @@ func GetNginxVersion(containerURL string) (string, error) { return "", nil } - re := regexp.MustCompile(NginxVersionRegex) match := re.FindStringSubmatch(serverHeader) if len(match) != 2 { return "", nil From bf6b7f3e7807ab073e8af4c2cbef53cb2b6bf984 Mon Sep 17 00:00:00 2001 From: yodigos Date: Thu, 29 Aug 2024 09:49:33 +0300 Subject: [PATCH 10/10] PR Fix --- procdiscovery/pkg/inspectors/golang/golang.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/procdiscovery/pkg/inspectors/golang/golang.go b/procdiscovery/pkg/inspectors/golang/golang.go index f3e18f424..5473da2b5 100644 --- a/procdiscovery/pkg/inspectors/golang/golang.go +++ b/procdiscovery/pkg/inspectors/golang/golang.go @@ -9,9 +9,7 @@ import ( "regexp" ) -type GolangInspector struct { - *buildinfo.BuildInfo -} +type GolangInspector struct{} const GolangVersionRegex = `go(\d+\.\d+\.\d+)` @@ -19,21 +17,21 @@ var re = regexp.MustCompile(GolangVersionRegex) func (g *GolangInspector) Inspect(p *process.Details) (common.ProgrammingLanguage, bool) { file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) - buildInfo, err := buildinfo.ReadFile(file) + _, err := buildinfo.ReadFile(file) if err != nil { return "", false } - g.BuildInfo = buildInfo - return common.GoProgrammingLanguage, true } func (g *GolangInspector) GetRuntimeVersion(p *process.Details, containerURL string) *version.Version { - if g.BuildInfo == nil { + file := fmt.Sprintf("/proc/%d/exe", p.ProcessID) + buildInfo, err := buildinfo.ReadFile(file) + if err != nil || buildInfo == nil { return nil } - match := re.FindStringSubmatch(g.BuildInfo.GoVersion) + match := re.FindStringSubmatch(buildInfo.GoVersion) return common.GetVersion(match[1])