Skip to content

Conversation

@yifan-gu
Copy link
Contributor

@yifan-gu yifan-gu commented Sep 28, 2018

Fix https://jira.coreos.com/browse/CORS-847

  • Add Load() to Asset interface that returns files of the asset.
  • Make all assets implement the Load() function to read files from disk.

@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 Sep 28, 2018
Copy link
Contributor

Choose a reason for hiding this comment

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

i think this can move out of this if ?

Copy link
Contributor

Choose a reason for hiding this comment

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

can the load provide basic read/stat on files. So each asset doesn't have to remember to prefix dir

Copy link
Contributor Author

Choose a reason for hiding this comment

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

what do you mean? assets are not remembering dir, that's why the dir is passed in.

Copy link
Member

Choose a reason for hiding this comment

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

assets are not remembering dir, that's why the dir is passed in.

I think @abhinavdahiya's suggesting we handle the file open and read in centralized code, and then pass the data down into the individual assets. I agree that this is a good way to go. Basically, what we're doing here is reversing the looped PersistToFile. How about making that a Store.Save(dir) method, and adding a new Store.Load(dir) to reverse? The difficulty would be that the Store would need a way to discover filenames used by the asset. I'd rather make that public instead. Maybe with a Filenames() []string method here on Asset? Then Store.Load goes through the required assets, calls their Filenames(), reads those files, and pushes the read map[string][]bytes (filename -> content) into Asset.Load to get turned into a *State. In the other hand, once you've loaded the content from disk by filename, you've pretty much got a State instance already. Maybe all we need from Asset is Asset.Filenames()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@wking Going to take care of the state of the whole store in the next PR. This one is only going to handle reading individual assets from the disk, the reason is that when run openshift-install <target> only the assets in the <target> are written to the disk, the state of other assets will be stored in a hidden state file.
That's why we also want individual asset to have a Load() function. The implementation of the Load() is centralized in the state.go, only the master-ignition and network-config are special because they will only look for some specific files under a dir.

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @crawford @staebler this might have to change as generate might drop returning state?

Copy link
Contributor

Choose a reason for hiding this comment

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

ioutil.ReadDir()

@yifan-gu yifan-gu force-pushed the load_assets branch 2 times, most recently from 8fdca37 to 5d11dc3 Compare September 29, 2018 00:03
@wking
Copy link
Member

wking commented Sep 29, 2018

e2e:

time="2018-09-29T00:05:22Z" level=fatal msg="failed to generate asset: unexpected error when loading asset \"Master Ignition Config(s)\": failed to read dir \"/tmp/artifacts/installer\": open /tmp/artifacts/installer: no such file or directory"

Copy link
Member

@wking wking left a comment

Choose a reason for hiding this comment

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

How does this interact with #344? I haven't wrapped my head around that one well enough to know.

Copy link
Member

Choose a reason for hiding this comment

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

assets are not remembering dir, that's why the dir is passed in.

I think @abhinavdahiya's suggesting we handle the file open and read in centralized code, and then pass the data down into the individual assets. I agree that this is a good way to go. Basically, what we're doing here is reversing the looped PersistToFile. How about making that a Store.Save(dir) method, and adding a new Store.Load(dir) to reverse? The difficulty would be that the Store would need a way to discover filenames used by the asset. I'd rather make that public instead. Maybe with a Filenames() []string method here on Asset? Then Store.Load goes through the required assets, calls their Filenames(), reads those files, and pushes the read map[string][]bytes (filename -> content) into Asset.Load to get turned into a *State. In the other hand, once you've loaded the content from disk by filename, you've pretty much got a State instance already. Maybe all we need from Asset is Asset.Filenames()?

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 30, 2018
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 1, 2018
@yifan-gu
Copy link
Contributor Author

yifan-gu commented Oct 1, 2018

/test e2e-aws

@yifan-gu
Copy link
Contributor Author

yifan-gu commented Oct 1, 2018

How does this interact with #344? I haven't wrapped my head around that one well enough to know.

@wking I looked at the #344, it seems the biggest change is that tls asets are split from two types (certkey, keypair) to a number of types to match all assets. So basically we will add Load() function to all those new asset types, and in the Load(), we will call the LoadFromFile()

@yifan-gu
Copy link
Contributor Author

yifan-gu commented Oct 1, 2018

ok, let me try something different than Load(dir string)

@openshift-bot openshift-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 2, 2018
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 2, 2018
@yifan-gu
Copy link
Contributor Author

yifan-gu commented Oct 2, 2018

@abhinavdahiya @wking @rajatchopra Updated, ptal.

@yifan-gu yifan-gu force-pushed the load_assets branch 2 times, most recently from 220be45 to 1390176 Compare October 2, 2018 19:02
@yifan-gu
Copy link
Contributor Author

yifan-gu commented Oct 2, 2018

/retest

Copy link
Contributor

Choose a reason for hiding this comment

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

/s/will/should ?

Copy link
Contributor

Choose a reason for hiding this comment

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

IsAssetInState

Copy link
Contributor

Choose a reason for hiding this comment

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

you can return dirty, <error>

Copy link
Contributor

Choose a reason for hiding this comment

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

you can return dirty, <error>

Copy link
Contributor

Choose a reason for hiding this comment

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

you can return dirty, <error>

Copy link
Contributor

Choose a reason for hiding this comment

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

you can return dirty, <error>

Yifan Gu added 2 commits October 18, 2018 16:52
- Add Loadable interface to load assets from disk.
- Load on-disk assets in Fetch() and use it to overwrite the state
  file.
- Add FileFetcher interface to help reading the files from disk.
Implement Load() for all loadable assets to read files from disk
and generate the in-memory asset.
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 18, 2018
@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 18, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinavdahiya, crawford, 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,crawford,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
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 38fb38e into openshift:master Oct 19, 2018
@deads2k
Copy link
Contributor

deads2k commented Oct 19, 2018

I run with libvirt and after this pull merged I see

[deads@deads-02 installer]$ 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

resetting to bf0fa6d gives me a working binary

@deads2k
Copy link
Contributor

deads2k commented Oct 19, 2018

@yifan-gu @abhinavdahiya fyi

@stevekuznetsov how do I make a revert of this multicommit pull locally?

@sttts
Copy link
Contributor

sttts commented Oct 23, 2018

After this PR /var/opt/tectonic/auth/kubeconfig on the bootstrap node stopped working against the local kube-apiserver. Moreover, I see plenty of the following messages in the kube-apiserver logs:

I1023 13:03:11.355477       5 logs.go:49] http: TLS handshake error from 127.0.0.1:36586: remote error: tls: bad certificate

@sttts
Copy link
Contributor

sttts commented Oct 23, 2018

Before this PR, apiserver.crt (the kube-apiserver serving cert) was signed by kube-ca. So the kube-ca cert was enough to validate apiserver.crt.

@staebler
Copy link
Contributor

@sttts Isn't the second CA output the root CA, not the apiserver CA?

Subject: OU=openshift, CN=root-ca

@sttts
Copy link
Contributor

sttts commented Oct 23, 2018

Yep, copied the wrong piece. Recreating a cluster to get the right one.

wking added a commit to wking/openshift-installer that referenced this pull request Oct 24, 2018
Avoiding:

  $ openshift-install --dir=wking create install-config
  $ emacs	wking/install-config.yaml
  $ openshift-install --dir=wking create manifests
  FATAL Error executing openshift-install: remove install-config.yml: no such file or directory

Fixing a bug from 116dd64 (pkg/asset: Load on-disk files in Fetch(),
2018-10-18, openshift#374).
@sttts
Copy link
Contributor

sttts commented Oct 25, 2018

To close the discussion: the issue was #522, i.e. the installer picking up state from the working dir leading to a cert mismatch.

@stevekuznetsov
Copy link
Contributor

@stevekuznetsov how do I make a revert of this multicommit pull locally?

@deads2k are you asking how to revert this merge?

Find the merge commit SHA and

git revert $MERGE_SHA -m 1

Is that what you need?

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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.