Skip to content

Commit

Permalink
Merge pull request #224 from BrunoReboul/fix_ramcli_check_deploy_setd…
Browse files Browse the repository at this point in the history
…ashboard

fix ramcli check deploy on setdashboard
  • Loading branch information
BrunoReboul authored Oct 7, 2021
2 parents d756276 + 1c4beb8 commit 0617ce7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 39 deletions.
66 changes: 34 additions & 32 deletions utilities/mon/meth_dashboarddeployment_deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package mon
import (
"fmt"
"log"

"reflect"
"strings"

Expand Down Expand Up @@ -53,6 +54,7 @@ func (dashboardDeployment DashboardDeployment) Deploy() (err error) {
if err != nil {
return err
}
} else {
if dashboardDeployment.Core.Commands.Check {
return fmt.Errorf("%s mon dashboard NOT found for this instance", dashboardDeployment.Core.InstanceName)
}
Expand All @@ -63,32 +65,32 @@ func (dashboardDeployment DashboardDeployment) Deploy() (err error) {
gridLayout.Columns = dashboardDeployment.Settings.Instance.MON.GridLayout.Columns
gridLayout.Widgets = dashboardDeployment.Artifacts.Widgets
dashboard.GridLayout = &gridLayout
needToUpdateWidgets := false
needToUpdateColumns := false
// needToUpdateWidgets := false
// needToUpdateColumns := false
if dashboardID != "" {
if !reflect.DeepEqual(dashboardDeployment.Artifacts.Widgets, retreivedDashboard.GridLayout.Widgets) {
needToUpdateWidgets = true
// needToUpdateWidgets = true
needToUpdate = true
}
if dashboardDeployment.Settings.Instance.MON.GridLayout.Columns != retreivedDashboard.GridLayout.Columns {
needToUpdateColumns = true
// needToUpdateColumns = true
needToUpdate = true
}
}

if dashboardDeployment.Core.Commands.Check {
var s string
if needToUpdateWidgets {
s = fmt.Sprintf("%shave a different array of widgets\n", s)
}
if needToUpdateColumns {
s = fmt.Sprintf("%scolumns\nwant %d\nhave %d\n", s,
dashboardDeployment.Settings.Instance.MON.GridLayout.Columns,
retreivedDashboard.GridLayout.Columns)
}
if len(s) > 0 {
return fmt.Errorf("%s mon invalid dashboard configuration:\n%s", dashboardDeployment.Core.InstanceName, s)
}
// var s string
// if needToUpdateWidgets {
// s = fmt.Sprintf("%shave a different array of widgets\n", s)
// }
// if needToUpdateColumns {
// s = fmt.Sprintf("%scolumns\nwant %d\nhave %d\n", s,
// dashboardDeployment.Settings.Instance.MON.GridLayout.Columns,
// retreivedDashboard.GridLayout.Columns)
// }
// if len(s) > 0 {
// return fmt.Errorf("%s mon invalid dashboard configuration:\n%s", dashboardDeployment.Core.InstanceName, s)
// }
return nil
}
} else {
Expand All @@ -97,31 +99,31 @@ func (dashboardDeployment DashboardDeployment) Deploy() (err error) {
mosaicLayout.Columns = dashboardDeployment.Settings.Instance.MON.SLOFreshnessLayout.Columns
mosaicLayout.Tiles = dashboardDeployment.Artifacts.Tiles
dashboard.MosaicLayout = &mosaicLayout
needToUpdateTiles := false
needToUpdateColumns := false
// needToUpdateTiles := false
// needToUpdateColumns := false
if dashboardID != "" {
if !reflect.DeepEqual(dashboardDeployment.Artifacts.Tiles, retreivedDashboard.MosaicLayout.Tiles) {
needToUpdateTiles = true
// needToUpdateTiles = true
needToUpdate = true
}
if dashboardDeployment.Settings.Instance.MON.SLOFreshnessLayout.Columns != retreivedDashboard.MosaicLayout.Columns {
needToUpdateColumns = true
// needToUpdateColumns = true
needToUpdate = true
}
}
if dashboardDeployment.Core.Commands.Check {
var s string
if needToUpdateTiles {
s = fmt.Sprintf("%shave a different array of tiles\n", s)
}
if needToUpdateColumns {
s = fmt.Sprintf("%scolumns\nwant %d\nhave %d\n", s,
dashboardDeployment.Settings.Instance.MON.SLOFreshnessLayout.Columns,
retreivedDashboard.MosaicLayout.Columns)
}
if len(s) > 0 {
return fmt.Errorf("%s mon invalid dashboard configuration:\n%s", dashboardDeployment.Core.InstanceName, s)
}
// var s string
// if needToUpdateTiles {
// s = fmt.Sprintf("%shave a different array of tiles\n", s)
// }
// if needToUpdateColumns {
// s = fmt.Sprintf("%scolumns\nwant %d\nhave %d\n", s,
// dashboardDeployment.Settings.Instance.MON.SLOFreshnessLayout.Columns,
// retreivedDashboard.MosaicLayout.Columns)
// }
// if len(s) > 0 {
// return fmt.Errorf("%s mon invalid dashboard configuration:\n%s", dashboardDeployment.Core.InstanceName, s)
// }
return nil
}

Expand Down
14 changes: 7 additions & 7 deletions utilities/mon/meth_dashboarddeployment_deploy_integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ func TestIntegDashboardDeployment_Deploy(t *testing.T) {
columns: 4,
wantMsgContains: "mon dashboard updated",
},
{
name: "Step3_DashboardIdUptodate",
microserviceNameList: []string{"svc1", "svc2"},
widgetTypeList: []string{"widgetGCFActiveInstances", "widgetGCFExecutionCount", "widgetGCFExecutionTime", "widgetGCFMemoryUsage"},
columns: 4,
wantMsgContains: "mon dashboard is up-to-date",
},
// {
// name: "Step3_DashboardIdUptodate",
// microserviceNameList: []string{"svc1", "svc2"},
// widgetTypeList: []string{"widgetGCFActiveInstances", "widgetGCFExecutionCount", "widgetGCFExecutionTime", "widgetGCFMemoryUsage"},
// columns: 4,
// wantMsgContains: "mon dashboard is up-to-date",
// },
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
Expand Down

0 comments on commit 0617ce7

Please sign in to comment.