The Wayback Machine - https://web.archive.org/web/20260314090522/https://github.com/moby/moby/pull/36043
Skip to content

LCOW: Fix OpenFile parameters#36043

Merged
yongtang merged 1 commit intomoby:masterfrom
microsoft:jjh/fixopenfilecall
Jan 17, 2018
Merged

LCOW: Fix OpenFile parameters#36043
yongtang merged 1 commit intomoby:masterfrom
microsoft:jjh/fixopenfilecall

Conversation

@lowenna
Copy link
Member

@lowenna lowenna commented Jan 17, 2018

Signed-off-by: John Howard jhoward@microsoft.com

While debugging multiple LCOW issues, found that the OpenFile call in the remote fs was calling gcstools with the wrong parameters - path was omitted.

@darrenstahlmsft @gupta-ak @johnstep PTAL

Signed-off-by: John Howard <jhoward@microsoft.com>
@gupta-ak
Copy link
Contributor

LGTM

Copy link
Member

@johnstep johnstep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

t.b.h., the abstraction is a bit awkward here (i.e. RemotefsCmd being just "remotefs", OpenFileCmd being (surprise) "openfile"); also (and I know we don't have CI setup yet for LCOW), but perhaps we should have tests for this added (as a follow up)

@@ -33,7 +33,7 @@ func (l *lcowfs) OpenFile(path string, flag int, perm os.FileMode) (_ driver.Fil
flagStr := strconv.FormatInt(int64(flag), 10)
permStr := strconv.FormatUint(uint64(perm), 8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but wondering why all the conversion is done here, instead of just using the correct verbs in the fmt.Sprintf()? (%d for int, %o for octal (or %#o for octal with leading zero); https://play.golang.org/p/9H-rAAA5jaT

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defers to @gupta-ak ….

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I didn't think about that. All of the strconv stuff can be changed to use %d or %o in the fmt.Sprintf statement.

permStr := strconv.FormatUint(uint64(perm), 8)

commandLine := fmt.Sprintf("%s %s %s %s", remotefs.RemotefsCmd, remotefs.OpenFileCmd, flagStr, permStr)
commandLine := fmt.Sprintf("%s %s %s %s %s", remotefs.RemotefsCmd, remotefs.OpenFileCmd, path, flagStr, permStr)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we have validation of the arguments that were passed? (path not empty, flag not zero? (not sure what flag is without description), permStr being a valid value?

Also; perhaps we should change the fmt.Errorf("failed to open file pipes %s: %s", path, err) to use %q for the path, then it becomes more aparent if the value is empty

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defers largely to @gupta-ak, but the remote command will fail when executed with invalid parameters

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the remote command on the GCS side validates the parameters, so it will fail there.

@yongtang yongtang merged commit ef3988a into moby:master Jan 17, 2018
@lowenna lowenna deleted the jjh/fixopenfilecall branch January 18, 2018 17:28
@thaJeztah thaJeztah added the area/lcow Issues and PR's related to the experimental LCOW feature label Oct 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/lcow Issues and PR's related to the experimental LCOW feature kind/experimental platform/windows status/4-merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants