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

Decouple configs from cluster #53

Merged
merged 28 commits into from
Jul 1, 2019
Merged

Decouple configs from cluster #53

merged 28 commits into from
Jul 1, 2019

Conversation

varl
Copy link
Contributor

@varl varl commented May 23, 2019

Creates a new Cache for d2-cluster based on the global cache.

Would be nice to pair with https://github.com/dhis2/cli-helpers-engine/pull/15/files to remove the layered cache directory.

Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

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

This is cool! I'm not sure if we want to go all the way to implementing a generic key-value store, but if we don't (yet) this is a great solution.

I don't think the multi-tiered Caches are required, which would make this even simpler!

packages/cluster/src/common.js Outdated Show resolved Hide resolved
@varl
Copy link
Contributor Author

varl commented May 27, 2019

Rebased on master, variation on the multi-layered Cache.

Produces this structure:

tree ~/.cache/d2/ -L 4
/home/varl/.cache/d2/
└── cache
    ├── cluster
    │   ├── dev
    │   │   ├── config.json
    │   │   └── docker-compose
    │   └── master
    │       ├── config.json
    │       └── docker-compose
    ├── cluster-db-dev.sql.gz
    └── cluster-db-master.sql.gz

edit: updated with simpler paths.

Depends on dhis2/cli-helpers-engine#16

@varl
Copy link
Contributor Author

varl commented May 27, 2019

varl@veronika:~/dev/dhis2/libs/cli$ ./packages/main/bin/d2 debug cache list
┌──────────────────────────┬──────────┬─────────────────────┐
│ Name                     │ Size     │ Modified            │
├──────────────────────────┼──────────┼─────────────────────┤
│ cluster                  │ 512      │ 2019-05-27 17:50:36 │
├──────────────────────────┼──────────┼─────────────────────┤
│ cluster-db-dev.sql.gz    │ 98904634 │ 2019-05-27 17:50:42 │
├──────────────────────────┼──────────┼─────────────────────┤
│ cluster-db-master.sql.gz │ 165532   │ 2019-05-27 17:50:20 │
└──────────────────────────┴──────────┴─────────────────────┘

varl@veronika:~/dev/dhis2/libs/cli$ ./packages/main/bin/d2 debug cache list cluster
┌───────────────────┬──────┬─────────────────────┐
│ Name              │ Size │ Modified            │
├───────────────────┼──────┼─────────────────────┤
│ dev               │ 512  │ 2019-05-27 17:50:37 │
├───────────────────┼──────┼─────────────────────┤
│ master            │ 512  │ 2019-05-27 17:44:02 │
└───────────────────┴──────┴─────────────────────┘

varl@veronika:~/dev/dhis2/libs/cli$ ./packages/main/bin/d2 debug cache list cluster/dev/docker-compose
┌────────────────────┬──────┬─────────────────────┐
│ Name               │ Size │ Modified            │
├────────────────────┼──────┼─────────────────────┤
│ config             │ 512  │ 2019-05-27 19:01:22 │
├────────────────────┼──────┼─────────────────────┤
│ docker-compose.yml │ 918  │ 2019-05-23 09:53:06 │
├────────────────────┼──────┼─────────────────────┤
│ README.md          │ 3641 │ 2019-05-23 09:53:06 │
├────────────────────┼──────┼─────────────────────┤
│ scripts            │ 512  │ 2019-05-27 19:01:22 │
└────────────────────┴──────┴─────────────────────┘

I think I'll rename the d2-cluster-dev to just dev since it's already subdired.

edit: updated.

@varl varl marked this pull request as ready for review May 30, 2019 09:39
packages/cluster/src/common.js Outdated Show resolved Hide resolved
packages/cluster/src/common.js Outdated Show resolved Hide resolved
@varl
Copy link
Contributor Author

varl commented May 30, 2019

Updated dhis2/cli-helpers-engine#16 with a read/write implementation for the cache, and could simplify this PR as a result.

The cached configuration reading/writing is handled after the runtime configuration has been resolved. Only a subset of the configuration object is cached for subsequent runs.

@varl
Copy link
Contributor Author

varl commented Jun 5, 2019

@amcgee I think this is ready for review and testing without using links.

@varl varl force-pushed the decouple-configs-from-cluster branch 2 times, most recently from 046590e to 5e42b86 Compare June 6, 2019 13:02
@amcgee
Copy link
Member

amcgee commented Jun 12, 2019

@varl looks like there's been a bunch of activity since you said this was ready for review, are you still iterating on it?

@varl
Copy link
Contributor Author

varl commented Jun 12, 2019

@amcgee No, I just rebased on master to bring it up to date. Looks like there's another conflict so I'll do it once more. 😇

@varl varl force-pushed the decouple-configs-from-cluster branch from 3f849e8 to 2d6209c Compare June 17, 2019 06:35
@varl
Copy link
Contributor Author

varl commented Jun 17, 2019

Rebased on master so incorporates #61.

@varl
Copy link
Contributor Author

varl commented Jun 17, 2019

@amcgee This is ready for review.

Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

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

Looking good! Made a few comments

packages/cluster/src/commands/up.js Outdated Show resolved Hide resolved
packages/cluster/src/common.js Outdated Show resolved Hide resolved
packages/cluster/src/common.js Outdated Show resolved Hide resolved
packages/cluster/src/commands/status.js Outdated Show resolved Hide resolved
@varl
Copy link
Contributor Author

varl commented Jun 18, 2019

@amcgee changed the code with regards to your comments.

Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

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

@varl made some few minor comments, will test and approve

packages/cluster/src/commands/seed.js Show resolved Hide resolved
packages/cluster/src/db.js Outdated Show resolved Hide resolved
const cacheLocation = await initDockerComposeCache({
composeProjectName: name,
Copy link
Member

Choose a reason for hiding this comment

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

Should this also be makeComposeProject(name) or the parameter just called name? Otherwise maybe initDockerComposeCache::composeProjectName is a bit misleading...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I've considered that too.

The main reason I want name here is to make the cache a lot easier to browse: d2 debug cache list clusters/dev/docker-compose

If we use makeComposeProject: d2 debug cache list clusters/d2-cluster-dev/docker-compose

Since all the compose projects are already namespaced to clusters/{name} I don't think it makes sense to prefix it again with d2-cluster-{name}.

It's still the cache directory for the compose project, so the function name names sense (initDockerComposeCache), it's just the argument that is slightly misleading. I can rename it to composeCacheName if that makes it clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@amcgee Alternatively initDockerComposeCache::cacheDirName?

Copy link
Member

Choose a reason for hiding this comment

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

We can rename this later but I think name might even be fine

Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

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

Testing and looks good but found one undefined variable!

packages/cluster/src/common.js Outdated Show resolved Hide resolved
Copy link
Member

@amcgee amcgee left a comment

Choose a reason for hiding this comment

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

Nice work @varl!! Tested and approved, sorry it took so much back-and-forth

@varl
Copy link
Contributor Author

varl commented Jul 1, 2019

No worries, the PR is not that big but the implications of it are huge so good to be thorough!

@varl varl merged commit e5b40af into master Jul 1, 2019
@varl varl deleted the decouple-configs-from-cluster branch July 1, 2019 12:34
dhis2-bot pushed a commit that referenced this pull request Jul 1, 2019
# [1.3.0](v1.2.4...v1.3.0) (2019-07-01)

### Features

* decouple configs from cluster ([#53](#53)) ([e5b40af](e5b40af))
@dhis2-bot
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

3 participants