Skip to content

Commit 2de9913

Browse files
committed
fix merge conflicts
2 parents f21cec2 + e745a32 commit 2de9913

File tree

7 files changed

+49
-56
lines changed

7 files changed

+49
-56
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,23 +306,3 @@ jobs:
306306
- name: Push load test result
307307
if: ${{ success() && github.ref_name == 'v3'}}
308308
run: git push 'https://github-actions:${{ secrets.GITHUB_TOKEN }}@github.com/nginx/agent.git' benchmark-results:benchmark-results
309-
310-
publish-packages:
311-
name: Publish NGINX Agent v3 packages
312-
if: ${{ github.ref_name == 'v3' &&
313-
!github.event.pull_request.head.repo.fork }}
314-
needs: [ lint, unit-test, performance-tests,
315-
load-tests, official-oss-image-integration-tests,
316-
official-plus-image-integration-tests,
317-
race-condition-test, integration-tests ]
318-
uses: ./.github/workflows/release-branch.yml
319-
secrets: inherit
320-
permissions:
321-
id-token: write
322-
contents: read
323-
with:
324-
packageVersion: "3.0.0"
325-
packageBuildNo: "${{ github.run_number }}"
326-
uploadAzure: true
327-
publishPackages: true
328-
releaseBranch: "v3"

.github/workflows/release-branch.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,35 +39,6 @@ on:
3939
description: 'Location to publish packages to'
4040
required: false
4141
default: "https://up-ap.nginx.com"
42-
workflow_call:
43-
inputs:
44-
githubRelease:
45-
type: boolean
46-
default: false
47-
packageVersion:
48-
type: string
49-
default: "3.0.0"
50-
packageBuildNo:
51-
type: string
52-
default: "1"
53-
uploadAzure:
54-
type: boolean
55-
default: true
56-
publishPackages:
57-
type: boolean
58-
default: true
59-
tagRelease:
60-
type: boolean
61-
default: false
62-
createPullRequest:
63-
type: boolean
64-
default: false
65-
releaseBranch:
66-
type: string
67-
required: true
68-
uploadUrl:
69-
type: string
70-
default: "https://up-ap.nginx.com"
7142

7243
env:
7344
NFPM_VERSION: 'v2.35.3'

internal/collector/nginxplusreceiver/factory.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ package nginxplusreceiver
77
import (
88
"context"
99
"errors"
10+
"time"
1011

1112
"go.opentelemetry.io/collector/scraper"
1213
"go.opentelemetry.io/collector/scraper/scraperhelper"
@@ -18,6 +19,9 @@ import (
1819
"github.com/nginx/agent/v3/internal/collector/nginxplusreceiver/internal/metadata"
1920
)
2021

22+
// nolint: ireturn
23+
const defaultTimeout = 10 * time.Second
24+
2125
// nolint: ireturn
2226
func NewFactory() receiver.Factory {
2327
return receiver.NewFactory(

internal/watcher/instance/nginx_process_parser.go

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ func (npp *NginxProcessParser) getInfo(ctx context.Context, proc *nginxprocess.P
136136
}
137137
}
138138

139+
confPath := getConfPathFromCommand(proc.Cmd)
140+
139141
var nginxInfo *Info
140142

141143
outputBuffer, err := npp.executer.RunCmd(ctx, exePath, "-V")
@@ -148,6 +150,10 @@ func (npp *NginxProcessParser) getInfo(ctx context.Context, proc *nginxprocess.P
148150
nginxInfo.ExePath = exePath
149151
nginxInfo.ProcessID = proc.PID
150152

153+
if nginxInfo.ConfPath = getNginxConfPath(ctx, nginxInfo); confPath != "" {
154+
nginxInfo.ConfPath = confPath
155+
}
156+
151157
loadableModules := getLoadableModules(nginxInfo)
152158
nginxInfo.LoadableModules = loadableModules
153159

@@ -268,7 +274,6 @@ func parseNginxVersionCommandOutput(ctx context.Context, output *bytes.Buffer) *
268274
}
269275

270276
nginxInfo.Prefix = getNginxPrefix(ctx, nginxInfo)
271-
nginxInfo.ConfPath = getNginxConfPath(ctx, nginxInfo)
272277

273278
return nginxInfo
274279
}
@@ -392,3 +397,17 @@ func convertToMap(processes []*nginxprocess.Process) map[int32]*nginxprocess.Pro
392397

393398
return processesByPID
394399
}
400+
401+
func getConfPathFromCommand(command string) string {
402+
commands := strings.Split(command, " ")
403+
404+
for i, command := range commands {
405+
if command == "-c" {
406+
if i < len(commands)-1 {
407+
return commands[i+1]
408+
}
409+
}
410+
}
411+
412+
return ""
413+
}

