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

Change monitoring workflow configuration argument to optional #543

Merged

Conversation

linus-sun
Copy link
Collaborator

Summary

This PR changes the config argument in the GitHub Actions reusable monitoring workflow to no longer be required, and sets the identity monitor portion of the workflow to only run if a config containing a desired set of identities to monitor has been passed in.

Release Note

Workflow config argument has been changed to optional

Documentation

N/A

Copy link

codecov bot commented Nov 18, 2024

Codecov Report

Attention: Patch coverage is 0% with 10 lines in your changes missing coverage. Please review.

Project coverage is 62.90%. Comparing base (d271ec7) to head (3769ea8).
Report is 165 commits behind head on main.

Files with missing lines Patch % Lines
cmd/rekor_monitor/main.go 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #543      +/-   ##
==========================================
- Coverage   64.02%   62.90%   -1.13%     
==========================================
  Files           4       17      +13     
  Lines         303     1267     +964     
==========================================
+ Hits          194      797     +603     
- Misses         78      399     +321     
- Partials       31       71      +40     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@linus-sun linus-sun marked this pull request as ready for review November 18, 2024 19:17
@@ -76,12 +69,16 @@ func main() {
if err := yaml.Unmarshal([]byte(configString), &config); err != nil {
log.Fatalf("error parsing identities: %v", err)
}

configProvided = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? An uninitalized config should be sufficient for the checks below like config.EndIndex == nil

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that in the event that an uninitialized config is currently passed in, the workflow will still attempt to set StartIndex and EndIndex using the latest checkpoint and log checkpoint file and then attempt to run the identity monitor using the uninitialized config's values resulting in an error- if we would prefer to have checking for the config's indices stop the identity monitor from running I can refactor that in another PR after this one

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/sigstore/rekor-monitor/blob/114befbd5a9ab2639b80d592f7c777791495c192/cmd/rekor_monitor/main.go#L148C3-L175C4 As of right now I believe this check is only looking for nil values to set the start and end indices, not checking if the identity monitor is runnable- an uninitialized config will have the start and end indices set and then the identity monitor will run with nil arguments

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

an uninitialized config will have the start and end indices set and then the identity monitor will run with nil arguments

I thought the defaults for start and end were nil. So if the config is not initialized, then the default values of nil will be read in the code you linked, and then the monitor will initialize them with defaults.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes - I guess what I'm thinking is that in the event that a config is not initialized, there are also no identities provided to monitor; is the identity monitor portion of the workflow then still necessary to run?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see your question. What about if we gated calling IdentitySearch on if MonitoredValues is set? That was like the original implementation, where it would only run if a user configured a value to monitor for.

}

if *configYamlInput != "" {
if err := yaml.Unmarshal([]byte(*configYamlInput), &config); err != nil {
log.Fatalf("error parsing identities: %v", err)
}

configProvided = true
}

if config.OutputIdentitiesFile == "" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below for VerifyConsistencyCheckInputs, given we provide defaults, do we need this check anymore? Just need to update config.LogINfoFile based on the default if it's not provided.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updating logInfoFile and removing this part of the check

@linus-sun linus-sun force-pushed the linussun/fix-config-required branch from 938437a to 50330a1 Compare November 18, 2024 19:34
@linus-sun linus-sun force-pushed the linussun/fix-config-required branch from 50330a1 to 6c2def6 Compare November 18, 2024 19:47
@@ -88,7 +81,7 @@ func main() {
config.OutputIdentitiesFile = outputIdentitiesFileName
}

err := rekor.VerifyConsistencyCheckInputs(interval, &config.LogInfoFile, once)
err := rekor.VerifyConsistencyCheckInputs(interval, logInfoFile, once)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we delete this check now, since all these variables have default values so this check will always pass?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleting this from main.go and removing the function in a follow-up PR

@@ -163,7 +162,6 @@ func main() {
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the default of 0? Scrapping the entire log is hard to do without careful rate limiting on the client side. If no start index is provided and no checkpoint is provided, then just throw an error.

@@ -145,10 +138,16 @@ func main() {
}
}

err = rekor.RunConsistencyCheck(rekorClient, verifier, *logInfoFile)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a follow up - I noticed RunConsistencyCheck calls GetLogInfo, so we could reduce duplication by having RunConsistencyCheck return the log info struct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will work on this in a follow-up PR now

@linus-sun linus-sun force-pushed the linussun/fix-config-required branch from 6c2def6 to 3769ea8 Compare November 18, 2024 20:11
Copy link
Contributor

@haydentherapper haydentherapper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@haydentherapper haydentherapper merged commit e4644fe into sigstore:main Nov 18, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants