Skip to content

Commit fa4c660

Browse files
Merge pull request #412 from chrisbug/secure-error
Improve error handling
2 parents 859787e + c2bf665 commit fa4c660

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
@@ -615,7 +615,7 @@ func (r *OVNDBClusterReconciler) reconcileNormal(ctx context.Context, instance *
615615
if networkReady {
616616
instance.Status.Conditions.MarkTrue(condition.NetworkAttachmentsReadyCondition, condition.NetworkAttachmentsReadyMessage)
617617
} else {
618-
err := fmt.Errorf("not all pods have interfaces with ips as configured in NetworkAttachments: %s", instance.Spec.NetworkAttachment)
618+
err := fmt.Errorf("%w with ips as configured in NetworkAttachments: %s", util.ErrPodsInterfaces, instance.Spec.NetworkAttachment)
619619
instance.Status.Conditions.Set(condition.FalseCondition(
620620
condition.NetworkAttachmentsReadyCondition,
621621
condition.ErrorReason,
@@ -719,7 +719,7 @@ func getPodIPInNetwork(ovnPod corev1.Pod, namespace string, networkAttachment st
719719
}
720720
}
721721
// If this is reached it means that no IP was found, construct error and return
722-
err = fmt.Errorf("error while getting IP address from pod %s in network %s, IP is empty", ovnPod.Name, networkAttachment)
722+
err = fmt.Errorf("%w IP address from pod %s in network %s, IP is empty", util.ErrInvalidStatus, ovnPod.Name, networkAttachment)
723723
return "", err
724724
}
725725

0 commit comments

Comments
 (0)