Skip to content

Commit

Permalink
Merge pull request openstack-k8s-operators#851 from stuggi/fix_cond
Browse files Browse the repository at this point in the history
fix potential nil ptr for cond.Message
  • Loading branch information
openshift-merge-robot authored Jun 15, 2023
2 parents 5c910c9 + 9dc3f1b commit d6d1f98
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions controllers/openstackbaremetalset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ outer:
foundBaremetalHost := &metal3v1alpha1.BareMetalHost{}
err = r.Get(ctx, types.NamespacedName{Name: bmh, Namespace: "openshift-machine-api"}, foundBaremetalHost)
if err != nil {
cond.Message = fmt.Sprintf("Failed to get %s %s", foundBaremetalHost.Kind, foundBaremetalHost.Name)
cond.Message = fmt.Sprintf("Failed to get %s %s", foundBaremetalHost.Kind, bmh)
cond.Reason = shared.BaremetalHostCondReasonGetError
cond.Type = shared.CommonCondTypeError

Expand Down Expand Up @@ -1146,7 +1146,7 @@ func (r *OpenStackBaremetalSetReconciler) baremetalHostDeprovision(
baremetalHost := &metal3v1alpha1.BareMetalHost{}
err := r.Get(ctx, types.NamespacedName{Name: bmh.HostRef, Namespace: "openshift-machine-api"}, baremetalHost)
if err != nil {
cond.Message = fmt.Sprintf("Failed to get %s %s", baremetalHost.Kind, baremetalHost.Name)
cond.Message = fmt.Sprintf("Failed to get %s %s", baremetalHost.Kind, bmh.HostRef)
cond.Reason = shared.BaremetalHostCondReasonGetError
cond.Type = shared.CommonCondTypeError

Expand Down
6 changes: 3 additions & 3 deletions controllers/openstackclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ func (r *OpenStackClientReconciler) createPVCs(

pvc, op, err := common.CreateOrUpdatePvc(ctx, r, instance, &pvcDetails)
if err != nil {
cond.Message = fmt.Sprintf("Failed to create or update pvc %s ", pvc.Name)
cond.Message = fmt.Sprintf("Failed to create or update pvc %s ", pvcDetails.Name)
cond.Reason = shared.OsClientCondReasonPVCError
cond.Type = shared.CommonCondTypeError
err = common.WrapErrorForObject(cond.Message, instance, err)
Expand Down Expand Up @@ -773,7 +773,7 @@ func (r *OpenStackClientReconciler) createPVCs(

pvc, op, err = common.CreateOrUpdatePvc(ctx, r, instance, &pvcDetails)
if err != nil {
cond.Message = fmt.Sprintf("Failed to create or update pvc %s ", pvc.Name)
cond.Message = fmt.Sprintf("Failed to create or update pvc %s ", pvcDetails.Name)
cond.Reason = shared.OsClientCondReasonPVCError
cond.Type = shared.CommonCondTypeError
err = common.WrapErrorForObject(cond.Message, instance, err)
Expand Down Expand Up @@ -801,7 +801,7 @@ func (r *OpenStackClientReconciler) createPVCs(

pvc, op, err = common.CreateOrUpdatePvc(ctx, r, instance, &pvcDetails)
if err != nil {
cond.Message = fmt.Sprintf("Failed to create or update pvc %s ", pvc.Name)
cond.Message = fmt.Sprintf("Failed to create or update pvc %s ", pvcDetails.Name)
cond.Reason = shared.OsClientCondReasonPVCError
cond.Type = shared.CommonCondTypeError
err = common.WrapErrorForObject(cond.Message, instance, err)
Expand Down
2 changes: 1 addition & 1 deletion controllers/openstackipset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (r *OpenStackIPSetReconciler) Reconcile(ctx context.Context, req ctrl.Reque
Namespace: instance.Namespace},
osBms)
if err != nil && !k8s_errors.IsNotFound(err) {
cond.Message = fmt.Sprintf("Failed to get %s %s ", osBms.Kind, osBms.Name)
cond.Message = fmt.Sprintf("Failed to get %s %s ", osBms.Kind, instance.Labels[common.OwnerNameLabelSelector])
cond.Reason = shared.BaremetalSetCondReasonError
cond.Type = shared.CommonCondTypeError
err = common.WrapErrorForObject(cond.Message, instance, err)
Expand Down
2 changes: 1 addition & 1 deletion controllers/openstacknetattachment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ func (r *OpenStackNetAttachmentReconciler) getNodeNetworkConfigurationPolicyStat

err := r.Get(ctx, types.NamespacedName{Name: instance.Status.BridgeName}, networkConfigurationPolicy)
if err != nil {
cond.Message = fmt.Sprintf("Failed to get %s %s ", networkConfigurationPolicy.Kind, networkConfigurationPolicy.Name)
cond.Message = fmt.Sprintf("Failed to get %s %s ", networkConfigurationPolicy.Kind, instance.Status.BridgeName)
cond.Reason = shared.CommonCondReasonNNCPError
cond.Type = shared.NetAttachError
err = common.WrapErrorForObject(cond.Message, instance, err)
Expand Down
2 changes: 1 addition & 1 deletion controllers/openstacknetconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,7 @@ func (r *OpenStackNetConfigReconciler) ensureIPReservation(
osClient)
if err != nil {
if !k8s_errors.IsNotFound(err) {
cond.Message = fmt.Sprintf("Failed to get %s %s ", osClient.Kind, osClient.Name)
cond.Message = fmt.Sprintf("Failed to get %s %s ", osClient.Kind, osIPset.Labels[common.OwnerNameLabelSelector])
cond.Reason = shared.OsClientCondReasonError
cond.Type = shared.CommonCondTypeError
err = common.WrapErrorForObject(cond.Message, instance, err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/openstackipset/funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func EnsureIPs(
Namespace: obj.GetNamespace()},
ipSet)
if err != nil {
cond.Message = fmt.Sprintf("Failed to get %s %s ", ipSet.Kind, ipSet.Name)
cond.Message = fmt.Sprintf("Failed to get %s %s ", ipSet.Kind, strings.ToLower(name))
cond.Reason = shared.IPSetCondReasonError
cond.Type = shared.CommonCondTypeError
err = common.WrapErrorForObject(cond.Message, obj, err)
Expand Down

0 comments on commit d6d1f98

Please sign in to comment.