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

[release-4.5] Bug 1835090: Collect certificates #70

Merged
merged 4 commits into from Feb 19, 2020
Merged

[release-4.5] Bug 1835090: Collect certificates #70

merged 4 commits into from Feb 19, 2020

Conversation

martinkunc
Copy link
Contributor

@martinkunc martinkunc commented Jan 27, 2020

The task should add collection of Certificate features, which could be used to verify their validity in further stages.

@openshift-ci-robot
Copy link
Contributor

Hi @martinkunc. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 27, 2020
func() ([]record.Record, []error) {
requests, err := i.certClient.CertificateSigningRequests().List(metav1.ListOptions{})
if errors.IsNotFound(err) {
return nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this is used in previous gathering functions, but is the nil handled properly later?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fortunately returning nil in a slice will return empty slice and wont fail. It looks even empty Record wont fail as its just a structure. I have just verified both.

*certificatesv1b1api.CertificateSigningRequest
}

func (a CSRAnonymizer) Marshal(_ context.Context) ([]byte, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick - all public methods should have proper docstring

Copy link
Contributor

Choose a reason for hiding this comment

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

these comments are still pending, would be nice to add some docs in the whole file.

"k8s.io/apimachinery/pkg/util/json"
)

type CSRAnonymizer struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpick - all public data types should have proper docstring

}
csr, err := x509.ParseCertificateRequest(block.Bytes)
if err != nil {
return
Copy link
Contributor

Choose a reason for hiding this comment

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

don't we need to log these issues?

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

In overall it is a very nice work!

c.Spec.Request.PublicKeyAlgorithm = csr.PublicKeyAlgorithm.String()
c.Spec.Request.DNSNames = utils.Map(csr.DNSNames, anonymizeURL)
c.Spec.Request.EmailAddresses = utils.Map(csr.EmailAddresses, anonymizeURL)
ipsl := []string{}
Copy link
Contributor

Choose a reason for hiding this comment

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

if we know len(csr.IPAddresses), you can allocate an array, but it's up to you

package utils

// Map applies each of functions to passed slice
func Map(it []string, fn func(string) string) []string {
Copy link
Contributor

Choose a reason for hiding this comment

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

in the future, we might create a common utils package outside operator

Copy link
Contributor

Choose a reason for hiding this comment

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

in the future, Go may add map-reduce functions, but there already libraries like this available.

Copy link
Contributor

@tisnik tisnik left a comment

Choose a reason for hiding this comment

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

LGTM, but I think that golinter will fail on current sources ;/

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 27, 2020
@iNecas
Copy link
Contributor

iNecas commented Jan 31, 2020

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 31, 2020
@tisnik
Copy link
Contributor

tisnik commented Jan 31, 2020

/ok-to-test

@martinkunc
Copy link
Contributor Author

/retest

1 similar comment
@martinkunc
Copy link
Contributor Author

/retest

@tisnik
Copy link
Contributor

tisnik commented Feb 4, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 4, 2020
@martinkunc
Copy link
Contributor Author

/assign iNecas

@iNecas
Copy link
Contributor

iNecas commented Feb 5, 2020

Great job on adding tests as well.

I'm a bit concerned about the possible amounts of the records, so I would suggest filtering out Approved CSRs, as they would probably not be very valuable for troubleshooting.

@smarterclayton any suggestion for somebody close to CSRs to give us some hinds on what kinds of CSRs types are useful for troubleshooting?

@onmete
Copy link

onmete commented Feb 5, 2020

Well, we don't need the actual certificate, we are just using that to extract expiration date. If the cert is expired or will be expired on week or so.

I'm totally fine if the data extraction will be part of the collection mechanism.

So basically we just need info if the cert is approved and expiration date.

If it is still too much data, we can move all logic to the operator and collect just unapproved, expired and those, which will expire in 7 (we can discuss this number) days.

@martinkunc
Copy link
Contributor Author

I can either filter all, or just gather certain data from Approved. Do you have any idea about numbers here ?

One idea was that we might start thinking about maybe different profiles of small and bigger size.
While one could be really statistical, the other could be all-in-one for detailed investigation.

Which way would be the best for now ?

@iNecas
Copy link
Contributor

iNecas commented Feb 5, 2020

My main question is, whether we care (have a use-case) for the approved ones, or we are interested into some specific cases?

@onmete
Copy link

onmete commented Feb 6, 2020

As far as I know, we don't care about approved ones (at least from the Insights perspective).

@smarterclayton
Copy link
Contributor

Can you describe in more detail why we are collecting this? What scenarios will this enable us to detect (or which bugs are we seeing in the field that this info would return)?

@onmete
Copy link

onmete commented Feb 7, 2020

The unapproved or expired certificates were a root issue in some customer cases.
Hence it seems useful to collect this info in advance and possibly show it to the customer.

Are we missing something?

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Feb 18, 2020
func IncludeCSR(c *CSRAnonymizedFeatures, opts ...FilterOptFunc) bool {
opt := &FilterOpt{time: time.Now()}
for _, o := range opts {
o(opt)
Copy link
Contributor

Choose a reason for hiding this comment

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

these variables names are not good, e, t, o, i, etc, it could be a little more descriptive. In this case it could be optFn.

@martinkunc
Copy link
Contributor Author

/retest

@tisnik
Copy link
Contributor

tisnik commented Feb 19, 2020

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 19, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: martinkunc, tisnik

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

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 392fb20 into openshift:master Feb 19, 2020
@@ -0,0 +1,10 @@
package utils

Copy link
Contributor

Choose a reason for hiding this comment

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

In general in go we do not create utility packages like this. This is a trivial method and would inline privately in a package. Utility packages cause dependency creep and attract unrelated use cases, which cause coupling.

Please move this to a private method at the package call site.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the comment. It makes sense, I will remove this in some further PR.

@martinkunc
Copy link
Contributor Author

/retitle [release-4.3] Bug 1835090: Collect certificates

@openshift-ci-robot openshift-ci-robot changed the title Collect certificates [release-4.3] Bug 1835090: Collect certificates May 13, 2020
@openshift-ci-robot
Copy link
Contributor

@martinkunc: All pull requests linked via external trackers have merged: . Bugzilla bug 1835090 has been moved to the MODIFIED state.

In response to this:

[release-4.3] Bug 1835090: Collect certificates

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@martinkunc
Copy link
Contributor Author

/retitle [release-4.5] Bug 1835090: Collect certificates

@openshift-ci-robot openshift-ci-robot changed the title [release-4.3] Bug 1835090: Collect certificates [release-4.5] Bug 1835090: Collect certificates May 13, 2020
@openshift-ci-robot
Copy link
Contributor

@martinkunc: Bugzilla bug 1835090 is in an unrecognized state (MODIFIED) and will not be moved to the MODIFIED state.

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@martinkunc
Copy link
Contributor Author

/bugzilla refresh

@openshift-ci-robot
Copy link
Contributor

@martinkunc: All pull requests linked via external trackers have merged: . Bugzilla bug 1835090 has been moved to the MODIFIED state.

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot
Copy link
Contributor

@martinkunc: Bugzilla bug 1835090 is in an unrecognized state (MODIFIED) and will not be moved to the MODIFIED state.

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

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. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants