Skip to content

Commit 565620a

Browse files
Add CaCert support for DPT
1 parent a16b223 commit 565620a

File tree

7 files changed

+825
-4
lines changed

7 files changed

+825
-4
lines changed

api/v1alpha1/dataprotectiontest_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ type DataProtectionTestSpec struct {
4646
// +kubebuilder:default=false
4747
// +optional
4848
ForceRun bool `json:"forceRun,omitempty"`
49+
50+
// skipTLSVerify controls whether to bypass TLS certificate validation
51+
// +kubebuilder:default=true
52+
// +optional
53+
SkipTLSVerify bool `json:"skipTLSVerify,omitempty"`
4954
}
5055

5156
// UploadSpeedTestConfig contains configuration for testing object storage upload performance.

bundle/manifests/oadp.openshift.io_dataprotectiontests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ spec:
189189
default: false
190190
description: forceRun will re-trigger the DPT even if it already completed
191191
type: boolean
192+
skipTLSVerify:
193+
default: true
194+
description: skipTLSVerify controls whether to bypass TLS certificate
195+
validation
196+
type: boolean
192197
uploadSpeedTestConfig:
193198
description: uploadSpeedTestConfig specifies parameters for an object
194199
storage upload speed test.

config/crd/bases/oadp.openshift.io_dataprotectiontests.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@ spec:
189189
default: false
190190
description: forceRun will re-trigger the DPT even if it already completed
191191
type: boolean
192+
skipTLSVerify:
193+
default: true
194+
description: skipTLSVerify controls whether to bypass TLS certificate
195+
validation
196+
type: boolean
192197
uploadSpeedTestConfig:
193198
description: uploadSpeedTestConfig specifies parameters for an object
194199
storage upload speed test.

internal/controller/dataprotectiontest_controller.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"sync"
2525
"time"
2626

27+
"github.com/aws/aws-sdk-go/aws/credentials"
2728
"github.com/go-logr/logr"
2829
"github.com/hashicorp/go-multierror"
2930
snapshotv1api "github.com/kubernetes-csi/external-snapshotter/client/v6/apis/volumesnapshot/v1"
@@ -240,7 +241,13 @@ func (r *DataProtectionTestReconciler) determineVendor(ctx context.Context, dpt
240241
return fmt.Errorf("failed to create HEAD request: %w", err)
241242
}
242243

243-
resp, err := http.DefaultClient.Do(req)
244+
// Build HTTP client with TLS configuration
245+
httpClient, err := buildHTTPClientWithTLS(dpt, backupLocationSpec, r.Log)
246+
if err != nil {
247+
return fmt.Errorf("failed to build HTTP client with TLS: %w", err)
248+
}
249+
250+
resp, err := httpClient.Do(req)
244251
if err != nil {
245252
return fmt.Errorf("HEAD request to %s failed: %w", s3Url, err)
246253
}
@@ -345,13 +352,22 @@ func (r *DataProtectionTestReconciler) initializeAWSProvider(ctx context.Context
345352
s3Url = ""
346353
}
347354

348-
// Initialize the AWS provider
349-
awsProvider := cloudprovider.NewAWSProvider(region, s3Url, accessKey, secretKey)
355+
// Create AWS session with TLS configuration
356+
sess, err := buildAWSSessionWithTLS(r.dpt, backupLocationSpec, region, s3Url, r.Log)
357+
if err != nil {
358+
return nil, fmt.Errorf("failed to create AWS session with TLS: %w", err)
359+
}
360+
361+
// Set credentials on the session
362+
sess.Config.Credentials = credentials.NewStaticCredentials(accessKey, secretKey, "")
363+
364+
// Initialize the AWS provider with the TLS-configured session
365+
awsProvider := cloudprovider.NewAWSProviderWithSession(sess)
350366
if awsProvider == nil {
351367
return nil, fmt.Errorf("failed to create AWS provider")
352368
}
353369

354-
r.Log.Info("Successfully initialized AWS provider", "region", region, "s3Url", s3Url)
370+
r.Log.Info("Successfully initialized AWS provider with TLS", "region", region, "s3Url", s3Url, "skipTLSVerify", r.dpt.Spec.SkipTLSVerify)
355371
return awsProvider, nil
356372
}
357373

0 commit comments

Comments
 (0)