Skip to content

fix: address shubham's review feedback on DPT CACertRef handling - #2

Merged
msfrucht merged 1 commit into
msfrucht:cacertref_dptfrom
kaovilai:shubham-feedback-2443
Oct 5, 2026
Merged

msfrucht merged 1 commit into
msfrucht:cacertref_dptfrom
kaovilai:shubham-feedback-2443

Conversation

@kaovilai

@kaovilai kaovilai commented Oct 5, 2026

Copy link
Copy Markdown

Addresses @shubham-pampattiwar's review feedback on openshift#2443 (5 inline comments plus the follow-up comment on retrieveCAData).

Feedback Change
Resolved CA is read again in initializeProvider CA is resolved once per reconcile (resolveCAData) and passed into initializeProvider and initializeAWSProvider. One reconcile now uses one CA value and does one Secret lookup.
skipTLSVerify=true fails on a missing CACertRef Secret resolveCAData returns nil without touching the Secret when skipTLSVerify is set. Covered by a new test.
CACertRef resolved for GCP/Azure, which never receive caCertData Resolution is limited to the AWS-compatible path, so GCP/Azure no longer gain a Secret dependency. Covered by new tests.
E2E helper only checks phase, so a TLS failure can pass CreateDPTAndAssertComplete now also returns an error when status.uploadTest.success is false, including ErrorMessage.
Lock in Velero-compatible precedence New retrieveCAData case with both CACertRef and inline CACert set, asserting the Secret value is returned.

CA selection stays in retrieveCAData and buildTLSConfig only consumes the resolved bytes, as requested in the follow-up comment.

Validation

  • go build ./..., go vet, golangci-lint run ./internal/controller/... ./tests/e2e/lib/... -> 0 issues.
  • Unit tests pass: TestRetrieveCAData (including the new precedence case) and the new TestResolveCAData (aws, skipTLSVerify with a missing Secret, aws with a missing Secret, gcp, azure, nil spec).
  • Not run locally: the envtest suite (TestAPIs) needs bin/k8s/.../etcd, which is not installed here. It fails identically on the unmodified base, so it is an environment limitation, not a regression.
  • The e2e helper change and the CACertRef e2e test need a cluster and were not run here.

Not addressed: the comment asking for a DPT test that makes an HTTPS request using a referenced CA Secret is the existing e2e (cacert_suite_test.go), which this PR's stricter helper now makes meaningful.

- Resolve the CA once per reconcile (resolveCAData) and pass the bytes into
  initializeProvider/initializeAWSProvider instead of re-reading CACertRef,
  so one reconcile uses one CA value and does one Secret lookup.
- Skip CA resolution when skipTLSVerify is true, so a missing CACertRef
  Secret no longer fails a DPT that disables verification.
- Resolve the CA only for AWS-compatible providers; GCP and Azure do not
  receive caCertData, so resolving it only added an unused Secret
  dependency.
- E2E helper: fail when status.uploadTest.success is false (including
  ErrorMessage), since the reconciler marks the DPT Complete even when the
  upload failed and phase alone made the CACertRef test a false positive.
- Tests: retrieveCAData case with both CACertRef and inline CACert asserting
  the Secret value wins; TestResolveCAData covering aws, skipTLSVerify with a
  missing Secret, aws with a missing Secret, gcp/azure, and a nil spec.

Co-authored-by: Hermes Agent <noreply@hermes-agent>
Signed-off-by: Tiger Kaovilai <tkaovila@redhat.com>
Copilot AI balanced review requested due to automatic review settings October 5, 2026 18:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

The focused changes match the controller’s TLS and status handling, with relevant unit coverage and no unresolved blocking issues.

Review effort: Balanced
Findings: None

What changed in this PR

Refines certificate-authority handling in OADP’s DataProtectionTest controller and strengthens end-to-end validation.

Changes:

  • Resolves CA data once per reconcile, skipping lookup for non-AWS providers or disabled TLS verification.
  • Makes the end-to-end helper reject failed uploads even when the phase is Complete.
  • Adds tests for Secret precedence and CA-resolution conditions.
File Description
tests/​e2e/​lib/​dpt.go Checks upload success and reports failure details.
internal/​controller/​dataprotectiontest_controller.go Resolves CA data conditionally and reuses it during provider initialization.
internal/​controller/​dataprotectiontest_controller_test.go Updates initialization calls and tests CA-selection behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

if r.dpt != nil && r.dpt.Spec.SkipTLSVerify {
return nil, nil
}
if backupLocationSpec == nil || !strings.EqualFold(backupLocationSpec.Provider, AWSProvider) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

The Azure/GCP plugins don't respect providing custom CAs anyways.

I don't see how this helps, anyone doing so is configuring the object incorrectly. But I don't see this hurting to force ignoring for anything other than aws.

Comment thread tests/e2e/lib/dpt.go
if dpt.Status.Phase != "Complete" {
return fmt.Errorf("DataProtectionTest %s reached phase %q (error: %s)", dpt.Name, dpt.Status.Phase, dpt.Status.ErrorMessage)
}
// The reconciler marks the DPT Complete even when the upload itself failed

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

If there is ever a DPTv2 I would ask this to change.

One expects when the phase is "Completed" all parts were successful and otherwise either PartialFailed or PartialComplete or PartialSuccess or similar. With a condition array added to explain.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Client: fakeClient,
Log: logr.Discard(),
NamespacedName: types.NamespacedName{Namespace: namespace, Name: "test-obj"},
Context: context.Background(),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Should be t.Context(). I'll submit a commit to fix this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks

},
}

caData, err := reconciler.resolveCAData(context.Background(), tt.bsl)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Same here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants