Skip to content

Commit

Permalink
Merge pull request openshift#1638 from enxebre/fix-panic
Browse files Browse the repository at this point in the history
Fix nil pointer dereference for hostedControlPlane.Spec.Etcd.Managed
  • Loading branch information
openshift-merge-robot authored Aug 2, 2022
2 parents d19b16d + bbfbd81 commit 48e2402
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/hostedcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ type HostedClusterSpec struct {
// changed.
//
// +kubebuilder:validation:Optional
// +kubebuilder:default={managementType: "Managed"}
// +kubebuilder:default={managementType: "Managed", managed: {storage: {type: "PersistentVolume", persistentVolume: {size: "4Gi"}}}}
// +immutable
Etcd EtcdSpec `json:"etcd"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,11 @@ spec:
type: object
etcd:
default:
managed:
storage:
persistentVolume:
size: 4Gi
type: PersistentVolume
managementType: Managed
description: Etcd specifies configuration for the control plane etcd
cluster. The default ManagementType is Managed. Once set, the ManagementType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ func (r *HostedControlPlaneReconciler) Reconcile(ctx context.Context, req ctrl.R
}

// Reconcile etcd restore status
if hostedControlPlane.Spec.Etcd.ManagementType == hyperv1.Managed && len(hostedControlPlane.Spec.Etcd.Managed.Storage.RestoreSnapshotURL) > 0 {
if hostedControlPlane.Spec.Etcd.ManagementType == hyperv1.Managed &&
hostedControlPlane.Spec.Etcd.Managed != nil && len(hostedControlPlane.Spec.Etcd.Managed.Storage.RestoreSnapshotURL) > 0 {
restoreCondition := meta.FindStatusCondition(hostedControlPlane.Status.Conditions, string(hyperv1.EtcdSnapshotRestored))
if restoreCondition == nil {
r.Log.Info("Reconciling etcd cluster restore status")
Expand Down
5 changes: 5 additions & 0 deletions hack/app-sre/saas_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21941,6 +21941,11 @@ objects:
type: object
etcd:
default:
managed:
storage:
persistentVolume:
size: 4Gi
type: PersistentVolume
managementType: Managed
description: Etcd specifies configuration for the control plane
etcd cluster. The default ManagementType is Managed. Once set,
Expand Down

0 comments on commit 48e2402

Please sign in to comment.