Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .mise-tasks/test/_default
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@

set -e

# Export Docker environment variables for colima (if not already set)
if [ -z "$DOCKER_HOST" ]; then
if [ -S "$HOME/.colima/default/docker.sock" ]; then
export DOCKER_HOST="unix://$HOME/.colima/default/docker.sock"
# For testcontainers to work with colima, we need to tell it where the docker socket is
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE="$HOME/.colima/default/docker.sock"
# This allows testcontainers to use the host docker socket directly
export TESTCONTAINERS_HOST_OVERRIDE="localhost"
# Disable the Ryuk container that manages test container cleanup with colima
export TESTCONTAINERS_RYUK_DISABLED="true"
fi
fi

# shellcheck disable=SC2154
if [ "$usage_coverage" = "true" ]; then
rm -f hack/coverprofile.txt
Expand Down
11 changes: 11 additions & 0 deletions internal/kubernetes/watcher/object_manager.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package watcher

import (
"context"
"fmt"
"time"

Expand Down Expand Up @@ -78,6 +79,16 @@ func (c *clusterManager) createInformer(obj runtime.Object, gvr *schema.GroupVer
c.log.WithError(err).WithField("resource", gvr.String()).Error("resource not available in cluster")
return nil, *gvr, fmt.Errorf("resource not available in cluster")
}

// Also verify we have permission to list the resource by doing a test list with limit=1
// This prevents errors at runtime when the informer tries to watch resources we can't access
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
_, err = c.client.Resource(*gvr).List(ctx, v1.ListOptions{Limit: 1})
if err != nil {
c.log.WithError(err).WithField("resource", gvr.String()).Warn("no permission to list resource, skipping watcher")
return nil, *gvr, fmt.Errorf("no permission to list resource: %w", err)
}
Comment on lines +82 to +91
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hvorfor trenger vi dette?
Hvis det er rettigheter som er problemet, så er det fint at vi rett og slett blir spamma imho. Vi kan også fikse rettighetene uten å måtte restarte api etterpå, no?

}

if lblSelector == "" {
Expand Down