Skip to content

Conversation

@amitupadh
Copy link

This PR adds an end-to-end test to validate that when a CertificateRequest contains the label certificaterequests.certman.managed.openshift.io, the following workflow is performed successfully:

  • Revoke the certificate associated with the CertificateRequest.
    
  • Delete the CertificateRequest after removing its finalizers.
    
  • Verify reconciliation creates a new CertificateRequest .
    
  • Ensure the total number of issued certificates remains unchanged before and after the process.
    

To run the test case, you need to export the below environment variable:
DISABLE_JUNIT_REPORT=false

To run the test:
go test -tags=osde2e ./test/e2e -v

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 11, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 11, 2025

@amitupadh: This pull request references SREP-1220 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.20.0" version, but no target version was set.

Details

In response to this:

This PR adds an end-to-end test to validate that when a CertificateRequest contains the label certificaterequests.certman.managed.openshift.io, the following workflow is performed successfully:

  • Revoke the certificate associated with the CertificateRequest.
    
  • Delete the CertificateRequest after removing its finalizers.
    
  • Verify reconciliation creates a new CertificateRequest .
    
  • Ensure the total number of issued certificates remains unchanged before and after the process.
    

To run the test case, you need to export the below environment variable:
DISABLE_JUNIT_REPORT=false

To run the test:
go test -tags=osde2e ./test/e2e -v

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 11, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 11, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 11, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

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

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

Details 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-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 20, 2025
@amitupadh amitupadh marked this pull request as ready for review August 29, 2025 09:40
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 29, 2025
@openshift-ci openshift-ci bot requested review from Mhodesty and tnierman August 29, 2025 09:40
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 17, 2025
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.15%. Comparing base (1cc6dff) to head (4fd5fa2).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #377   +/-   ##
=======================================
  Coverage   57.15%   57.15%           
=======================================
  Files          29       29           
  Lines        2138     2138           
=======================================
  Hits         1222     1222           
  Misses        802      802           
  Partials      114      114           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Dec 2, 2025

@amitupadh: all tests passed!

Full PR test history. Your PR dashboard.

Details

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.

@amitupadh
Copy link
Author

/label tide/merge-method-squash

@openshift-ci openshift-ci bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Dec 2, 2025

log.Log.Info("STEP 1: Fetching existing CertificateRequest with owned=true label")
crList, err := dynamicClient.Resource(crGVR).Namespace(namespace).List(ctx, metav1.ListOptions{
LabelSelector: "certificaterequests.certman.managed.openshift.io",
Copy link
Member

Choose a reason for hiding this comment

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

This label does not exist on any certificaterequest that I've seen: which component do we expect adds this?


// Step 2: Delete the CertificateRequest
log.Log.Info("STEP 2: Deleting the original CertificateRequest")
err = dynamicClient.Resource(crGVR).Namespace(namespace).Delete(ctx, originalCRName, metav1.DeleteOptions{})
Copy link
Member

Choose a reason for hiding this comment

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

Which certificaterequests are we deleting here? As far as I can tell, nothing was created in the BeforeAll() above, so it seems like we're expecting a certificaterequest to already exist in the test evironment.

In general, I would caution against us blindly deleting objects that we retrieved with a list operation unless we're using a specific Selector

Comment on lines +317 to +347
gomega.Eventually(func() bool {
cr, err := dynamicClient.Resource(crGVR).Namespace(namespace).Get(ctx, originalCRName, metav1.GetOptions{})
if err != nil {
log.Log.Info("CR appears to be deleted already", "name", originalCRName)
return true
}
if cr.GetDeletionTimestamp() == nil {
log.Log.Info("CR not marked for deletion yet", "name", cr.GetName())
return false
}

finalizers, found, err := unstructured.NestedStringSlice(cr.Object, "metadata", "finalizers")
if err != nil {
log.Log.Error(err, "Error retrieving finalizers")
return false
}
if !found || len(finalizers) == 0 {
log.Log.Info("No finalizers present", "name", cr.GetName())
return false
}

crCopy := cr.DeepCopy()
_ = unstructured.SetNestedStringSlice(crCopy.Object, []string{}, "metadata", "finalizers")

_, err = dynamicClient.Resource(crGVR).Namespace(namespace).Update(ctx, crCopy, metav1.UpdateOptions{})
if err != nil {
log.Log.Error(err, "Failed to remove finalizer")
return false
}
return true
}, 1*time.Minute, 5*time.Second).Should(gomega.BeTrue(), "Finalizer should be removed")
Copy link
Member

Choose a reason for hiding this comment

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

Why remove the finalizer? Shouldn't this test include coverage for certman-operator's own finalizing logic?


// Step 4: Wait for new CertificateRequest with new UID
var newCRName string
gomega.Eventually(func() bool {
Copy link
Member

@tnierman tnierman Dec 3, 2025

Choose a reason for hiding this comment

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

Unless we're creating a dnszone.hive.openshift.io object as a prerequisite to this test and I've missed it (which could very well be the case!), a new certificaterequest would never get recreated just because one was deleted

@amitupadh amitupadh marked this pull request as draft December 8, 2025 04:44
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Dec 8, 2025
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 8, 2025
@amitupadh
Copy link
Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 8, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants