Skip to content

Conversation

@wking
Copy link
Member

@wking wking commented Oct 19, 2018

Avoid:

$ bin/openshift-install cluster
FATAL Error executing openshift-install: open tests/smoke/vendor/github.com/prometheus/procfs/fixtures/26231/fd/0: no such file or directory

as the old implementation attempts to walk the whole directory and hits:

$ ls -l tests/smoke/vendor/github.com/prometheus/procfs/fixtures/26231/fd/
total 0
lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 0 -> ../../symlinktargets/abc
lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 1 -> ../../symlinktargets/def
lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 10 -> ../../symlinktargets/xyz
lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 2 -> ../../symlinktargets/ghi
lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 3 -> ../../symlinktargets/uvw

With this commit, we only load files from the disk when someone asks for them.

closes #494

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Oct 19, 2018
@wking wking force-pushed the load-assets-on-demand branch from 29bad4e to 1301358 Compare October 19, 2018 16:57
Avoid:

  $ bin/openshift-install cluster
  FATAL Error executing openshift-install: open tests/smoke/vendor/github.com/prometheus/procfs/fixtures/26231/fd/0: no such file or directory

as the old implementation attempts to walk the whole directory and
hits:

  $ ls -l tests/smoke/vendor/github.com/prometheus/procfs/fixtures/26231/fd/
  total 0
  lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 0 -> ../../symlinktargets/abc
  lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 1 -> ../../symlinktargets/def
  lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 10 -> ../../symlinktargets/xyz
  lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 2 -> ../../symlinktargets/ghi
  lrwxrwxrwx. 1 trking trking 24 Oct  5 01:26 3 -> ../../symlinktargets/uvw

With this commit, we only load files from the disk when someone asks
for them.

I've adjusted the unit tests a bit because:

* ioutil.ReadFile returns errors like:

    read /: is a directory

  for directories.  There does not appear to be an analog to
  os.IsNotExist() for this condition, so instead of checking for it in
  the tests, I've just dropped the empty-string input cases.  If we
  break something and call FetchByName on an empty string, we want to
  error out, and that error message is appropriately descriptive
  already.

* Globs are not as precise as regular expressions, so our glob would
  match master-1x.ign and similar which the previous regexp excluded.
  But loading a few extra files doesn't seem like that big a deal, and
  folks adding files with names like that seems unlikely.
@wking wking force-pushed the load-assets-on-demand branch from 1301358 to edcd705 Compare October 19, 2018 18:31
@wking
Copy link
Member Author

wking commented Oct 19, 2018

I've pushed 1301358 -> edcd705 updating the unit tests to keep up.

// Load returns the master ignitions from disk.
func (a *Master) Load(f asset.FileFetcher) (found bool, err error) {
fileList := f.FetchByPattern(regexp.MustCompile(`^(master-(0|([1-9]\d*))\.ign)$`))
fileList, err := f.FetchByPattern("master-[0-9]*.ign")
Copy link
Contributor

Choose a reason for hiding this comment

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

There was a discussion that this matches more than we need, e.g. it matches master-0a.ign, but I guess that's fine.

Copy link
Member Author

@wking wking Oct 19, 2018

Choose a reason for hiding this comment

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

There was a discussion that this matches more than we need, e.g. it matches master-0a.ign...

Yeah, I waved my hands around that at the end of the edcd705 commit message ;).

Copy link
Contributor

@yifan-gu yifan-gu left a comment

Choose a reason for hiding this comment

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

/approve

@abhinavdahiya
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 19, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, wking, yifan-gu

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [abhinavdahiya,wking,yifan-gu]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit dfa3481 into openshift:master Oct 19, 2018
@wking wking deleted the load-assets-on-demand branch October 19, 2018 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants