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

fixed re-trigger job issue when public key deleted #2385

Merged
merged 1 commit into from
Feb 1, 2024

Conversation

rchikatw
Copy link
Contributor

@rchikatw rchikatw commented Jan 12, 2024

  • fixed re-trigger job issue when the public key deleted
  • formatted the logger in a proper format

controllers/storagecluster/provider_server.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
Copy link
Member

@jarrpa jarrpa left a comment

Choose a reason for hiding this comment

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

I made a few comments mostly asking for clarity on a few things. I'd also like to see anything that's not directly related to the problem solution (like the util function and the csv-merger changes) in a separate commit, but if that's not common practice in this part of the project I'm all right with leaving it as one commit.

controllers/util/util.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
tools/csv-merger/csv-merger.go Outdated Show resolved Hide resolved
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 18, 2024
@rchikatw rchikatw force-pushed the onboarding branch 2 times, most recently from 137afe0 to 270454e Compare January 19, 2024 13:10
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 19, 2024
@rchikatw rchikatw force-pushed the onboarding branch 2 times, most recently from 69ebda0 to da4b74d Compare January 23, 2024 13:50
controllers/storagecluster/storagecluster_controller.go Outdated Show resolved Hide resolved
controllers/util/util.go Outdated Show resolved Hide resolved
onboarding/main.go Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
controllers/storagecluster/storagecluster_controller.go Outdated Show resolved Hide resolved
controllers/storagecluster/storagecluster_controller.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
@rchikatw rchikatw force-pushed the onboarding branch 6 times, most recently from 10448b2 to 570da08 Compare January 25, 2024 10:37
controllers/storagecluster/provider_server.go Outdated Show resolved Hide resolved
controllers/storagecluster/storagecluster_controller.go Outdated Show resolved Hide resolved
controllers/storagecluster/storagecluster_controller.go Outdated Show resolved Hide resolved
controllers/storagecluster/storagecluster_controller.go Outdated Show resolved Hide resolved
controllers/storagecluster/storagecluster_controller.go Outdated Show resolved Hide resolved
@nb-ohad
Copy link
Contributor

nb-ohad commented Jan 25, 2024

@rchikatw why aren't we setting a controller reference on the secrets and using an Own watch?
If we don't do it we need to make sure to delete the secrets ourselves!

@rchikatw rchikatw force-pushed the onboarding branch 3 times, most recently from 4d333be to 1de667e Compare January 26, 2024 07:53
onboarding/main.go Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 29, 2024
@nb-ohad
Copy link
Contributor

nb-ohad commented Jan 29, 2024

I made a few comments mostly asking for clarity on a few things. I'd also like to see anything that's not directly related to the problem solution (like the util function and the csv-merger changes) in a separate commit, but if that's not common practice in this part of the project I'm all right with leaving it as one commit.

@jarrpa Regarding the separation into separate PRs. From my point of view, a PR needs to be a complete contribution not to be dependent on some code that needs to be reviewed somewhere else.

Because of that, I would claim that a separate PR is an overkill but I do agree that it makes sense to separate these parts into different commits under the same PR, similar to what I ask when we have vendor changes.

@jarrpa
Copy link
Member

jarrpa commented Jan 29, 2024

Just to note, I poked at the whole pointer-to-value thing and effectively came to a similar conclusion to yours... with one catch: there's already a k8s library for this: https://pkg.go.dev/k8s.io/utils/ptr I find its implementation more elegant (and more complete), so I'd like to move to that.

I submitted a draft PR to showcase its usage. I based it on this PR, so as soon as this one merges I'll mark mine as no longer a draft.

@rchikatw
Copy link
Contributor Author

/retest

onboarding/main.go Outdated Show resolved Hide resolved
@nb-ohad
Copy link
Contributor

nb-ohad commented Jan 30, 2024

@rchikatw What is the reason you choose to use different formats for marshaling of private and public keys?

You use PKCS1 for the private key:
privteKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey)

And PKIX for the public key:
publicKeyBytes, err := x509.MarshalPKIXPublicKey(publicKey)

controllers/storagecluster/provider_server.go Outdated Show resolved Hide resolved
controllers/storagecluster/storagecluster_controller.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
onboarding/main.go Outdated Show resolved Hide resolved
@rchikatw
Copy link
Contributor Author

rchikatw commented Jan 30, 2024

@rchikatw What is the reason you choose to use different formats for marshaling of private and public keys?

You use PKCS1 for the private key: privteKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey)

And PKIX for the public key: publicKeyBytes, err := x509.MarshalPKIXPublicKey(publicKey)

