Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ linters:
default: none
enable:
- copyloopvar
- errcheck
- gocyclo
- govet
- ineffassign
- loggercheck
- mirror
- misspell
- nilnil
- nolintlint
- staticcheck
- unconvert
- unused
- unparam
- unused
exclusions:
generated: lax
presets:
Expand All @@ -32,6 +35,7 @@ linters:
- third_party$
- builtin$
- examples$
- pkg/common/concurrentviper/generated\.go$
formatters:
enable:
- gofumpt
Expand Down
7 changes: 5 additions & 2 deletions cmd/osde2e/provision/cmd.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package provision

import (
"errors"
"fmt"

"github.com/openshift/osde2e/cmd/osde2e/common"
Expand Down Expand Up @@ -80,7 +81,6 @@ func init() {
_ = viper.BindPFlag(config.Tests.OnlyHealthCheckNodes, Cmd.PersistentFlags().Lookup("only-health-check-nodes"))
}

//nolint:gocyclo
func run(cmd *cobra.Command, argv []string) error {
var err error
if err = common.LoadConfigs(args.configString, "", args.secretLocations); err != nil {
Expand All @@ -92,5 +92,8 @@ func run(cmd *cobra.Command, argv []string) error {
}

_, err = clusterutil.Provision(provider)
return err
if err != nil && !errors.Is(err, clusterutil.ErrReserveFull) {
return err
}
return nil
}
14 changes: 8 additions & 6 deletions internal/sanitizer/sanitizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ func (s *Sanitizer) sanitizeContent(content, source string, timestamp time.Time)

// Perform audit logging asynchronously to avoid blocking
if s.auditLog != nil && (matchCount > 0 || !s.config.SkipAuditOnNoMatch) {
go s.auditLog.Log(AuditEntry{
Timestamp: timestamp,
Source: source,
RulesApplied: rulesApplied,
MatchCount: matchCount,
})
go func() {
_ = s.auditLog.Log(AuditEntry{
Timestamp: timestamp,
Source: source,
RulesApplied: rulesApplied,
MatchCount: matchCount,
})
}()
}

return result, nil
Expand Down
8 changes: 4 additions & 4 deletions pkg/common/aws/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ type S3UploadResult struct {
// Upload is automatically enabled when LOG_BUCKET is set.
// Reuses the global CcsAwsSession for AWS credentials and session management.
// The component parameter is used to organize artifacts in S3 (e.g., "osd-example-operator").
//
// TODO: Refactor to use dependency injection instead of viper globals.
// Should accept (bucket, region, component string) parameters for better testability
// and reusability. Caller should check config and decide whether to upload.
func NewS3Uploader(component string) (*S3Uploader, error) {
bucket := viper.GetString(config.Tests.LogBucket)
if bucket == "" {
// S3 upload disabled - no bucket configured
return nil, nil
}

// Ensure region is set (default to us-east-1)
if viper.GetString(config.AWSRegion) == "" {
Expand Down
12 changes: 0 additions & 12 deletions pkg/common/aws/s3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,6 @@ func TestBuildS3Key(t *testing.T) {
}
}

func TestNewS3Uploader_Disabled(t *testing.T) {
viper.Set(config.Tests.LogBucket, "")

uploader, err := NewS3Uploader("test-component")
if err != nil {
t.Errorf("NewS3Uploader() with disabled config returned error: %v", err)
}
if uploader != nil {
t.Error("NewS3Uploader() should return nil when LOG_BUCKET is empty")
}
}

func TestBuildBaseKey(t *testing.T) {
tests := []struct {
key string
Expand Down
3 changes: 1 addition & 2 deletions pkg/common/cluster/clusterutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,8 @@ func Provision(provider spi.Provider) (*spi.Cluster, error) {
if err != nil {
if errors.Is(err, ErrReserveFull) {
log.Printf("Reserve full, exiting without provisioning")
Comment thread
christophermancini marked this conversation as resolved.
return nil, nil
}
return nil, fmt.Errorf("failed to set up or retrieve cluster: %v", err)
return nil, fmt.Errorf("failed to set up or retrieve cluster: %w", err)
}

viper.Set(config.Cluster.ID, cluster.ID())
Expand Down
1 change: 0 additions & 1 deletion pkg/common/concurrentviper/generated.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// nolint
package concurrentviper

import (
Expand Down
3 changes: 2 additions & 1 deletion pkg/common/providers/ocmprovider/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ func (o *OCMProvider) IsValidClusterName(clusterName string) (bool, error) {
}

// LaunchCluster setups an new cluster using the OSD API and returns it's ID.
// nolint:gocyclo
//
//nolint:gocyclo
func (o *OCMProvider) LaunchCluster(clusterName string) (string, error) {
flavourID := getFlavour()
skuID := getSKU()
Expand Down
18 changes: 9 additions & 9 deletions pkg/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,27 +249,27 @@ func (o *E2EOrchestrator) Report(ctx context.Context) error {

runner.ReportClusterInstallLogs(o.provider)

// Upload test artifacts to S3 if bucket set
if viper.GetString(config.Tests.LogBucket) != "" {
if err := o.uploadToS3(); err != nil {
log.Printf("S3 upload failed: %v", err)
// Don't fail the overall report phase for S3 upload errors
}
// Upload test artifacts to S3 if bucket configured
if err := o.uploadToS3(); err != nil {
log.Printf("S3 upload failed: %v", err)
// Don't fail the overall report phase for S3 upload errors
}

return nil
}

// uploadToS3 uploads the report directory contents to S3.
func (o *E2EOrchestrator) uploadToS3() error {
// Check if S3 bucket is configured
if viper.GetString(config.Tests.LogBucket) == "" {
return nil // S3 upload not configured, skip
}

component := deriveComponentFromTestImage()
uploader, err := aws.NewS3Uploader(component)
if err != nil {
return fmt.Errorf("failed to create S3 uploader: %w", err)
}
if uploader == nil {
return nil // S3 upload not enabled
}

reportDir := viper.GetString(config.ReportDir)
if reportDir == "" {
Expand Down
2 changes: 1 addition & 1 deletion test/sdn_migration/sdn_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ func runTerraformCommand(command string) (map[string]tfexec.OutputMeta, error) {
if err != nil {
return nil, fmt.Errorf("terraform destroy failed: %v", err.Error())
}
return map[string]tfexec.OutputMeta{}, nil
default:
return nil, fmt.Errorf("unknown command: %s", command)
}
return nil, nil
}

func cluterOperatorHealthCheck(ctx context.Context, clusterClient *openshiftclient.Client, logger logr.Logger) error {
Expand Down