Repository navigation
Conversation
| if name := hostRulesSecretName(job); name != "" { | ||
| volumes = append(volumes, v1.Volume{ | ||
| Name: hostRulesVolumeName, | ||
| VolumeSource: v1.VolumeSource{ | ||
| Secret: &v1.SecretVolumeSource{ | ||
| SecretName: name, | ||
| Items: []v1.KeyToPath{{Key: github.HostRulesConfigFileKey, Path: github.HostRulesConfigFileKey}}, | ||
| }, | ||
| }, | ||
| }) | ||
| volumeMounts = append(volumeMounts, v1.VolumeMount{ | ||
| Name: hostRulesVolumeName, | ||
| MountPath: hostRulesMountPath, | ||
| ReadOnly: true, | ||
| }) | ||
| } |
There was a problem hiding this comment.
This volume projects host-rules.json and isn't optional, so the pod can only start if the Secret exists and has that key.
This breaks when app credentials are revoked or when a install token generation fails. Pods get then hang with a "ContainerCreating" blocking a parallelism slot.
I'd make the "empty" state valid config {"hostRules":[]} rather than no data. Pods would start and simply get no shared rules
There was a problem hiding this comment.
both is implemented now, the secret mount has the optional flag in case the creation of the "empty" secret still fails. also a secret holding empty host rules is now created at the start of ensureHostRules if it does not exist yet, so if something fails afterwards at least there is a secret to mount
https://github.com/mogenius/renovate-operator/pull/780/changes#diff-31b5c456966fc05bd3f5bfc7b9d734e44810a5aef1ba7adee6b6d9b681db71f9R59-R63
Hope it is okay if I resolve the other comments referencing this issue
| } | ||
|
|
||
| func (g *githubappToken) MintInstallationToken(appID, installationID, pemString, githubApi string) (string, time.Time, error) { | ||
| return g.createGithubAppTokenDetailed(appID, installationID, pemString, githubApi) |
There was a problem hiding this comment.
These tokens are minted without a permissions body, so each one can do everything the App can do on that org, typically contents: write and pull_requests: write.
For presets and lookups, read access is enough: {"permissions":{"contents":"read","metadata":"read"}} POST /app/installations/{id}/access_tokens accepts that. Scoping the tokens down limits the damage the Security note in the docs warns about.
There was a problem hiding this comment.
permissions are now set explicitly as suggested
https://github.com/mogenius/renovate-operator/pull/780/changes#diff-7f02a9c207978a0cf0ecc3b36f2f08c4e43d7f2eb89c34ae895bf0493ea35457R22
https://github.com/mogenius/renovate-operator/pull/780/changes#diff-7f02a9c207978a0cf0ecc3b36f2f08c4e43d7f2eb89c34ae895bf0493ea35457R40
| // The previous Secret stays: its tokens may still be valid. | ||
| return fmt.Errorf("minting hostRules token for installation %d (%s): %w", inst.ID, inst.Account, err) |
There was a problem hiding this comment.
If any single installation fails to generate a token this returns and throws away the tokens already generated. Renewal is then blocked for every installation, and within about 30 minutes all shared tokens have expired. The retry runs every minute and mints N tokens each time, only to drop them again. Could we skip the installation that fails, keep the rest, and report it through failures?
There was a problem hiding this comment.
done, tokens that have not expired are now reused and failures are collected
| Each generated `RenovateJob` reads only the repositories of its own | ||
| installation. With `hostRules` enabled, every generated `RenovateJob` also gets | ||
| the tokens of other installations of the App, so a run for one account can | ||
| resolve presets and GitHub API lookups hosted in another: |
There was a problem hiding this comment.
The rules match only /repos//. Graphql isn't covered which is used for github-tags and github-releases datasources and github.com//... for git-refs, Go modules and clones
I'd narrow the wording to presets and REST repos/ calls, so nobody expects private release lookups across orgs to work.
| cfg := hostRulesConfig{HostRules: make([]hostRule, 0, len(tokens))} | ||
| for _, t := range tokens { | ||
| cfg.HostRules = append(cfg.HostRules, hostRule{ | ||
| MatchHost: base + "/repos/" + t.Account + "/", |
There was a problem hiding this comment.
Renovate matches matchHost paths case-sensitively, and these rules use the login exactly as GitHub returns it. A preset referenced as github>org-a/… won't match an org whose login is Org-A. Could you add a sentence to the hostRules section of the docs saying that preset references must use the exact login?
28ba40a to
30807ed
Compare
Signed-off-by: Michael Rynkiewicz <michael.rynkiewicz@dynatrace.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This allows presets from one organization to be discoverable easily from renovate jobs running for different organizations of the same enterprise.