Skip to content

Commit

Permalink
Add a log message when a there is a file with size more than the allo…
Browse files Browse the repository at this point in the history
…wed limit
  • Loading branch information
rohitsakala committed Oct 16, 2024
1 parent 7ead36a commit a0d1d86
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/controllers/dashboard/plugin/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package plugin
import (
"context"
"fmt"
"strconv"

"github.com/pkg/errors"
"github.com/rancher/rancher/pkg/namespace"
"github.com/rancher/rancher/pkg/settings"
"github.com/rancher/rancher/pkg/wrangler"
"github.com/sirupsen/logrus"

Expand Down Expand Up @@ -66,9 +68,17 @@ func (h *handler) OnPluginChange(key string, plugin *v1.UIPlugin) (*v1.UIPlugin,
} else {
plugin.Status.CacheState = Pending
}

maxFileSize, err := strconv.ParseInt(settings.MaxUIPluginFileByteSize.Get(), 10, 64)
if err != nil {
logrus.Errorf("failed to convert setting MaxUIPluginFileByteSize to int64, using fallback. err: %s", err.Error())
maxFileSize = settings.DefaultMaxUIPluginFileSizeInBytes
}

for _, p := range cachedPlugins {
err2 := FsCache.SyncWithControllersCache(p)
if errors.Is(err2, errMaxFileSizeError) {
logrus.Errorf("one of the files is more than the defaultUIPluginFileByteSize limit %s", strconv.FormatInt(maxFileSize, 10))
// update CRD to remove cache
p.Spec.Plugin.NoCache = true
_, err2 := h.plugin.Update(p)
Expand Down

0 comments on commit a0d1d86

Please sign in to comment.