Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Added channel to write to logInfo.txt only after identities.txt is up… #602

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 28 additions & 9 deletions cmd/rekor_monitor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ func main() {
signalChan := make(chan os.Signal, 1)
signal.Notify(signalChan, os.Interrupt, syscall.SIGTERM)

identityUpdated := make(chan struct{})
initialRun := true
// To get an immediate first tick, for-select is at the end of the loop
for {
inputEndIndex := config.EndIndex
Expand All @@ -132,10 +134,22 @@ func main() {
// https://github.com/sigstore/rekor-monitor/issues/57
var logInfo *models.LogInfo
var prevCheckpoint *util.SignedCheckpoint
prevCheckpoint, logInfo, err = rekor.RunConsistencyCheck(rekorClient, verifier, *logInfoFile)
if err != nil {
fmt.Fprintf(os.Stderr, "error running consistency check: %v", err)
return

if initialRun {
prevCheckpoint, logInfo, err = rekor.RunConsistencyCheck(rekorClient, verifier, *logInfoFile)
if err != nil {
fmt.Fprintf(os.Stderr, "error running consistency check: %v", err)
return
}
initialRun = false
} else {
if _, ok := <-identityUpdated; ok {
prevCheckpoint, logInfo, err = rekor.RunConsistencyCheck(rekorClient, verifier, *logInfoFile)
if err != nil {
fmt.Fprintf(os.Stderr, "error running consistency check: %v", err)
return
}
}
}

if config.StartIndex == nil {
Expand Down Expand Up @@ -165,11 +179,16 @@ func main() {
}

if identity.MonitoredValuesExist(monitoredValues) {
_, err = rekor.IdentitySearch(*config.StartIndex, *config.EndIndex, rekorClient, monitoredValues, config.OutputIdentitiesFile, config.IdentityMetadataFile)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to successfully complete identity search: %v", err)
return
}
go func() {
_, err = rekor.IdentitySearch(*config.StartIndex, *config.EndIndex, rekorClient, monitoredValues, config.OutputIdentitiesFile, config.IdentityMetadataFile)
if err != nil {
fmt.Fprintf(os.Stderr, "failed to successfully complete identity search: %v", err)
close(identityUpdated)
return
}
identityUpdated <- struct{}{}
}()
<-identityUpdated
}

if *once || inputEndIndex != nil {
Expand Down
Loading