-
Notifications
You must be signed in to change notification settings - Fork 31
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
LVM module #184
LVM module #184
Conversation
suggestions how to make LVM related code testable also welcomed |
} | ||
} | ||
return "", fmt.Errorf("too many symlinks for %s", dev) | ||
} |
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.
Could we use filepath.EvalSymlinks
here?
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.
definelly yes
Could we consider using |
ced335a
to
8768f24
Compare
1911304
to
af116b9
Compare
please make sure your example has a check for the pvs, etc. commands or it will fail |
Errors are not clear during a failure. You are logging tasks in INFO but it is not clear why this is failing:
|
} | ||
|
||
lvm.fs "mnt-me" { | ||
device = "/dev/mapper/mantl-test" |
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.
this should be /dev/mapper/lv-test
We really need to throw a lot of errors at it and make sure it is providing helpful feedback. |
Are pvs created automatically? I think it would be helpful to separate that out as a module
Not really clear what is happening here. Is the lv being created or the vg?
|
@avnik You have failing tests - please take a look and make appropriate changes. Thanks! |
@@ -0,0 +1,18 @@ | |||
lvm.vg "mantl" { |
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.
Please remove "mantl" in all places and replace with "test" or something else.
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.
done (also reoved from history)
@@ -0,0 +1,18 @@ | |||
lvm.vg "mantl" { | |||
name = "mantl" | |||
devices = [ "/dev/sdb" ] |
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.
can you change this to a parameter so users can provide the value; you could set "/dev/sdb" as default.
) | ||
|
||
type ResourceFS struct { | ||
mount *Mount |
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.
mount, lvm, etc. should be capitalized since the struct is exported
device, err := render.Render("device", p.Device) | ||
if err != nil { | ||
return nil, err | ||
} |
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.
This is no longer necessary and is handled for you. You can simply set "What" to p.device in Mount, etc.
group, err := render.Render("group", p.Group) | ||
if err != nil { | ||
return nil, err | ||
} |
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.
These checks are now done for you; just use the value of p.Group, etc.
func (*OsExec) Run(prog string, args []string) error { | ||
log.WithField("module", "lvm").Infof("Executing %s: %v", prog, args) | ||
e := exec.Command(prog, args...).Run() | ||
if e == 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.
Probably only need the err != nil case here.
"testing" | ||
) | ||
|
||
func TestExecRun(t *testing.T) { |
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.
It might be easier to follow if you have one Test[FuncName], and then use t.Run to test the different cases of success and failure resulting in error. Using t.Run is what we are trying to do now, so updating throughout is probably a good idea.
) | ||
|
||
type ResourceLV struct { | ||
group string |
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.
group, name, etc. should be capitalized since this struct is exported.
status := &Status{} | ||
ok, err := r.checkVG() | ||
if err != nil { | ||
return nil, err |
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.
Probably a good idea to wrap the errors with "check", "apply", etc. to give the user more information.
|
||
pvs, err := r.lvm.QueryPhysicalVolumes() | ||
if err != nil { | ||
return nil, err |
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.
Wrapping errors here in check and apply would be helpful for the user.
5ecc8c0
to
092c008
Compare
CodeClimate aggroing on then
Also move init() to preparer.go as in all other resources
coverage: 98.2% of statements
0b02675
to
19c98dc
Compare
This is straight rewrite of mantl-storage-setup.py (at the moment)
Architecture caveats:
1 we need to install lvm tools, and start lvm-metad service before we start
and we can't issue install requirement in lvm module.
2 we need to express all LVM structure in single hcl expression, otherwise we
can't plan/check VG/LV part, until PV/VG part commited.
Possible future ways:
Funny go language issues:
we can
exec.Command(name, args...)
but not `exec.Command(name, arg, more_args...)``So let discuss it