Skip to content

Commit e6221df

Browse files
committed
refactor: emit apimachinery conflict error
1 parent 6454703 commit e6221df

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

hcloud/routes.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"golang.org/x/time/rate"
1111
corev1 "k8s.io/api/core/v1"
12+
apierrors "k8s.io/apimachinery/pkg/api/errors"
1213
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1314
"k8s.io/apimachinery/pkg/types"
1415
"k8s.io/client-go/tools/record"
@@ -179,6 +180,13 @@ func (r *routes) CreateRoute(ctx context.Context, _ string, _ string, route *clo
179180
}
180181
action, _, err := r.client.Network.AddRoute(ctx, r.network, opts)
181182
if err != nil {
183+
if hcloud.IsError(err, hcloud.ErrorCodeLocked, hcloud.ErrorCodeConflict) {
184+
return apierrors.NewConflict(
185+
corev1.Resource("nodes"),
186+
string(route.TargetNode),
187+
err,
188+
)
189+
}
182190
return fmt.Errorf("%s: %w", op, err)
183191
}
184192

0 commit comments

Comments
 (0)