Skip to content

Conversation

@staebler
Copy link
Contributor

This adds tests around creating the targeted assets. The tests validate the following.

  1. An asset that is generated and then fetched again from a new store has equivalent state.
  2. A targeted asset restored from the state file and from on-disk has equivalent state.

This PR also includes a few changes to the assets to get the tests passing.

Fixes https://jira.coreos.com/browse/CORS-940

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 13, 2018
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 13, 2018
@staebler
Copy link
Contributor Author

staebler commented Dec 13, 2018

This PR include the changes in #877 as well.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 21, 2018
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 11, 2019
@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 14, 2019
Copy link
Contributor

Choose a reason for hiding this comment

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

what is this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a link to that directory. TestCreatedAssetsAreNotDirty needs it to be able to generate the manifest templates.

@openshift-ci-robot openshift-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Jan 22, 2019
Copy link
Member

@wking wking Jan 30, 2019

Choose a reason for hiding this comment

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

Why gut this method instead of removing it completely? Can't we get away with just Files() for use in (*Manifests).Generate(...) and turn *DNS from a WritableAsset into an Asset? Maybe we want to split interfaces:

// WritableAsset is an Asset that has files that can be written to disk.
type WritableAsset interface {
  Asset

  // Files returns the files to write.
  Files() []*File
}

// ReadWriteableAsset is a WriteableAsset that can be loaded from disk.
type ReadWritableAsset interface {
  WriteableAsset

  // Load returns the on-disk asset if it exists.
  // The asset object should be changed only when it's loaded successfully.
  Load(FileFetcher) (found bool, err error)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had those separate interfaces when I wrote the asset store originally. I'll have to dig back into past PRs to refresh my memory about who had what objections to that approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would like to pass on making any change along these lines for this PR. I agree with you that it is ugly to have asset with Load functions that do nothing. However, the problem is more widespread than just these manifest assets. I think that changes that we make to remove unused Load functions are worthy of their own PR.

@wking
Copy link
Member

wking commented Jan 30, 2019

meta: Can we pull out the SVG rebuilds to a single commit at the end of the series? That would make it easier to read the commit history for human-generated changes.

@wking
Copy link
Member

wking commented Jan 30, 2019

I've left a few minor nits inline, but I'm also fine landing this as-is and addressing those in follow-up work. I skimmed over the tests and a7ebfaa very quickly, but while it would be nice to go over those more carefully, I'm also fine with "the tests are green, if anything slipped through we can fix it up later" ;). Everything the commit messages said made sense to me.

@staebler
Copy link
Contributor Author

meta: Can we pull out the SVG rebuilds to a single commit at the end of the series? That would make it easier to read the commit history for human-generated changes.

Done.

@staebler
Copy link
Contributor Author

This looks like it could be squashed down into 5dc9d18.

Done.

@wking
Copy link
Member

wking commented Jan 30, 2019

/lgtm
/retest

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2019
@wking
Copy link
Member

wking commented Jan 31, 2019

e2e-aws:

level=info msg="Waiting up to 10m0s for the openshift-console route to be created..."
level=fatal msg="waiting for openshift-console URL: context deadline exceeded"

/tetest

@wking
Copy link
Member

wking commented Jan 31, 2019

/tetest

Sigh.

/retest

The Common Templates asset is not truly an asset. It does not own any
on-disk files, and no other assets depend upon it. The problem with
the Common Templates asset is that it writes files to disk as a targeted
asset but then does not load any assets back in. So a test that verifies
that the loaded-in asset matches the written asset fails.

Changes for https://jira.coreos.com/browse/CORS-940
Tests are being created that use the asset store implementation to
validate restoring assets from the state file and disk. The tests are
much easier when they have access to the private fields of the asset
store. Rather than exposing more public fields and methods on the store,
the tests will be placed in the same package as the store. Unfortunately,
this creates cyclic imports between the base asset package and the
various packages containing the targeted assets. To rectify this,
the concrete asset store implementation has been moved to a new
pkg/asset/store package.

Changes for https://jira.coreos.com/browse/CORS-940
This adds tests around creating the targeted assets. The tests validate
the following.

1) An asset that is generated and then fetched again from a new store
has equivalent state.
2) A targeted asset restored from the state file and from on-disk has
equivalent state.

To keep from duplicating the code defining the assets including in the
targets, the definitions have been moved to pkg/asset/targets/targets.go.

Fixes https://jira.coreos.com/browse/CORS-940
The files lists in the manifests assets need to be sorted to ensure that
the assets are equivalent when read from the state file and from on disk.

Changes for https://jira.coreos.com/browse/CORS-940
The Common Templates asset was removed so the dependency graph needed to be updated.

Generated with:

$ openshift-install graph | dot -Tsvg >docs/design/resource_dep.svg

using:

$ dot -V
dot - graphviz version 2.40.1 (20161225.0304)
@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 1, 2019
@staebler
Copy link
Contributor Author

staebler commented Feb 4, 2019

@wking CI is green once again on this. Can you reapply your lgtm?

@wking
Copy link
Member

wking commented Feb 4, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 4, 2019
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: staebler, wking

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:

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 da6d45b into openshift:master Feb 4, 2019
wking added a commit to wking/openshift-installer that referenced this pull request Feb 5, 2019
Through da6d45b (Merge pull request openshift#890 from
staebler/asset_loading_tests, 2019-02-04).

Background for the networking.type validation entry is in this thread
[1].

The OpenStack HAProxy entry has wording based on [2] and Russell's
out-of-band suggestions.

Forwarding static-pod longs to systemd is still in flight with [3].

[1]: openshift#1013 (comment)
[2]: https://github.com/openshift/installer/pull/1185/files#r253714521
[3]: openshift/cluster-bootstrap#11
wking added a commit to wking/openshift-installer that referenced this pull request Feb 5, 2019
Through da6d45b (Merge pull request openshift#890 from
staebler/asset_loading_tests, 2019-02-04).

Background for the networking.type validation entry is in this thread
[1].

The OpenStack HAProxy entry has wording based on [2] and Russell's
out-of-band suggestions.

Forwarding static-pod longs to systemd is still in flight with [3].

[1]: openshift#1013 (comment)
[2]: https://github.com/openshift/installer/pull/1185/files#r253714521
[3]: openshift/cluster-bootstrap#11
wking added a commit to wking/openshift-installer that referenced this pull request Feb 6, 2019
Otherwise Terraform failures will lead to exits without metadata.json,
which makes it harder for users to reap any resources from the
possibly-partially-created cluster.  Before this commit:

  $ git diff -U1 | cat
  diff --git a/pkg/terraform/terraform.go b/pkg/terraform/terraform.go
  index f566d34..bad05e5 100644
  --- a/pkg/terraform/terraform.go
  +++ b/pkg/terraform/terraform.go
  @@ -53,2 +53,3 @@ func Apply(dir string, platform string, extraArgs ...string) (path string, err e

  +				return sf, errors.New("faking a Terraform failure")
   				if exitCode := texec.Apply(dir, args, lpDebug, lpError); exitCode != 0 {
  $ hack/build.sh
  $ openshift-install --dir=wking create cluster
  INFO Consuming "Install Config" from target directory
  INFO Creating cluster...
  ERROR Failed to read tfstate: open /tmp/openshift-install-655768368/terraform.tfstate: no such file or directory
  FATAL failed to fetch Cluster: failed to generate asset "Cluster": failed to create cluster: faking a Terraform failure
  $ ls wking
  auth  terraform.tfvars  tls

With this commit, we get metadata.json too.  Fixes a bug introduced by
the re-order in 75ab106 (assets: add tests for validating asset
fetching of targets, 2018-12-12, openshift#890, v0.12.0).
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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants