Unverified Commit 480981a3 authored by Daivik Dave's avatar Daivik Dave Committed by GitHub
Browse files

removed global log from pkg/dashboard/store (#3143)


* removed global log from pkg/dashboard/store
Signed-off-by: default avatarDaivik <daivikdave229@gmail.com>

* Add logger to pkg/dashboard/store
Signed-off-by: default avatarDaivik <daivikdave229@gmail.com>

* chore: update changelog #2880
Signed-off-by: default avatarDaivik <daivikdave229@gmail.com>
Co-authored-by: default avatarSTRRL <im@strrl.dev>
Co-authored-by: default avatarTi Chi Robot <ti-community-prow-bot@tidb.io>
parent ef467d4b
Showing with 44 additions and 13 deletions
+44 -13
......@@ -27,6 +27,7 @@ For more information and how-to, see [RFC: Keep A Changelog](https://github.com/
- Bump chaos-tproxy to v0.4.6 [#3272](https://github.com/chaos-mesh/chaos-mesh/pull/3272)
- Helm charts: using 0.0.0 as version and appVersion [#3311](https://github.com/chaos-mesh/chaos-mesh/pull/3311)
- Add a comment to the flag size of memory stress in the dashboard [#3359](https://github.com/chaos-mesh/chaos-mesh/pull/3359)
- Refine logging in pkg/dashboard/store, removed global the log [#3143] (https://github.com/chaos-mesh/chaos-mesh/pull/3143)
### Deprecated
......
......@@ -89,7 +89,7 @@ func main() {
func() (context.Context, *config.ChaosDashboardConfig, *ttlcontroller.TTLConfig) {
return controllerRuntimeSignalHandlerContext, dashboardConfig, persistTTLConfigParsed
},
store.NewDBStore,
store.Bootstrap,
collector.Bootstrap,
ttlcontroller.Bootstrap,
),
......
// Copyright 2021 Chaos Mesh Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
package store
import (
"github.com/go-logr/logr"
"github.com/jinzhu/gorm"
"go.uber.org/fx"
config "github.com/chaos-mesh/chaos-mesh/pkg/config/dashboard"
)
func Bootstrap(lc fx.Lifecycle, conf *config.ChaosDashboardConfig, logger logr.Logger) (*gorm.DB, error) {
return NewDBStore(lc, conf, logger.WithName("dashboard-store"))
}
......@@ -18,9 +18,9 @@ package store
import (
"context"
"github.com/go-logr/logr"
"github.com/jinzhu/gorm"
"go.uber.org/fx"
ctrl "sigs.k8s.io/controller-runtime"
controllermetrics "sigs.k8s.io/controller-runtime/pkg/metrics"
config "github.com/chaos-mesh/chaos-mesh/pkg/config/dashboard"
......@@ -46,11 +46,10 @@ var (
fx.Invoke(schedule.DeleteIncompleteSchedules),
)
sqliteDriver = "sqlite3"
log = ctrl.Log.WithName("store").WithName("dbstore")
)
// NewDBStore returns a new gorm.DB
func NewDBStore(lc fx.Lifecycle, conf *config.ChaosDashboardConfig) (*gorm.DB, error) {
func NewDBStore(lc fx.Lifecycle, conf *config.ChaosDashboardConfig, logger logr.Logger) (*gorm.DB, error) {
ds := conf.Database.Datasource
// fix error `database is locked`, refer to https://github.com/mattn/go-sqlite3/blob/master/README.md#faq
......@@ -60,8 +59,7 @@ func NewDBStore(lc fx.Lifecycle, conf *config.ChaosDashboardConfig) (*gorm.DB, e
gormDB, err := gorm.Open(conf.Database.Driver, ds)
if err != nil {
log.Error(err, "Failed to open DB: ", "driver => ", conf.Database.Driver)
logger.Error(err, "Failed to open DB: ", "driver => ", conf.Database.Driver)
return nil, err
}
......
......@@ -14,16 +14,19 @@
* limitations under the License.
*
*/
import { Typography } from '@mui/material'
import { Form, Formik, getIn } from 'formik'
import { LabelField, Submit, TextField } from 'components/FormField'
import { useEffect, useState } from 'react'
import MoreOptions from 'components/MoreOptions'
import Space from '@ui/mui-extends/esm/Space'
import { Typography } from '@mui/material'
import typesData from '../data/types'
import { useStoreSelector } from 'store'
import { LabelField, Submit, TextField } from 'components/FormField'
import MoreOptions from 'components/MoreOptions'
import typesData from '../data/types'
const validate = (values: any) => {
let errors = {}
......@@ -100,9 +103,10 @@ const Stress: React.FC<StressProps> = ({ onSubmit }) => {
error={getIn(errors, 'stressors.memory.workers') ? true : false}
inputProps={{ min: 0 }}
/>
<TextField name="stressors.memory.size"
label="Size"
helperText="Memory size specifies the memory size to be occupied or a percentage of the total memory size"
<TextField
name="stressors.memory.size"
label="Size"
helperText="Memory size specifies the memory size to be occupied or a percentage of the total memory size"
/>
<LabelField
name="stressors.memory.options"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment