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

Move pkg/certificates from control-protocol to networking #802

Merged
merged 6 commits into from
Jun 6, 2023

Conversation

ReToCode
Copy link
Member

@ReToCode ReToCode commented May 2, 2023

Motivation

  • Currently Serving depends on control-protocol just for pkg/certificates
  • The constants and parts of the code in control-protocol is needed in net-* implementations

Changes

  • Move pkg/certificates from control-protocol to networking
  • Update the dependencies accordingly
  • Fixed lint warnings

Testing

Release Note
None

Docs
None

/kind cleanup

/cc @evankanderson, @nak3, @davidhadas, @dprotaso

Fixes #805

@knative-prow knative-prow bot added the kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. label May 2, 2023
@knative-prow knative-prow bot requested review from jsanin-vmw and kauana May 2, 2023 06:08
@knative-prow knative-prow bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label May 2, 2023
@codecov
Copy link

codecov bot commented May 2, 2023

Codecov Report

Patch coverage: 50.86% and project coverage change: -11.76 ⚠️

Comparison is base (0dbe4f9) 94.59% compared to head (0a2e7a6) 82.84%.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #802       +/-   ##
===========================================
- Coverage   94.59%   82.84%   -11.76%     
===========================================
  Files          41       45        +4     
  Lines        1259     1708      +449     
===========================================
+ Hits         1191     1415      +224     
- Misses         56      252      +196     
- Partials       12       41       +29     
Impacted Files Coverage Δ
.../networking/v1alpha1/serverlessservice_defaults.go 0.00% <0.00%> (ø)
pkg/certificates/reconciler/reconciler.go 30.08% <30.08%> (ø)
pkg/certificates/reconciler/controller_impl.go 62.50% <62.50%> (ø)
pkg/certificates/reconciler/certificates.go 68.03% <68.03%> (ø)
pkg/certificates/reconciler/controller.go 92.85% <92.85%> (ø)
...apis/networking/v1alpha1/certificate_validation.go 100.00% <100.00%> (ø)
pkg/apis/networking/v1alpha1/domain_defaults.go 100.00% <100.00%> (ø)
pkg/apis/networking/v1alpha1/domain_validation.go 100.00% <100.00%> (ø)
pkg/apis/networking/v1alpha1/ingress_defaults.go 100.00% <100.00%> (ø)
pkg/apis/networking/v1alpha1/ingress_validation.go 100.00% <100.00%> (ø)
... and 3 more

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@ReToCode
Copy link
Member Author

ReToCode commented May 2, 2023

I'd like to ignore lint errors to keep the code the same as in the origin and fix those in a new PR afterwards.

  Error: G101: Potential hardcoded credentials (gosec)
  Error: G101: Potential hardcoded credentials (gosec)
  Warning: var-naming: const LegacyFakeDnsName should be LegacyFakeDNSName (revive)
  Warning: var-naming: const FakeDnsName should be FakeDNSName (revive)
  Warning: var-naming: func parameter routingId should be routingID (revive)
  Warning: var-naming: func parameter routingId should be routingID (revive)
  Warning: var-naming: var routingId should be routingID (revive)
  Warning: var-naming: const secretRoutingId should be secretRoutingID (revive)
  Error: createCert - result cert is never used (unparam)
  Error: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)
  Error: non-wrapping format verb for fmt.Errorf. Use `%w` to format errors (errorlint)

Should be fine, as we have to update all usages anyway. FYI @davidhadas, @nak3

@nak3
Copy link
Contributor

nak3 commented May 2, 2023

/lgtm
/approve
/hold for other reviewers.

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 2, 2023
@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label May 2, 2023
@knative-prow
Copy link

knative-prow bot commented May 2, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nak3, ReToCode

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

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 2, 2023
@davidhadas
Copy link
Contributor

davidhadas commented May 3, 2023

@ReToCode
(1) Would it not be better to fix the lint and other issues in the original control-protocol repo and only then move to networking?
I think it is cleaner.
Consider any other PR that will be needed in networking until it is fixed - it will fail on Lint.

(2) As for changes needed in exported symbols that are being used as you correctly indicated elsewhere -changing such symbols may break stuff somewhere for someone at some code we do not control. In a way, if we can avoid making changes in exported symbols (e.g. ask Lint to not concern itself with this change) I would suggest to prefer this approach for exported symbols. Else, we can create a new correct export and leave the old export for a period of time as deprecated or something along this line.

@ReToCode
Copy link
Member Author

ReToCode commented May 3, 2023

This would be way more work (as this here is already done and tested) for something that is removed in control-protocol, also it seems that control-protocol has different lint settings, otherwise it would have failed there as well. But I get your point about the builds, then I'd prefer to go with fixing those in this PR in a separate commit.

Regarding the symbols. Agreed in general, but these are all just recently introduced by you for an undocumented alpha feature. We should be fine with changing them, right?

  • LegacyFakeDnsName -> just recently renamed
  • FakeDnsName -> just recently introduced
  • routingID -> internal
  • secretRoutingID -> internal

@davidhadas
Copy link
Contributor

davidhadas commented May 3, 2023

This would be way more work (as this here is already done and tested) for something that is removed in control-protocol, also it seems that control-protocol has different lint settings, otherwise it would have failed there as well. But I get your point about the builds, then I'd prefer to go with fixing those in this PR in a separate commit.

ok

Regarding the symbols. Agreed in general, but these are all just recently introduced by you for an undocumented alpha feature. We should be fine with changing them, right?

LegacyFakeDnsName -> just recently renamed
FakeDnsName -> just recently introduced
routingID -> internal
secretRoutingID -> internal

afaik, FakeDnsName is being used - this is why I did not change it.
All I did is deprecate it and replaced it with LegacyFakeDnsName to make people notice that we are making changes and moving away from the FakeDnsName.

@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label May 4, 2023
@ReToCode
Copy link
Member Author

ReToCode commented May 4, 2023

Updated the PR with lint-fixes. I kept the public symbols and added lint-comments to ignore those.

@ReToCode
Copy link
Member Author

ReToCode commented May 4, 2023

/hold as I need to check if test failures in Serving are related or flakes.

Copy link
Member

@evankanderson evankanderson left a comment

Choose a reason for hiding this comment

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

Apparently, I never sent my review.

If you want to clean these in the future, I don't feel very strongly about adding more to this PR.

pkg/certificates/certs.go Outdated Show resolved Hide resolved
return cert, err
}

func createCert(template, parent *x509.Certificate, pub, parentPriv interface{}) (cert *x509.Certificate, certPEM *pem.Block, err error) {
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we want to switch the pub and parentPriv to any like in x509.

pkg/certificates/certs.go Outdated Show resolved Hide resolved
pkg/certificates/certs.go Outdated Show resolved Hide resolved
pkg/certificates/certs.go Outdated Show resolved Hide resolved
pkg/certificates/certs.go Outdated Show resolved Hide resolved
@ReToCode
Copy link
Member Author

ReToCode commented May 5, 2023

If you want to clean these in the future, I don't feel very strongly about adding more to this PR.

@evankanderson I think I'd prefer to merge this one as closely to the original code from control-protocol and do a follow-up on the improvements. We also need to change all the usages of the code in serving and all net-* repos, then we'd also have better feedback if we break something in the dependant repos.

@ReToCode
Copy link
Member Author

/unhold

@evankanderson gentle ping

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label May 15, 2023
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2023
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 26, 2023
@ReToCode
Copy link
Member Author

Rebased here, rebased & retriggered the checking PR.

@evankanderson can you please take a look? ^^

pkg/certificates/certs.go Outdated Show resolved Hide resolved
pkg/certificates/certs.go Outdated Show resolved Hide resolved
pkg/certificates/constants.go Outdated Show resolved Hide resolved
pkg/certificates/certs.go Outdated Show resolved Hide resolved
@ReToCode
Copy link
Member Author

ReToCode commented Jun 1, 2023

Initially I intended to keep the code the same as in the source, but I'm also fine with fixing it in this PR so I updated the PR.

@dprotaso
Copy link
Member

dprotaso commented Jun 1, 2023

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jun 1, 2023
@nak3
Copy link
Contributor

nak3 commented Jun 6, 2023

A few lint error happens. Will we fix another PR or fix here?

@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Jun 6, 2023
@ReToCode
Copy link
Member Author

ReToCode commented Jun 6, 2023

Fixed the lint issue and cherry-picked knative-extensions/control-protocol@06411c4 to be at the same state as control-protocol. If this is merged, I'll start to migrate all the dependants to networking so we can depreciate the code in control-protocol.

@nak3
Copy link
Contributor

nak3 commented Jun 6, 2023

/lgtm
/hold

Thank you! /hold for test.

@knative-prow knative-prow 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. labels Jun 6, 2023
@ReToCode
Copy link
Member Author

ReToCode commented Jun 6, 2023

/unhold

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. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the certificate code moved from control-protocol
6 participants