A good catch actually but I never faced any issues while onboarding the application cluster. I did generate the token several times and onboarded the application cluster. But let me try once changing x509.MarshalPKIXPublicKey -> x509.MarshalPKCS1PublicKey

I found the reason why I am using PKIX for marshaling the public key, when a new OnboardConsumer RPC call to onboard a new OCS application cluster happens it parses the public key using the ParsePKIXPublicKey so i have used the same for the public key. refer here and there is no function marshell private key using PKIX

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 30, 2024
@nb-ohad
Copy link
Contributor

nb-ohad commented Jan 31, 2024

@rchikatw What is the reason you choose to use different formats for marshaling of private and public keys?
You use PKCS1 for the private key: privteKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey)
And PKIX for the public key: publicKeyBytes, err := x509.MarshalPKIXPublicKey(publicKey)

A good catch actually but I never faced any issues while onboarding the application cluster. I did generate the token several times and onboarded the application cluster. But let me try once changing x509.MarshalPKIXPublicKey -> x509.MarshalPKCS1PublicKey

I found the reason why I am using PKIX for marshaling the public key, when a new OnboardConsumer RPC call to onboard a new OCS application cluster happens it parses the public key using the ParsePKIXPublicKey so i have used the same for the public key. refer here and there is no function marshell private key using PKIX

But in that case shouldn't we just align the server code to use PKCS1 as well?

P.S
I just found this
https://stackoverflow.com/questions/49876521/golang-x509-marshalpkixpublickey-vs-x509-marshalpkcs1publickey#:~:text=Add%20a%20comment-,1%20Answer,-Sorted%20by%3A

According to this PCIX was designed to be used for key certificates. It encodes an identity as well as encryption. I think we should align all of our code to use PKCS1. That means both private and public keys

@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 31, 2024
@rchikatw
Copy link
Contributor Author

rchikatw commented Jan 31, 2024

@rchikatw What is the reason you choose to use different formats for marshaling of private and public keys?
You use PKCS1 for the private key: privteKeyBytes := x509.MarshalPKCS1PrivateKey(privateKey)
And PKIX for the public key: publicKeyBytes, err := x509.MarshalPKIXPublicKey(publicKey)

A good catch actually but I never faced any issues while onboarding the application cluster. I did generate the token several times and onboarded the application cluster. But let me try once changing x509.MarshalPKIXPublicKey -> x509.MarshalPKCS1PublicKey
I found the reason why I am using PKIX for marshaling the public key, when a new OnboardConsumer RPC call to onboard a new OCS application cluster happens it parses the public key using the ParsePKIXPublicKey so i have used the same for the public key. refer here and there is no function marshell private key using PKIX

But in that case shouldn't we just align the server code to use PKCS1 as well?

P.S I just found this https://stackoverflow.com/questions/49876521/golang-x509-marshalpkixpublickey-vs-x509-marshalpkcs1publickey#:~:text=Add%20a%20comment-,1%20Answer,-Sorted%20by%3A

According to this PCIX was designed to be used for key certificates. It encodes an identity as well as encryption. I think we should align all of our code to use PKCS1. That means both private and public keys

Yes that solves the problem if we used PKCS1 at both places (Client & provider) and for both the keys, Let me do that and verify

@rchikatw
Copy link
Contributor Author

rchikatw commented Feb 1, 2024

/retest

@nb-ohad
Copy link
Contributor

nb-ohad commented Feb 1, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 1, 2024
Copy link
Contributor

openshift-ci bot commented Feb 1, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: leelavg, nb-ohad, rchikatw

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-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 1, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 35ac7ee into red-hat-storage:main Feb 1, 2024
11 checks passed
@leelavg
Copy link
Contributor

leelavg commented Feb 1, 2024

/cherrypick release-4.15

@leelavg
Copy link
Contributor

leelavg commented Feb 1, 2024

/cherrypick fusion-hci-4.14

@openshift-cherrypick-robot

@leelavg: new pull request created: #2438

In response to this:

/cherrypick release-4.15

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-cherrypick-robot

@leelavg: #2385 failed to apply on top of branch "fusion-hci-4.14":

Applying: fixed re trigger job issue when public key deleted
Using index info to reconstruct a base tree...
M	controllers/storagecluster/provider_server.go
M	controllers/storagecluster/storagecluster_controller.go
M	services/provider/server/server.go
Falling back to patching base and 3-way merge...
Auto-merging services/provider/server/server.go
Auto-merging controllers/storagecluster/storagecluster_controller.go
CONFLICT (content): Merge conflict in controllers/storagecluster/storagecluster_controller.go
Auto-merging controllers/storagecluster/provider_server.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 fixed re trigger job issue when public key deleted
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherrypick fusion-hci-4.14

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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants