diff --git a/backend/cmd/headlamp.go b/backend/cmd/headlamp.go index 24504a8ab38..d5be709b7df 100644 --- a/backend/cmd/headlamp.go +++ b/backend/cmd/headlamp.go @@ -97,6 +97,7 @@ const ( type clientConfig struct { Clusters []Cluster `json:"clusters"` IsDynamicClusterEnabled bool `json:"isDynamicClusterEnabled"` + FiltersWarningsOnly bool `json:"filtersWarningsOnly"` } type OauthConfig struct { @@ -1750,7 +1751,11 @@ func parseClusterFromKubeConfig(kubeConfigs []string) ([]Cluster, []error) { func (c *HeadlampConfig) getConfig(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") - clientConfig := clientConfig{c.getClusters(), c.EnableDynamicClusters} + clientConfig := clientConfig{ + Clusters: c.getClusters(), + IsDynamicClusterEnabled: c.EnableDynamicClusters, + FiltersWarningsOnly: c.FiltersWarningsOnly, + } if err := json.NewEncoder(w).Encode(&clientConfig); err != nil { logger.Log(logger.LevelError, nil, err, "encoding config") diff --git a/backend/cmd/stateless.go b/backend/cmd/stateless.go index a7d395c23cd..befb4da6476 100644 --- a/backend/cmd/stateless.go +++ b/backend/cmd/stateless.go @@ -178,7 +178,11 @@ func (c *HeadlampConfig) parseKubeConfig(w http.ResponseWriter, r *http.Request) return } - clientConfig := clientConfig{contexts, c.EnableDynamicClusters} + clientConfig := clientConfig{ + Clusters: contexts, + IsDynamicClusterEnabled: c.EnableDynamicClusters, + FiltersWarningsOnly: c.FiltersWarningsOnly, + } if err := json.NewEncoder(w).Encode(&clientConfig); err != nil { logger.Log(logger.LevelError, nil, err, "encoding config") diff --git a/backend/pkg/config/config.go b/backend/pkg/config/config.go index 8aca9c8db2e..88f44dfb874 100644 --- a/backend/pkg/config/config.go +++ b/backend/pkg/config/config.go @@ -82,6 +82,8 @@ type Config struct { UseOTLPHTTP *bool `koanf:"use-otlp-http"` StdoutTraceEnabled *bool `koanf:"stdout-trace-enabled"` SamplingRate *float64 `koanf:"sampling-rate"` + // FiltersWarningsOnly is the default state of the events filter (true = only warnings, false = all events). + FiltersWarningsOnly bool `koanf:"filters-warnings-only"` // TLS config TLSCertPath string `koanf:"tls-cert-path"` TLSKeyPath string `koanf:"tls-key-path"` @@ -448,6 +450,7 @@ func addGeneralFlags(f *flag.FlagSet) { f.Uint("port", defaultPort, "Port to listen from") f.String("proxy-urls", "", "Allow proxy requests to specified URLs") f.Bool("enable-helm", false, "Enable Helm operations") + f.Bool("filters-warnings-only", true, "Whether to filter events by warnings only by default") } func addOIDCFlags(f *flag.FlagSet) { diff --git a/backend/pkg/headlampconfig/headlampConfig.go b/backend/pkg/headlampconfig/headlampConfig.go index 66f0f006f5c..422ebb4682a 100644 --- a/backend/pkg/headlampconfig/headlampConfig.go +++ b/backend/pkg/headlampconfig/headlampConfig.go @@ -63,4 +63,5 @@ type HeadlampCFG struct { TLSCertPath string TLSKeyPath string SessionTTL int + FiltersWarningsOnly bool } diff --git a/charts/headlamp/templates/deployment.yaml b/charts/headlamp/templates/deployment.yaml index 3cbe214b9f9..1184f86e9cb 100644 --- a/charts/headlamp/templates/deployment.yaml +++ b/charts/headlamp/templates/deployment.yaml @@ -325,6 +325,7 @@ spec: {{- with .Values.config.tlsKeyPath }} - "-tls-key-path={{ . }}" {{- end }} + - "-filters-warnings-only={{ dig "events" "warningsOnly" true .Values.config }}" {{- with .Values.config.extraArgs }} {{- toYaml . | nindent 12 }} {{- end }} diff --git a/charts/headlamp/tests/expected_templates/azure-oidc-with-validators.yaml b/charts/headlamp/tests/expected_templates/azure-oidc-with-validators.yaml index 2cd2b07f275..99cf0d7cf91 100644 --- a/charts/headlamp/tests/expected_templates/azure-oidc-with-validators.yaml +++ b/charts/headlamp/tests/expected_templates/azure-oidc-with-validators.yaml @@ -129,6 +129,7 @@ spec: - "-oidc-validator-client-id=$(OIDC_VALIDATOR_CLIENT_ID)" # Check if validatorIssuerURL is non empty either from env or oidc.config - "-oidc-validator-idp-issuer-url=$(OIDC_VALIDATOR_ISSUER_URL)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/default.yaml b/charts/headlamp/tests/expected_templates/default.yaml index d4f3d4d1da3..14870c7f942 100644 --- a/charts/headlamp/tests/expected_templates/default.yaml +++ b/charts/headlamp/tests/expected_templates/default.yaml @@ -114,6 +114,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/extra-args.yaml b/charts/headlamp/tests/expected_templates/extra-args.yaml index 1e92ecbe160..34609ba7e81 100644 --- a/charts/headlamp/tests/expected_templates/extra-args.yaml +++ b/charts/headlamp/tests/expected_templates/extra-args.yaml @@ -114,6 +114,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" - -insecure-ssl ports: - name: http diff --git a/charts/headlamp/tests/expected_templates/extra-manifests.yaml b/charts/headlamp/tests/expected_templates/extra-manifests.yaml index 679e97174d2..836ab32c87c 100644 --- a/charts/headlamp/tests/expected_templates/extra-manifests.yaml +++ b/charts/headlamp/tests/expected_templates/extra-manifests.yaml @@ -131,6 +131,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/host-users-override.yaml b/charts/headlamp/tests/expected_templates/host-users-override.yaml index b5853be7afe..d92e2c0f49e 100644 --- a/charts/headlamp/tests/expected_templates/host-users-override.yaml +++ b/charts/headlamp/tests/expected_templates/host-users-override.yaml @@ -114,6 +114,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/httproute-enabled.yaml b/charts/headlamp/tests/expected_templates/httproute-enabled.yaml index 260577e3b67..466409e5ecf 100644 --- a/charts/headlamp/tests/expected_templates/httproute-enabled.yaml +++ b/charts/headlamp/tests/expected_templates/httproute-enabled.yaml @@ -114,6 +114,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/me-user-info-url-directly.yaml b/charts/headlamp/tests/expected_templates/me-user-info-url-directly.yaml index 6b449cbdad7..a43fd64ff7b 100644 --- a/charts/headlamp/tests/expected_templates/me-user-info-url-directly.yaml +++ b/charts/headlamp/tests/expected_templates/me-user-info-url-directly.yaml @@ -117,6 +117,7 @@ spec: - "-session-ttl=86400" # Check if externalSecret is disabled - "-me-user-info-url=$(ME_USER_INFO_URL)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/me-user-info-url.yaml b/charts/headlamp/tests/expected_templates/me-user-info-url.yaml index c38039ad51e..42751a18c22 100644 --- a/charts/headlamp/tests/expected_templates/me-user-info-url.yaml +++ b/charts/headlamp/tests/expected_templates/me-user-info-url.yaml @@ -121,6 +121,7 @@ spec: - "-session-ttl=86400" # Check if externalSecret is disabled - "-me-user-info-url=$(ME_USER_INFO_URL)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/namespace-override-oidc-create-secret.yaml b/charts/headlamp/tests/expected_templates/namespace-override-oidc-create-secret.yaml index d9829a6471e..72c351fa1a0 100644 --- a/charts/headlamp/tests/expected_templates/namespace-override-oidc-create-secret.yaml +++ b/charts/headlamp/tests/expected_templates/namespace-override-oidc-create-secret.yaml @@ -146,6 +146,7 @@ spec: - "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)" # Check if scopes are non empty either from env or oidc.config - "-oidc-scopes=$(OIDC_SCOPES)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/namespace-override.yaml b/charts/headlamp/tests/expected_templates/namespace-override.yaml index 3309df1b148..0f4fce14809 100644 --- a/charts/headlamp/tests/expected_templates/namespace-override.yaml +++ b/charts/headlamp/tests/expected_templates/namespace-override.yaml @@ -114,6 +114,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/non-azure-oidc.yaml b/charts/headlamp/tests/expected_templates/non-azure-oidc.yaml index b79ed218edc..c6c19bc30f3 100644 --- a/charts/headlamp/tests/expected_templates/non-azure-oidc.yaml +++ b/charts/headlamp/tests/expected_templates/non-azure-oidc.yaml @@ -121,6 +121,7 @@ spec: - "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)" # Check if scopes are non empty either from env or oidc.config - "-oidc-scopes=$(OIDC_SCOPES)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/oidc-create-secret.yaml b/charts/headlamp/tests/expected_templates/oidc-create-secret.yaml index be8b1053627..5596e3076e1 100644 --- a/charts/headlamp/tests/expected_templates/oidc-create-secret.yaml +++ b/charts/headlamp/tests/expected_templates/oidc-create-secret.yaml @@ -146,6 +146,7 @@ spec: - "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)" # Check if scopes are non empty either from env or oidc.config - "-oidc-scopes=$(OIDC_SCOPES)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/oidc-directly-env.yaml b/charts/headlamp/tests/expected_templates/oidc-directly-env.yaml index 1a11327ff4a..ae391df03b1 100644 --- a/charts/headlamp/tests/expected_templates/oidc-directly-env.yaml +++ b/charts/headlamp/tests/expected_templates/oidc-directly-env.yaml @@ -130,6 +130,7 @@ spec: - "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)" # Check if scopes are non empty either from env or oidc.config - "-oidc-scopes=$(OIDC_SCOPES)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/oidc-directly.yaml b/charts/headlamp/tests/expected_templates/oidc-directly.yaml index efd6f484fa9..4894566cfb6 100644 --- a/charts/headlamp/tests/expected_templates/oidc-directly.yaml +++ b/charts/headlamp/tests/expected_templates/oidc-directly.yaml @@ -121,6 +121,7 @@ spec: - "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)" # Check if scopes are non empty either from env or oidc.config - "-oidc-scopes=$(OIDC_SCOPES)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/oidc-external-secret.yaml b/charts/headlamp/tests/expected_templates/oidc-external-secret.yaml index fce13971223..361529de2f9 100644 --- a/charts/headlamp/tests/expected_templates/oidc-external-secret.yaml +++ b/charts/headlamp/tests/expected_templates/oidc-external-secret.yaml @@ -111,6 +111,7 @@ spec: - "-oidc-client-secret=$(OIDC_CLIENT_SECRET)" - "-oidc-idp-issuer-url=$(OIDC_ISSUER_URL)" - "-oidc-scopes=$(OIDC_SCOPES)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/oidc-pkce.yaml b/charts/headlamp/tests/expected_templates/oidc-pkce.yaml index 8c547595325..00303b7bd4d 100644 --- a/charts/headlamp/tests/expected_templates/oidc-pkce.yaml +++ b/charts/headlamp/tests/expected_templates/oidc-pkce.yaml @@ -124,6 +124,7 @@ spec: # Check if scopes are non empty either from env or oidc.config - "-oidc-scopes=$(OIDC_SCOPES)" - "-oidc-use-pkce=$(OIDC_USE_PKCE)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/oidc-validator-overrides.yaml b/charts/headlamp/tests/expected_templates/oidc-validator-overrides.yaml index b7502bf4dc4..91c275c14c4 100644 --- a/charts/headlamp/tests/expected_templates/oidc-validator-overrides.yaml +++ b/charts/headlamp/tests/expected_templates/oidc-validator-overrides.yaml @@ -133,6 +133,7 @@ spec: - "-oidc-validator-idp-issuer-url=$(OIDC_VALIDATOR_ISSUER_URL)" # Check if useAccessToken is non false either from env or oidc.config - "-oidc-use-access-token=$(OIDC_USE_ACCESS_TOKEN)" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/pod-disruption.yaml b/charts/headlamp/tests/expected_templates/pod-disruption.yaml index d1baf88e2b7..0e95f5d0935 100644 --- a/charts/headlamp/tests/expected_templates/pod-disruption.yaml +++ b/charts/headlamp/tests/expected_templates/pod-disruption.yaml @@ -134,6 +134,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/security-context.yaml b/charts/headlamp/tests/expected_templates/security-context.yaml index 8f4bc68ef87..02cdb12cfd8 100644 --- a/charts/headlamp/tests/expected_templates/security-context.yaml +++ b/charts/headlamp/tests/expected_templates/security-context.yaml @@ -140,6 +140,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/tls-added.yaml b/charts/headlamp/tests/expected_templates/tls-added.yaml index f615fb53eea..0bc98d5e5e9 100644 --- a/charts/headlamp/tests/expected_templates/tls-added.yaml +++ b/charts/headlamp/tests/expected_templates/tls-added.yaml @@ -116,6 +116,7 @@ spec: # Check if externalSecret is disabled - "-tls-cert-path=/headlamp-cert/headlamp-ca.crt" - "-tls-key-path=/headlamp-cert/headlamp-tls.key" + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/topology-spread-constraints-custom-selector.yaml b/charts/headlamp/tests/expected_templates/topology-spread-constraints-custom-selector.yaml index 3ce615b3218..0ce608a0b15 100644 --- a/charts/headlamp/tests/expected_templates/topology-spread-constraints-custom-selector.yaml +++ b/charts/headlamp/tests/expected_templates/topology-spread-constraints-custom-selector.yaml @@ -114,6 +114,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/topology-spread-constraints.yaml b/charts/headlamp/tests/expected_templates/topology-spread-constraints.yaml index f896efeb48c..d2d21413e0c 100644 --- a/charts/headlamp/tests/expected_templates/topology-spread-constraints.yaml +++ b/charts/headlamp/tests/expected_templates/topology-spread-constraints.yaml @@ -114,6 +114,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/tests/expected_templates/volumes-added.yaml b/charts/headlamp/tests/expected_templates/volumes-added.yaml index 117bb1ada49..8eee7ca0fce 100644 --- a/charts/headlamp/tests/expected_templates/volumes-added.yaml +++ b/charts/headlamp/tests/expected_templates/volumes-added.yaml @@ -114,6 +114,7 @@ spec: - "-plugins-dir=/headlamp/plugins" - "-session-ttl=86400" # Check if externalSecret is disabled + - "-filters-warnings-only=true" ports: - name: http containerPort: 4466 diff --git a/charts/headlamp/values.yaml b/charts/headlamp/values.yaml index bc9d30f99b9..d76ab1c048f 100644 --- a/charts/headlamp/values.yaml +++ b/charts/headlamp/values.yaml @@ -38,6 +38,9 @@ config: baseURL: "" # -- session token TTL in seconds (default is 24 hours) sessionTTL: 86400 + events: + # -- Whether to filter events by warnings only by default + warningsOnly: true oidc: # Option 1: # @param config.oidc.secret - OIDC secret configuration @@ -161,8 +164,7 @@ podLabels: {} hostUsers: true # -- Headlamp pod's Security Context -podSecurityContext: - {} +podSecurityContext: {} # fsGroup: 2000 # -- Headlamp containers Security Context @@ -184,7 +186,6 @@ securityContext: # drop: # - ALL - service: # -- Annotations to add to the service annotations: {} @@ -211,8 +212,7 @@ persistentVolumeClaim: # -- Enable Persistent Volume Claim enabled: false # -- Annotations to add to the persistent volume claim (if enabled) - annotations: - {} + annotations: {} # -- accessModes for the persistent volume claim, eg: ReadWriteOnce, ReadOnlyMany, ReadWriteMany etc. accessModes: [] # -- size of the persistent volume claim, eg: 10Gi. Required if enabled is true. @@ -228,8 +228,7 @@ ingress: # -- Enable ingress controller resource enabled: false # -- Annotations for Ingress resource - annotations: - {} + annotations: {} # kubernetes.io/tls-acme: "true" # -- Additional labels to add to the Ingress resource @@ -242,8 +241,7 @@ ingress: # -- Hostname(s) for the Ingress resource # Please refer to https://kubernetes.io/docs/reference/kubernetes-api/service-resources/ingress-v1/#IngressSpec for more information. - hosts: - [] + hosts: [] # - host: chart-example.local # paths: # - path: / @@ -288,8 +286,7 @@ httpRoute: # port: 80 # -- CPU/Memory resource requests/limits -resources: - {} +resources: {} # We usually recommend not to specify default resources and to leave this as a conscious # choice for the user. This also increases chances charts run on environments with little # resources, such as Minikube. If you do want to specify resources, uncomment the following @@ -353,8 +350,7 @@ pluginsManager: # cpu: "1000m" # memory: "4096Mi" # If omitted, the plugin manager will inherit the global securityContext - securityContext: - {} + securityContext: {} # runAsUser: 1001 # runAsNonRoot: true # allowPrivilegeEscalation: false diff --git a/frontend/src/components/cluster/Overview.tsx b/frontend/src/components/cluster/Overview.tsx index 60f435f612b..7a5e8ccf153 100644 --- a/frontend/src/components/cluster/Overview.tsx +++ b/frontend/src/components/cluster/Overview.tsx @@ -104,7 +104,8 @@ export default function Overview() { function EventsSection() { const EVENT_WARNING_SWITCH_FILTER_STORAGE_KEY = 'EVENT_WARNING_SWITCH_FILTER_STORAGE_KEY'; - const EVENT_WARNING_SWITCH_DEFAULT = true; + const filtersWarningsOnly = useTypedSelector(state => state.config.filtersWarningsOnly); + const EVENT_WARNING_SWITCH_DEFAULT = filtersWarningsOnly; const { t } = useTranslation(['translation', 'glossary']); const location = useLocation(); const queryParams = new URLSearchParams(location.search); diff --git a/frontend/src/components/project/NewProjectPopup.stories.tsx b/frontend/src/components/project/NewProjectPopup.stories.tsx index b22da09e030..23d28da8312 100644 --- a/frontend/src/components/project/NewProjectPopup.stories.tsx +++ b/frontend/src/components/project/NewProjectPopup.stories.tsx @@ -46,6 +46,7 @@ const makeStore = () => { timezone: 'UTC', useEvict: true, }, + filtersWarningsOnly: true, }, projects: { headerActions: {}, diff --git a/frontend/src/components/project/ProjectCreateFromYaml.stories.tsx b/frontend/src/components/project/ProjectCreateFromYaml.stories.tsx index d08e47a47c1..6f57e6d4120 100644 --- a/frontend/src/components/project/ProjectCreateFromYaml.stories.tsx +++ b/frontend/src/components/project/ProjectCreateFromYaml.stories.tsx @@ -45,6 +45,7 @@ const makeStore = () => { timezone: 'UTC', useEvict: true, }, + filtersWarningsOnly: true, }, projects: { headerActions: {}, diff --git a/frontend/src/redux/configSlice.ts b/frontend/src/redux/configSlice.ts index 422831c6d98..2b8003d7aab 100644 --- a/frontend/src/redux/configSlice.ts +++ b/frontend/src/redux/configSlice.ts @@ -42,6 +42,10 @@ export interface ConfigState { allClusters: { [clusterName: string]: Cluster; } | null; + /** + * Whether to filter events by warnings only by default. + */ + filtersWarningsOnly: boolean; /** * Settings is a map of settings names to settings values. */ @@ -71,6 +75,7 @@ export const initialState: ConfigState = { clusters: null, statelessClusters: null, allClusters: null, + filtersWarningsOnly: true, settings: { tableRowsPerPageOptions: storedSettings.tableRowsPerPageOptions || defaultTableRowsPerPageOptions, @@ -89,8 +94,14 @@ const configSlice = createSlice({ * @param state - The current state. * @param action - The payload action containing the config. */ - setConfig(state, action: PayloadAction<{ clusters: ConfigState['clusters'] }>) { + setConfig( + state, + action: PayloadAction<{ clusters: ConfigState['clusters']; filtersWarningsOnly?: boolean }> + ) { state.clusters = action.payload.clusters; + if (action.payload.filtersWarningsOnly !== undefined) { + state.filtersWarningsOnly = action.payload.filtersWarningsOnly; + } }, /** * Save the config. To both the store, and localStorage.