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

pkg/asset: remove asset stocks. store asset state in asset itself. #344

Merged
merged 3 commits into from
Oct 5, 2018
Merged

pkg/asset: remove asset stocks. store asset state in asset itself. #344

merged 3 commits into from
Oct 5, 2018

Conversation

staebler
Copy link
Contributor

@staebler staebler commented Sep 27, 2018

This improves the code surrounding accessing state for dependent assets. It reduces the amount of casting and de-serialization of state data.

Every asset is now associated with a unique type. The asset store retains at most a single instance of a given asset type.

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 27, 2018
@crawford
Copy link
Contributor

/hold

Waiting on CI to actually test this code.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 27, 2018
@crawford
Copy link
Contributor

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 28, 2018
@crawford
Copy link
Contributor

/test all

@wking
Copy link
Member

wking commented Sep 28, 2018

The router didn't come up in time:

Waiting for router to be created ...
NAME                          STATUS    ROLES       AGE       VERSION
ip-10-0-13-150.ec2.internal   Ready     master      1h        v1.11.0+d4cacc0
ip-10-0-14-104.ec2.internal   Ready     bootstrap   1h        v1.11.0+d4cacc0
ip-10-0-23-100.ec2.internal   Ready     master      1h        v1.11.0+d4cacc0
ip-10-0-39-16.ec2.internal    Ready     master      1h        v1.11.0+d4cacc0
Waiting for router to be created ...
Another process exited
2018/09/28 17:55:55 Container test in pod e2e-aws failed, exit code 1, reason Error

Sometimes that happens as a flake.

/retest

@abhinavdahiya
Copy link
Contributor

/approve

@abhinavdahiya
Copy link
Contributor

#344 (comment)

This might have been because the workers didn't come up. And the router is deployed on workers.

@crawford
Copy link
Contributor

@staebler Can you fix the format of your commit title and add a description to the body? It helps the reviewer understand why things are being changed and it helps our future selves remember why we made the change.

type Parents map[reflect.Type]*State

// Get gets the state of the specified asset.
func (p Parents) Get(asset Asset) (*State, bool) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is there a distinction between Asset and State? Is it possible for each asset to implement its own special logic and the Asset interface, allowing us to drop State? I had imagined this method would look as follows:

func (p Parents) Get(asset &Asset) { // this isn't quite right because Asset is an interface
  *asset, ok := p[reflect.TypeOf(asset)]
  if !ok {
    panic("Asset %s was requested, but was not available", asset.Name())
  }
}

We could then pass in the subset of assets that have been declared by each assets' Dependencies() method to ensure that every asset is properly declaring its dependencies.

@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
@yifan-gu
Copy link
Contributor

yifan-gu commented Oct 3, 2018

@staebler Any updates on this one? Trying to figure out how #374 and my asset deserializationwork will fit with this one.

@staebler
Copy link
Contributor Author

staebler commented Oct 3, 2018

@yifan-gu I am working through some minor bugs. I'll push up an update with its current rough state.

@staebler staebler changed the title Remove asset stocks WIP: Remove asset stocks Oct 3, 2018
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 3, 2018
@openshift-bot openshift-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 3, 2018
@staebler staebler changed the title WIP: Remove asset stocks pkg/asset: remove asset stocks. store asset state in asset itself Oct 4, 2018
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 4, 2018
@staebler staebler changed the title pkg/asset: remove asset stocks. store asset state in asset itself pkg/asset: remove asset stocks. store asset state in asset itself. Oct 4, 2018
@abhinavdahiya
Copy link
Contributor

@staebler is it possible to split 18e53d1 into smaller commits for ease of review we can squash them back before we merge? WDYT?

@staebler
Copy link
Contributor Author

staebler commented Oct 4, 2018

@staebler is it possible to split 18e53d1 into smaller commits for ease of review we can squash them back before we merge? WDYT?

@abhinavdahiya I can break into a commit per package, but they will not be atomic commits. Is that sufficient? It makes it more cumbersome to resolve merge conflicts when there are multiple commits .If it makes the review easier, then I'll do it.

@@ -0,0 +1,52 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
Copy link
Contributor

Choose a reason for hiding this comment

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

*.bazel no bazel files required. can you remove this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, this got left in accidentally in one of the merges. I will remove it.

@abhinavdahiya
Copy link
Contributor

@staebler this looks good, just some small not importants.
And discussion around why new interface WriteableAsset ?

@abhinavdahiya
Copy link
Contributor

abhinavdahiya commented Oct 4, 2018

And sorry for the rebase around #400 :(

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

@yifan-gu
Copy link
Contributor

yifan-gu commented Oct 4, 2018

@crawford Wanna take another look on this?

@openshift-bot openshift-bot 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 Oct 5, 2018
@abhinavdahiya
Copy link
Contributor

/approve

@openshift-bot openshift-bot 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 Oct 5, 2018
@abhinavdahiya
Copy link
Contributor

abhinavdahiya commented Oct 5, 2018

operator-framework/operator-lifecycle-manager#500
seems to have broken us previously.

/retest

// PersistToFile writes all of the files of the specified asset into the specified
// directory. If the asset is not a WritableAsset, then no files will be written.
func PersistToFile(asset Asset, directory string) error {
writableAsset, ok := asset.(WritableAsset)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just change the signature of PersistToFile? Targets shouldn't include non-writable assets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is fine, too. I'll make that change.

@crawford
Copy link
Contributor

crawford commented Oct 5, 2018

/approve

This looks fantastic!


asset := &persistAsset{}
expectedFiles := map[string][]byte{}
err = PersistToFile(asset, dir)
Copy link
Member

Choose a reason for hiding this comment

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

govet:

# github.com/openshift/installer/pkg/asset
pkg/asset/asset_test.go:45:21: cannot use asset (type *persistAsset) as type WritableAsset in argument to PersistToFile:
	*persistAsset does not implement WritableAsset (missing Files method)

@crawford
Copy link
Contributor

crawford commented Oct 5, 2018

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 5, 2018
This improves the code surrounding accessing state for dependent assets.
It reduces the amount of casting and de-serialization of state data.

Every asset is now associated with a unique type. The asset store retains
at most a single instance of a given asset type.
…asset state

Assets have been changed to store their state internally.
If PersistToFile only accepts WritableAsset instances, then
PersistToFile does not have to case to WritableAsset or deal
with assets that do not generate any files.
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Oct 5, 2018
@crawford
Copy link
Contributor

crawford commented Oct 5, 2018

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

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

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

The pull request process is described here

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

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

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.

8 participants