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

Read secrets for onboarding-token validation #2790

Closed
wants to merge 8 commits into from

Conversation

mrudraia1
Copy link

This PR is a copy PR of #2715

I faced git account issues, I was not able to recover my account, so created a new PR with new account

This PR reads the secrets instead of reading the secrets from the volume mounts.
whenever the new onboarding secrets are created, it takes more time to read the secrets from the volume mounts,
The user clicks the rotate onboarding keys, the kubernetes still uses the old public, private keys , the new keys are mounted later, So this PR will read the secrets directly from the kubernetes secrets.

Copy link
Contributor

openshift-ci bot commented Sep 10, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mrudraia1
Once this PR has been reviewed and has the lgtm label, please assign jarrpa for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 10, 2024
Copy link
Contributor

openshift-ci bot commented Sep 10, 2024

Hi @mrudraia1. Thanks for your PR.

I'm waiting for a red-hat-storage 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-sigs/prow repository.

@malayparida2000
Copy link
Contributor

/ok-to-test

@openshift-ci openshift-ci bot 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 Sep 17, 2024
@mrudraia1
Copy link
Author

/ok-to-test

1 similar comment
@leelavg
Copy link
Contributor

leelavg commented Sep 17, 2024

/ok-to-test

Copy link
Contributor

@leelavg leelavg left a comment

Choose a reason for hiding this comment

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

much better, can merge it at the earliest.

)

