Skip to content
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

stages/files: do not fail if links are correct #798

Merged
merged 4 commits into from Apr 24, 2019

Conversation

@ajeddeloh
Copy link
Contributor

ajeddeloh commented Apr 15, 2019

If a link already exists that matches the specified link, do not fail.

WIP needs tests, docs

@ajeddeloh ajeddeloh marked this pull request as ready for review Apr 17, 2019
@ajeddeloh

This comment has been minimized.

Copy link
Contributor Author

ajeddeloh commented Apr 17, 2019

Depends on #794

@ajeddeloh ajeddeloh force-pushed the ajeddeloh:link-state-sync branch 4 times, most recently from 276cba6 to 1809514 Apr 17, 2019
Copy link
Contributor

arithx left a comment

generally LGTM

@@ -45,6 +45,8 @@ func (s *stage) createFilesystemsEntries(config types.Config) error {

// filesystemEntry represent a thing that knows how to create itself.
type filesystemEntry interface {
// create creates the entry if specified. It assumes that if overwrite=true then any existing

This comment has been minimized.

Copy link
@arithx

arithx Apr 23, 2019

Contributor

Maybe drop the initial create

This comment has been minimized.

Copy link
@ajeddeloh

ajeddeloh Apr 23, 2019

Author Contributor

That's the golang comment style. <functionname> <verbs> <stuff>

return nil
}
}
return fmt.Errorf("error creating symlink %s: a non-symlink already exists that that path and overwrite is false", s.Path)

This comment has been minimized.

Copy link
@jlebon

jlebon Apr 23, 2019

Member

that that

if st.Mode()&os.ModeSymlink != 0 {
if target, err := os.Readlink(s.Path); err != nil {
return fmt.Errorf("error reading link at %s: %v", s.Path, err)
} else if filepath.Clean(target) != s.Target {

This comment has been minimized.

Copy link
@jlebon

jlebon Apr 23, 2019

Member

Sanity-check: is s.Target also already cleaned? Or should this be filepath.Clean(target) != filepath.Clean(s.Target)?

This comment has been minimized.

Copy link
@ajeddeloh

ajeddeloh Apr 23, 2019

Author Contributor

Thought it was, turns out it wasn't. Adding it here (and will PR with it to require clean paths for target).

@@ -81,7 +81,7 @@ The Ignition configuration is a JSON document conforming to the following specif
* **_name_** (string): the group name of the owner.
* **_links_** (list of objects): the list of links to be created. Every file, directory, and link must have a unique `path`.
* **path** (string): the absolute path to the link
* **_overwrite_** (boolean): whether to delete preexisting nodes at the path. Defaults to false.
* **_overwrite_** (boolean): whether to delete preexisting nodes at the path. Defaults to false. If overwrite is false and a matching link exists at the path, Ignition will only set the owner and group.

This comment has been minimized.

Copy link
@jlebon

jlebon Apr 23, 2019

Member

Minor: in files and directories, we finish the blurb with Defaults to false. Should probably be consistent here too.

@ajeddeloh ajeddeloh force-pushed the ajeddeloh:link-state-sync branch from 1809514 to d254703 Apr 23, 2019
@ajeddeloh

This comment has been minimized.

Copy link
Contributor Author

ajeddeloh commented Apr 23, 2019

Updated with fixes, except the go comment thing because that's the way golang wants it.

@jlebon
jlebon approved these changes Apr 24, 2019
@@ -81,7 +81,7 @@ The Ignition configuration is a JSON document conforming to the following specif
* **_name_** (string): the group name of the owner.
* **_links_** (list of objects): the list of links to be created. Every file, directory, and link must have a unique `path`.
* **path** (string): the absolute path to the link
* **_overwrite_** (boolean): whether to delete preexisting nodes at the path. Defaults to false.
* **_overwrite_** (boolean): whether to delete preexisting nodes at the path. If overwrite is false and a matching link exists at the path, Ignition will only set the owner and group. Defaults to false

This comment has been minimized.

Copy link
@jlebon

jlebon Apr 24, 2019

Member

Minor: missing final period here.

ajeddeloh added 4 commits Apr 15, 2019
If a link already exists that matches the specified link, do not fail.
Also refactor links to use u.SetPermissions and fix u.SetPermissions to
Lchown instead of Chown.
Add docs stating that Ignition will not fail (and instead just set
user/group) when overwrite is false and Ignition encounters a matching
link.
@ajeddeloh ajeddeloh force-pushed the ajeddeloh:link-state-sync branch from d254703 to ba9a9ba Apr 24, 2019
@ajeddeloh ajeddeloh merged commit 9212ea6 into coreos:master Apr 24, 2019
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.