Skip to content

Commit 396a8fc

Browse files
authored
Fix proto registration for beholder (#2198)
1 parent 85e3ace commit 396a8fc

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

framework/.changeset/v0.11.2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix concurrent map write when streaming Docker logs
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
- Fix prefix stripping from proto package names
2+
- Add `_` to valid character in proto package name (fix for `bridge_status` package)
3+
- Update `chainlink-protos` SHA used in tests to `latest`

framework/components/dockercompose/chip_ingress_set/protos.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,16 @@ func RegisterAndFetchProtos(ctx context.Context, client *github.Client, protoSch
139139
// or in other words, we treat "workflows/" folder as the root folder for all protos in this schema set and strip it from the paths derived from the repository structure.
140140
prefixesToStrip := determineFolderPrefixesToStrip(protoSchemaSet.Folders)
141141

142+
strippedProtdMap := make(map[string]string)
143+
strippedSubjects := make(map[string]string)
144+
142145
for path := range protoMap {
143146
strippedPath := stripFolderPrefix(path, prefixesToStrip)
144-
protoMap[strippedPath] = protoMap[path]
145-
subjects[strippedPath] = subjects[path]
146-
delete(protoMap, path)
147-
delete(subjects, path)
147+
strippedProtdMap[strippedPath] = protoMap[path]
148+
strippedSubjects[strippedPath] = subjects[path]
148149
}
149150

150-
registerErr := registerAllWithTopologicalSorting(schemaRegistryURL, protoMap, subjects)
151+
registerErr := registerAllWithTopologicalSorting(schemaRegistryURL, strippedProtdMap, strippedSubjects)
151152
if registerErr != nil {
152153
return errors.Wrapf(registerErr, "failed to register protos from %s", protoSchemaSet.URI)
153154
}
@@ -174,7 +175,7 @@ func DefaultSubjectNamingStrategy(subjectPrefix string, proto protoFile, protoSc
174175
// extractPackageNameWithRegex extracts the package name from a proto source file using regex.
175176
// It returns an error if no package name is found.
176177
func extractPackageNameWithRegex(protoSrc string) (string, error) {
177-
matches := regexp.MustCompile(`(?m)^\s*package\s+([a-zA-Z0-9.]+)\s*;`).FindStringSubmatch(protoSrc)
178+
matches := regexp.MustCompile(`(?m)^\s*package\s+([a-zA-Z0-9._]+)\s*;`).FindStringSubmatch(protoSrc)
178179
if len(matches) < 2 {
179180
return "", fmt.Errorf("no package name found in proto source")
180181
}

framework/docker.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,7 @@ func StreamContainerLogs(listOptions container.ListOptions, logOptions container
368368

369369
eg := &errgroup.Group{}
370370
logMap := make(map[string]io.ReadCloser)
371+
var mutex sync.Mutex
371372

372373
for _, containerInfo := range containers {
373374
eg.Go(func() error {
@@ -378,6 +379,8 @@ func StreamContainerLogs(listOptions container.ListOptions, logOptions container
378379
L.Error().Err(err).Str("Container", containerName).Msg("failed to fetch logs for container")
379380
return err
380381
}
382+
mutex.Lock()
383+
defer mutex.Unlock()
381384
logMap[containerName] = logs
382385
return nil
383386
})

framework/examples/myproject/smoke_chip_ingress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func TestChipIngressSmoke(t *testing.T) {
3434
err := chipingressset.DefaultRegisterAndFetchProtos(ctx, nil, []chipingressset.ProtoSchemaSet{
3535
{
3636
URI: "https://github.com/smartcontractkit/chainlink-protos",
37-
Ref: "49a301ac36cad84ac8dd7fae6749d3a124b6819b",
37+
Ref: "a653ed4c82a02ec6c0d501dd5af80d02a00009db",
3838
Folders: []string{"workflows"},
3939
SubjectPrefix: "cre-",
4040
},

0 commit comments

Comments
 (0)