Skip to content

Commit

Permalink
Return an error if clusterSelector is not parsable
Browse files Browse the repository at this point in the history
  • Loading branch information
mgianluc committed Jan 11, 2024
1 parent db550c9 commit a0bcf6c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ARCH ?= amd64
OS ?= $(shell uname -s | tr A-Z a-z)
K8S_LATEST_VER ?= $(shell curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)
export CONTROLLER_IMG ?= $(REGISTRY)/$(IMAGE_NAME)
TAG ?= main
TAG ?= dev

.PHONY: all
all: build
Expand Down
2 changes: 1 addition & 1 deletion config/default/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ spec:
spec:
containers:
# Change the value of image field below to your controller image URL
- image: projectsveltos/access-manager-amd64:main
- image: projectsveltos/access-manager-amd64:dev
name: manager
7 changes: 5 additions & 2 deletions controllers/rolerequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,12 @@ func (r *RoleRequestReconciler) getMatchingClusters(ctx context.Context, roleReq
logger logr.Logger) ([]corev1.ObjectReference, error) {

var matchingCluster []corev1.ObjectReference
var err error
if roleRequestScope.GetSelector() != "" {
parsedSelector, _ := labels.Parse(roleRequestScope.GetSelector())
parsedSelector, err := labels.Parse(roleRequestScope.GetSelector())
if err != nil {
logger.V(logs.LogInfo).Info(fmt.Sprintf("failed to parse clusterSelector: %v", err))
return nil, err
}
matchingCluster, err = clusterproxy.GetMatchingClusters(ctx, r.Client, parsedSelector, "", logger)
if err != nil {
return nil, err
Expand Down
7 changes: 6 additions & 1 deletion controllers/rolerequest_transformations.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ func (r *RoleRequestReconciler) requeueRoleRequestForCluster(
// matching the Cluster
for k := range r.RoleRequests {
clusterProfileSelector := r.RoleRequests[k]
parsedSelector, _ := labels.Parse(string(clusterProfileSelector))
parsedSelector, err := labels.Parse(string(clusterProfileSelector))
if err != nil {
// When clusterSelector is fixed, this RoleRequest instance will
// be reconciled
continue
}
if parsedSelector.Matches(labels.Set(cluster.GetLabels())) {
l := logger.WithValues("roleRequest", k.Name)
l.V(logs.LogDebug).Info("queuing roleRequest")
Expand Down
2 changes: 1 addition & 1 deletion manifest/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ spec:
- --v=5
command:
- /manager
image: projectsveltos/access-manager-amd64:main
image: projectsveltos/access-manager-amd64:dev
livenessProbe:
httpGet:
path: /healthz
Expand Down

0 comments on commit a0bcf6c

Please sign in to comment.