Skip to content

Commit

Permalink
Initialize Mirroring spec to avoid nil pointer exception
Browse files Browse the repository at this point in the history
Signed-off-by: Gowtham Shanmugasundaram <[email protected]>
  • Loading branch information
GowthamShanmugam committed Nov 26, 2024
1 parent 17353b7 commit 88c6177
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions addons/agent_mirrorpeer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,9 @@ func (r *MirrorPeerReconciler) toggleMirroring(ctx context.Context, storageClust
}

// Determine if mirroring should be enabled or disabled
if sc.spec.Mirroring == nil {

Check failure on line 376 in addons/agent_mirrorpeer_controller.go

View workflow job for this annotation

GitHub Actions / Ensure Clean Workdir (1.22)

sc.spec undefined (type "github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)

Check failure on line 376 in addons/agent_mirrorpeer_controller.go

View workflow job for this annotation

GitHub Actions / Go 1.22 Lint

sc.spec undefined (type "github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)

Check failure on line 376 in addons/agent_mirrorpeer_controller.go

View workflow job for this annotation

GitHub Actions / Go 1.22 Lint

sc.spec undefined (type "github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)
sc.spec.Mirroring = &ocsv1.MirroringSpec{}

Check failure on line 377 in addons/agent_mirrorpeer_controller.go

View workflow job for this annotation

GitHub Actions / Ensure Clean Workdir (1.22)

sc.spec undefined (type "github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)

Check failure on line 377 in addons/agent_mirrorpeer_controller.go

View workflow job for this annotation

GitHub Actions / Go 1.22 Lint

sc.spec undefined (type "github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)

Check failure on line 377 in addons/agent_mirrorpeer_controller.go

View workflow job for this annotation

GitHub Actions / Go 1.22 Lint

sc.spec undefined (type "github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)
}
if enabled {
oppPeers := getOppositePeerRefs(mp, r.SpokeClusterName)
if hasRequiredSecret(sc.Spec.Mirroring.PeerSecretNames, oppPeers) {
Expand Down
3 changes: 3 additions & 0 deletions addons/rook_secret_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ func updateStorageCluster(secretName, storageClusterName, storageClusterNamespac
}

// Update secret name
if sc.spec.Mirroring == nil {

Check failure on line 200 in addons/rook_secret_handler.go

View workflow job for this annotation

GitHub Actions / Ensure Clean Workdir (1.22)

sc.spec undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)

Check failure on line 200 in addons/rook_secret_handler.go

View workflow job for this annotation

GitHub Actions / Go 1.22 Lint

sc.spec undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)

Check failure on line 200 in addons/rook_secret_handler.go

View workflow job for this annotation

GitHub Actions / Go 1.22 Lint

sc.spec undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)
sc.spec.Mirroring = &ocsv1.MirroringSpec{}

Check failure on line 201 in addons/rook_secret_handler.go

View workflow job for this annotation

GitHub Actions / Ensure Clean Workdir (1.22)

sc.spec undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)

Check failure on line 201 in addons/rook_secret_handler.go

View workflow job for this annotation

GitHub Actions / Go 1.22 Lint

sc.spec undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec)) (typecheck)

Check failure on line 201 in addons/rook_secret_handler.go

View workflow job for this annotation

GitHub Actions / Go 1.22 Lint

sc.spec undefined (type *"github.com/red-hat-storage/ocs-operator/api/v4/v1".StorageCluster has no field or method spec, but does have Spec) (typecheck)
}
if !utils.ContainsString(sc.Spec.Mirroring.PeerSecretNames, secretName) {
sc.Spec.Mirroring.PeerSecretNames = append(sc.Spec.Mirroring.PeerSecretNames, secretName)
err := spokeClient.Update(ctx, sc)
Expand Down

0 comments on commit 88c6177

Please sign in to comment.