Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request rancher#34939 from rmweir/update-error
Add cluster ID to error
  • Loading branch information
rmweir committed Oct 5, 2021
2 parents 1874d54 + fc3b290 commit 62c101a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions pkg/controllers/managementuser/settings/controller.go
Expand Up @@ -2,6 +2,7 @@ package settings

import (
"context"
"fmt"

v3 "github.com/rancher/rancher/pkg/apis/management.cattle.io/v3"
"github.com/rancher/rancher/pkg/settings"
Expand All @@ -19,7 +20,8 @@ var (
)

type handler struct {
apply apply.Apply
clusterID string
apply apply.Apply
}

func Register(ctx context.Context, userContext *config.UserContext) error {
Expand All @@ -29,7 +31,8 @@ func Register(ctx context.Context, userContext *config.UserContext) error {
}

h := &handler{
apply: apply.WithDynamicLookup(),
clusterID: userContext.ClusterName,
apply: apply.WithDynamicLookup().WithCacheTypes(userContext.Management.Wrangler.Mgmt.Setting()),
}

userContext.Management.Management.Settings("").AddHandler(ctx, "copy-settings", h.onChange)
Expand All @@ -41,7 +44,7 @@ func (h *handler) onChange(key string, obj *v3.Setting) (runtime.Object, error)
return nil, nil
}

return obj, h.apply.
err := h.apply.
WithOwner(obj).
ApplyObjects(&v3.Setting{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -50,4 +53,8 @@ func (h *handler) onChange(key string, obj *v3.Setting) (runtime.Object, error)
Value: obj.Value,
Default: obj.Default,
})
if err != nil {
return obj, fmt.Errorf("error applying setting object for cluster [%s]: %v", h.clusterID, err)
}
return obj, nil
}

0 comments on commit 62c101a

Please sign in to comment.