Skip to content

Commit

Permalink
Fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kovayur committed Feb 13, 2025
1 parent 60b9c39 commit 0807965
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
12 changes: 4 additions & 8 deletions fleetshard/pkg/central/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1037,25 +1037,21 @@ func (r *CentralReconciler) ensureRoutesDeleted(ctx context.Context, remoteCentr
reencryptErr := r.routeService.DeleteReencryptRoute(ctx, namespace)
passthroughErr := r.routeService.DeletePassthroughRoute(ctx, namespace)

if reencryptErr != nil && !apiErrors.IsNotFound(reencryptErr) { // ok if not found
if reencryptErr != nil {
return fmt.Errorf("deleting reencrypt route for namespace %q: %w", namespace, reencryptErr)
}
if passthroughErr != nil && !apiErrors.IsNotFound(passthroughErr) { // ok if not found
if passthroughErr != nil {
return fmt.Errorf("deleting passthrough route for namespace %q: %w", namespace, passthroughErr)
}
return nil
}

func (r *CentralReconciler) ensureCentralCASecretExists(ctx context.Context, centralNamespace string) (centralTLSSecretFound bool, err error) {
centralTLSSecretFound = true // pragma: allowlist secret
centralTLSSecret, err := r.getSecret(centralNamespace, k8s.CentralTLSSecretName)
if err != nil {
if apiErrors.IsNotFound(err) {
centralTLSSecretFound = false // pragma: allowlist secret
}
return centralTLSSecretFound, err
return !apiErrors.IsNotFound(err), err
}
return centralTLSSecretFound, ensureSecretExists(ctx, r.client, centralNamespace, centralCaTLSSecretName, func(secret *corev1.Secret) error {
return true, ensureSecretExists(ctx, r.client, centralNamespace, centralCaTLSSecretName, func(secret *corev1.Secret) error {
secret.Type = corev1.SecretTypeTLS
secret.Data = map[string][]byte{
corev1.TLSPrivateKeyKey: {},
Expand Down
5 changes: 4 additions & 1 deletion fleetshard/pkg/k8s/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/stackrox/acs-fleet-manager/fleetshard/config"
"github.com/stackrox/rox/pkg/errox"
apiErrors "k8s.io/apimachinery/pkg/api/errors"

openshiftRouteV1 "github.com/openshift/api/route/v1"
"github.com/stackrox/acs-fleet-manager/internal/dinosaur/pkg/api/private"
Expand Down Expand Up @@ -313,10 +314,12 @@ func (s *RouteService) deleteRoute(ctx context.Context, name string, namespace s
ObjectMeta: metav1.ObjectMeta{
Namespace: namespace,
Name: name,
Labels: map[string]string{ManagedByLabelKey: ManagedByFleetshardValue},
},
}
if err := s.client.Delete(ctx, route); err != nil {
if apiErrors.IsNotFound(err) {
return nil // ok if not found
}
return fmt.Errorf("deleting route %s/%s: %w", namespace, name, err)
}
return nil
Expand Down

0 comments on commit 0807965

Please sign in to comment.