internal/watcher/instance/nginx_process_parser_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,3 +616,14 @@ func TestNginxProcessParser_GetExe(t *testing.T) {
616616
})
617617
}
618618
}
619+
620+
func TestGetConfigPathFromCommand(t *testing.T) {
621+
result := getConfPathFromCommand("nginx: master process nginx -c /tmp/nginx.conf")
622+
assert.Equal(t, "/tmp/nginx.conf", result)
623+
624+
result = getConfPathFromCommand("nginx: master process nginx -c")
625+
assert.Equal(t, "", result)
626+
627+
result = getConfPathFromCommand("")
628+
assert.Equal(t, "", result)
629+
}

pkg/files/file_helpers.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ package files
88

99
import (
1010
"cmp"
11+
"crypto/sha256"
1112
"crypto/x509"
13+
"encoding/base64"
1214
"fmt"
1315
"net"
1416
"os"
1517
"slices"
1618
"strconv"
1719

18-
"github.com/google/uuid"
19-
2020
mpi "github.com/nginx/agent/v3/api/grpc/mpi/v1"
2121
"github.com/nginx/agent/v3/internal/datasource/cert"
2222
"google.golang.org/protobuf/types/known/timestamppb"
@@ -135,7 +135,10 @@ func GenerateConfigVersion(fileSlice []*mpi.File) string {
135135

136136
// GenerateHash returns the hash value of a file's contents.
137137
func GenerateHash(b []byte) string {
138-
return uuid.NewMD5(uuid.Nil, b).String()
138+
hash := sha256.New()
139+
hash.Write(b)
140+
141+
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
139142
}
140143

141144
// ConvertToMapOfFiles converts a list of files to a map of files with the file name as the key

pkg/files/file_helpers_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
package files
77

88
import (
9+
"crypto/sha256"
910
"crypto/x509"
11+
"encoding/base64"
1012
"net"
1113
"os"
1214
"testing"
1315

14-
"github.com/google/uuid"
1516
"github.com/stretchr/testify/assert"
1617
"github.com/stretchr/testify/require"
1718

@@ -136,6 +137,10 @@ func Test_GenerateConfigVersion(t *testing.T) {
136137
}
137138

138139
func TestGenerateHash(t *testing.T) {
140+
hash1 := sha256.New()
141+
hash2 := sha256.New()
142+
hash1.Write([]byte(""))
143+
hash2.Write([]byte("test"))
139144
tests := []struct {
140145
name string
141146
expected string
@@ -144,12 +149,12 @@ func TestGenerateHash(t *testing.T) {
144149
{
145150
name: "Test 1: empty byte slice",
146151
input: []byte{},
147-
expected: uuid.NewMD5(uuid.Nil, []byte("")).String(),
152+
expected: base64.StdEncoding.EncodeToString(hash1.Sum(nil)),
148153
},
149154
{
150155
name: "Test 2: non-empty byte slice",
151156
input: []byte("test"),
152-
expected: uuid.NewMD5(uuid.Nil, []byte("test")).String(),
157+
expected: base64.StdEncoding.EncodeToString(hash2.Sum(nil)),
153158
},
154159
}
155160

0 commit comments

Comments
 (0)