type serverConfig struct {
client.Client
Copy link
Contributor

Choose a reason for hiding this comment

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

where is this being used?

Copy link
Author

Choose a reason for hiding this comment

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

removed, it is no were called

@@ -7,12 +7,17 @@ import (
"os"
"strconv"

"k8s.io/klog/v2"

v1 "github.com/red-hat-storage/ocs-operator/api/v4/v1"
Copy link
Contributor

Choose a reason for hiding this comment

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

pls change to ocsv1, we generally use v1 for native apis, even that I'm not seeing lately.

Copy link
Author

Choose a reason for hiding this comment

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

ack

@@ -5,6 +5,8 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

const onboardingValidationPrivateKeySecretName = "onboarding-private-key"
Copy link
Contributor

Choose a reason for hiding this comment

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

could you pls move this const to the file where it is being used?

Copy link
Author

Choose a reason for hiding this comment

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

ack

"sigs.k8s.io/controller-runtime/pkg/client"
)

func ReadPrivateKey(cl client.Client) (*rsa.PrivateKey, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why can't this function be in existing provider.go itself?

Copy link
Author

Choose a reason for hiding this comment

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

In Provider.go, their will be import issues for package
"crypto", "crypto/rand", "crypto/rsa". ReadPrivateKey function require "crypto/rsa", "crypto/x509". So for import conflicts, I created an new file.

Copy link
Contributor

Choose a reason for hiding this comment

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

could you pls expand on this, I don't see the issue.

Copy link
Author

Choose a reason for hiding this comment

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

Ack, deleted the onboarding_secrets.go and function called in provider.go

"sigs.k8s.io/controller-runtime/pkg/client"
)

func ReadPrivateKey(cl client.Client) (*rsa.PrivateKey, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

we aren't reading the key, we are getting it from API and parsing it as well, name GetParsedPrivateKey is more apt.

Copy link
Author

Choose a reason for hiding this comment

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

ok

klog.Info("Getting the Pem key")
ctx := context.Background()

operatorNamespace, err := GetOperatorNamespace()
Copy link
Contributor

Choose a reason for hiding this comment

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

get the namespace as param rather than reading it everytime, I see this is being used in two places where you can already have ns.

  1. in reconciler, already has it
  2. in handler, pls initialize ns once and read from it rather than reading from env everytime, ref remove rotation of keys endpoint from ux-backend #2569

Copy link
Author

Choose a reason for hiding this comment

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

ack

privateKey, err := util.ReadPrivateKey(r.Client)
if err != nil {
r.Log.Error(err, "Unable to get privatekey")
return reconcile.Result{}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

you might want to return an error here.

Copy link
Author

Choose a reason for hiding this comment

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

ack

@mrudraia1 mrudraia1 changed the title Read secrets for onboarding-token validation. Read secrets for onboarding-token validation Sep 17, 2024
@mrudraia1 mrudraia1 changed the title Read secrets for onboarding-token validation Bug 231102: [release-4.17] Read secrets for onboarding-token validation Sep 17, 2024
@openshift-ci openshift-ci bot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Sep 17, 2024
Copy link
Contributor

openshift-ci bot commented Sep 17, 2024

@mrudraia1: This pull request references Bugzilla bug 231102, which is valid.

No validations were run on this bug

In response to this:

Bug 231102: [release-4.17] Read secrets for onboarding-token validation

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-sigs/prow repository.

@leelavg
Copy link
Contributor

leelavg commented Sep 17, 2024

We add Bug <num>:[branch] to PR summary when we are back porting to that branch but not when targeting main

@mrudraia1 mrudraia1 changed the title Bug 231102: [release-4.17] Read secrets for onboarding-token validation Bug 231102: Read secrets for onboarding-token validation Sep 18, 2024
@mrudraia1 mrudraia1 changed the title Bug 231102: Read secrets for onboarding-token validation Read secrets for onboarding-token validation Sep 24, 2024
@openshift-ci openshift-ci bot removed bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. labels Sep 24, 2024
Copy link
Contributor

openshift-ci bot commented Sep 24, 2024

@mrudraia1: No Bugzilla bug is referenced in the title of this pull request.
To reference a bug, add 'Bug XXX:' to the title of this pull request and request another bug refresh with /bugzilla refresh.

In response to this:

Read secrets for onboarding-token validation

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-sigs/prow repository.

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

PR needs rebase.

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-sigs/prow repository.

malayparida2000 and others added 8 commits September 30, 2024 14:00
While adding the fields the description of the fields were directly
lifted off from rook-operator. The values of NearFull, BackfillFull &
Full in rook are 0.85, 0.90 & 0.95 respectively. But in OCS Operator
we set these values to 0.75, 0.80 & 0.85 respectively with the help
of the rook-config-override ConfigMap. So the description of the fields
in the API should reflect the actual values that are set in OCS.

Signed-off-by: Malay Kumar Parida <[email protected]>
Earlier the cluster utilization alert rules (CephClusterNearFull,
CephClusterCriticallyFull, CephClusterReadOnly) and the osd alert rules
(CephOSDNearFull, CephOSDCriticallyFull) were hardcoded to use the
nearFullRatio 0.75, criticallyFullRatio 0.80, and fullRatio 0.85 values.

But these values are now configurable on the storageCluster CR. So the
prometheus rules for these alerts will now be updated to use the
specified values if provided in the storageCluster CR.

This also includes the refactor of the changing the prometheus rule
process. The function is now easier to read, maintain & expand.
Also add tests for prometheus rule changing process.

Signed-off-by: Malay Kumar Parida <[email protected]>
The PR does the following:
1. add role to the onboarding ticket
2. add a new endpoint for peer-onboarding-tokens

Signed-off-by: Rewant Soni <[email protected]>
The commit does the following:
1. Create service, deployment, onboarding job for both modes
2. Update the variable from watchnamespace to podnamespace
3. Remove hardcoded name for storagecluster
4. Move client configmap in storageclient

Signed-off-by: Rewant Soni <[email protected]>
Signed-off-by: Rewant Soni <[email protected]>
Copy link
Contributor

openshift-ci bot commented Sep 30, 2024

@mrudraia1: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ci-bundle-ocs-operator-bundle 75c8e1b link true /test ci-bundle-ocs-operator-bundle
ci/prow/images 75c8e1b link true /test images
ci/prow/ocs-operator-bundle-e2e-aws 75c8e1b link true /test ocs-operator-bundle-e2e-aws

Full PR test history. Your PR dashboard.

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-sigs/prow repository. I understand the commands that are listed here.

@mrudraia1 mrudraia1 closed this Sep 30, 2024
@mrudraia1
Copy link
Author

reopened new PR 2827. closing this PR due to some conflicting files and commits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants