Skip to content

Commit c2bf665

Browse files
committed
Improve error handling
1 parent 7c45762 commit c2bf665

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

.golangci.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,14 @@ linters:
77
- ginkgolinter
88
- gofmt
99
- govet
10+
- gosec
11+
- errname
12+
- err113
1013
run:
1114
timeout: 5m
15+
16+
issues:
17+
exclude-rules:
18+
- path: '(.+)_test\.go'
19+
linters:
20+
- gosec

controllers/ovn_common.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
// fields to index to reconcile when changed
2929
const (
3030
tlsField = ".spec.tls.secretName"
31-
caBundleSecretNameField = ".spec.tls.caBundleSecretName"
31+
caBundleSecretNameField = ".spec.tls.caBundleSecretName" // #nosec
3232
topologyField = ".spec.topologyRef.Name"
3333
)
3434

controllers/ovncontroller_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ func (r *OVNControllerReconciler) reconcileNormal(ctx context.Context, instance
640640

641641
instance.Status.NetworkAttachments = networkAttachmentStatus
642642
if !networkReady {
643-
err := fmt.Errorf("not all pods have interfaces with ips as configured in NetworkAttachments: %s", instance.Spec.NetworkAttachment)
643+
err := fmt.Errorf("%w with ips as configured in NetworkAttachments: %s", util.ErrPodsInterfaces, instance.Spec.NetworkAttachment)
644644
instance.Status.Conditions.Set(condition.FalseCondition(
645645
condition.NetworkAttachmentsReadyCondition,
646646
condition.ErrorReason,

controllers/ovndbcluster_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance *
614614
if networkReady {
615615
instance.Status.Conditions.MarkTrue(condition.NetworkAttachmentsReadyCondition, condition.NetworkAttachmentsReadyMessage)
616616
} else {
617-
err := fmt.Errorf("not all pods have interfaces with ips as configured in NetworkAttachments: %s", instance.Spec.NetworkAttachment)
617+
err := fmt.Errorf("%w with ips as configured in NetworkAttachments: %s", util.ErrPodsInterfaces, instance.Spec.NetworkAttachment)
618618
instance.Status.Conditions.Set(condition.FalseCondition(
619619
condition.NetworkAttachmentsReadyCondition,
620620
condition.ErrorReason,
@@ -718,7 +718,7 @@ func getPodIPInNetwork(ovnPod corev1.Pod, namespace string, networkAttachment st
718718
}
719719
}
720720
// If this is reached it means that no IP was found, construct error and return
721-
err = fmt.Errorf("error while getting IP address from pod %s in network %s, IP is empty", ovnPod.Name, networkAttachment)
721+
err = fmt.Errorf("%w IP address from pod %s in network %s, IP is empty", util.ErrInvalidStatus, ovnPod.Name, networkAttachment)
722722
return "", err
723723
}
724724

0 commit comments

Comments
 (0)