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

fix: should encode additional target format just once per bundle reconcile #241

Merged
merged 1 commit into from
Nov 28, 2023

Conversation

erikgb
Copy link
Contributor

@erikgb erikgb commented Nov 23, 2023

While working on something else, I discovered that if a bundle specifies any additional format in targets, the JKS/PKCS12 is encoded for each and every target configmap/secret. This seems wrong to me, as encoding in these binary trust store formats is a quite heavy operation.

This PR moves the encoding of any additional target formats into buildSourceBundle method - which is executed once per bundle reconciliation. I tried to make this fix/refactoring as minimal as possible to not affect the WIP on #235 too much. We could eventually improve this even more in a follow-up PR - especially the tests, which have a lot of duplication at present.

@jetstack-bot jetstack-bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 23, 2023
@erikgb
Copy link
Contributor Author

erikgb commented Nov 23, 2023

/retest

@hawksight
Copy link
Member

@aidy - this might be interesting to review.

Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold

Got a couple of nitpicky comments, but they're not blockers. Feel free to address them or to unhold and merge, I'm fine either way!

pkg/bundle/sync.go Outdated Show resolved Hide resolved
Comment on lines 133 to 135
resolvedBundle.data = strings.Join(bundles, "\n") + "\n"

resolvedBundle.binaryData = make(map[string][]byte)
err := populateAdditionalFormatData(resolvedBundle.data, bundle.Spec.Target, resolvedBundle.binaryData)
if err != nil {
return bundleData{}, fmt.Errorf("failed encoding additional formats: %w", err)
}
Copy link
Member

Choose a reason for hiding this comment

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

nitpick (non-blocking): This could be refactored a little more - maybe as a method on bundleData. It's a no-op though so I'm definitely not going to block over it!

func (b *bundleData) populateData(pemData []byte, target trustapi.BundleTarget) error {
    b.data = pemData
    b.binaryData = ...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I didn't want to change too much to make it easier for #244. That was also noted in the PR description. But I'll take a look and see if this can be slightly more refactored now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I refactored some more. Hope this is closer to what you had in mind. PTAL!

Copy link
Member

Choose a reason for hiding this comment

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

Oh totally my bad - I missed that in the description. I would've totally been fine with you skipping this with that in mind! Thank you for doing it though 😁

@jetstack-bot jetstack-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed lgtm Indicates that a PR is ready to be merged. labels Nov 28, 2023
…ncile

Signed-off-by: Erik Godding Boye <egboye@gmail.com>
@erikgb
Copy link
Contributor Author

erikgb commented Nov 28, 2023

/test pull-trust-manager-verify

1 similar comment
@erikgb
Copy link
Contributor Author

erikgb commented Nov 28, 2023

/test pull-trust-manager-verify

Copy link
Member

@SgtCoDFish SgtCoDFish left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Thank you 🚀

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 28, 2023
@jetstack-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: SgtCoDFish

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@SgtCoDFish
Copy link
Member

/unhold

@jetstack-bot jetstack-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 28, 2023
@SgtCoDFish SgtCoDFish merged commit 6bb7d30 into cert-manager:main Nov 28, 2023
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants