-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat]Curveadm: add debug mode #303
Conversation
Hi @Songjf-ttk, do you think is it more convenient to add a e.g. curveadm format --debug
curveadm deploy --debug |
Yes, I think so. I will modify my code as soon as possible. @Wine93 |
cli/command/deploy.go
Outdated
@@ -111,6 +111,7 @@ type deployOptions struct { | |||
insecure bool | |||
poolset string | |||
poolsetDiskType string | |||
debugDeploy bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe debug
is more clearly.
cli/command/format.go
Outdated
filename string | ||
showStatus bool | ||
stopFormat bool | ||
debugFormat bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
cli/command/deploy.go
Outdated
@@ -238,6 +241,7 @@ func genDeployPlaybook(curveadm *cli.CurveAdm, | |||
} else if step == CREATE_LOGICAL_POOL { | |||
options[comm.KEY_CREATE_POOL_TYPE] = comm.POOL_TYPE_LOGICAL | |||
} | |||
options[comm.DEBUG_MODE] = debugDeploy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sugesstion:
options := map[string]interface{}{
comm.DEBUG_MODE: debug,
}
if step == CREATE_PHYSICAL_POOL {
// do something
}
...
cli/command/format.go
Outdated
showStatus := options.showStatus | ||
stopFormat := options.stopFormat | ||
debugFormat := options.debugFormat | ||
if showStatus && stopFormat { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you can do this in PreRunE
phase, see:
curveadm/cli/command/deploy.go
Line 139 in 956c953
PreRunE: func(cmd *cobra.Command, args []string) error { |
internal/task/task/bs/format.go
Outdated
debugmode := curveadm.MemStorage().Get(comm.DEBUG_MODE).(bool) | ||
if debugmode { | ||
glg.Get().SetLevel(glg.DEBG) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to adjust the log level here. the log level should be determined by the configuration file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two ways to implement debug mode. The first is to directly modify curveadm.cfg and read the log level through the configuration file. The second method is to configure the debug mode through the command line, such as :
curveadm format --debug
curveadm deploy --debug
After communicating with @Wine93 this time, I chose this solution. This Solution set the debug mode in the command line, which may conflict with the log level in curveadm.cfg, so it is necessary to modify the log level.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two ways to implement debug mode. The first is to directly modify curveadm.cfg and read the log level through the configuration file. The second method is to configure the debug mode through the command line, such as :
curveadm format --debug curveadm deploy --debugAfter communicating with @Wine93 this time, I chose this solution. This Solution set the debug mode in the command line, which may conflict with the log level in curveadm.cfg, so it is necessary to modify the log level.
yep, maybe you can provide a function for curveadm to set log level.
if debugmode { | ||
glg.Get().SetLevel(glg.DEBG) | ||
return nil, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto.
@@ -279,6 +280,7 @@ func NewCreateContainerTask(curveadm *cli.CurveAdm, dc *topology.DeployConfig) ( | |||
Init: true, | |||
Name: hostname, | |||
Privileged: true, | |||
Remove: !debugmode, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is a problem, the service container exit but don't delete it forever util delete it manually.
cli/command/format.go
Outdated
@@ -133,6 +170,11 @@ func runFormat(curveadm *cli.CurveAdm, options formatOptions) error { | |||
var err error | |||
var fcs []*configure.FormatConfig | |||
diskRecords := curveadm.DiskRecords() | |||
debugmode := options.debug |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicate with line 128?
debug := options.debug
debugmode := options.debug
@Songjf-ttk look at the other comments. |
a96ce9e
to
57a1505
Compare
@Songjf-ttk |
5c0b62e
to
bec09a1
Compare
8a96cd6
to
6e53f2d
Compare
|
@Songjf-ttk please squash to one commit. |
cli/command/format.go
Outdated
showStatus bool | ||
stopFormat bool | ||
debug bool | ||
cleanFormat bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean instead of cleanFormat is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clean instead of cleanFormat is better?
Agree!
cli/command/format.go
Outdated
@@ -82,6 +122,8 @@ func NewFormatCommand(curveadm *cli.CurveAdm) *cobra.Command { | |||
flags.StringVarP(&options.filename, "formatting", "f", "format.yaml", "Specify the configure file for formatting chunkfile pool") | |||
flags.BoolVar(&options.showStatus, "status", false, "Show formatting status") | |||
flags.BoolVar(&options.stopFormat, "stop", false, "Stop formatting progress") | |||
flags.BoolVar(&options.debug, "debug", false, "Debug formatting progress") | |||
flags.BoolVar(&options.cleanFormat, "clean", false, "Clean the Container") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cli/command/format.go
Outdated
showStatus := options.showStatus | ||
stopFormat := options.stopFormat | ||
debug := options.debug | ||
cleanFormat := options.cleanFormat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
cli/command/format.go
Outdated
FORMAT_CHUNKFILE_POOL = playbook.FORMAT_CHUNKFILE_POOL | ||
GET_FORMAT_STATUS = playbook.GET_FORMAT_STATUS | ||
STOP_FORMAT = playbook.STOP_FORMAT | ||
CLEAN_FORMAT = playbook.CLEAN_FORMAT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete it if not used.
Signed-off-by: sjf <[email protected]>
lgtm. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Related to #252.
Solution: Add a debug option to the configuration file curvedm.cfg.
Test:
The container was not automatically deleted when an error occurred