Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

fleetd: support operators in metadata #1632

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

dongsupark
Copy link
Contributor

@dongsupark dongsupark commented Jul 13, 2016

This PR allows users to define metadata in units, such as "ram=1024". Precisely we can define the operator in the [X-Fleet] section in a unit as below:

[X-Fleet]
MachineMetadata=ram>=1024

Supported operators are "<=", ">=", "!=", "==", "<", ">".

This PR also contains more checks in fleetctl, more test cases in unit tests, and a new functional test.

Originally written by @wuqixuan.
Fixes #1143
Supersedes #1294

wuqixuan and others added 5 commits July 13, 2016 16:32
If define metadata in fleet conf, such as "ram=1024", we can
define the operator in [X-Fleet] unit as below:
[X-Fleet]
MachineMetadata=ram>=2048
The operators have been supported: "<=", ">=", "!=", "<", ">", "="
If the operatior are "<=", ">=", "!=", "<", ">", the value should
be integer, otherwise, the unit will never be launched.

Fixes coreos#1143
To follow the maintainer's suggestion, also support the operator "==",
which is actually the same as "=".
TestHasMetadata should also test more cases for metadata operators.
fleetctl list-machines should distinguish normal metadata from metadata
with operators, to print out human-readable messages.
TestMetadataOperator ensures that metadata operators work also for
extended operators such as ">=", "<=", "<", ">", "!=", or "==".
First make the test machine have "ram=1024" in its machine metadata.
Then in TestMetadataOperator, check each possible operator one after
another, to make sure that each works without error.
@dongsupark dongsupark force-pushed the dongsu/fleetd-metadata-operators branch from 7e765fe to 68028c7 Compare July 14, 2016 11:39
@dongsupark
Copy link
Contributor Author

Updated the functional test TestMetadataOperator.

  • Now the test checks not only success cases, but also failure cases.
  • Fixed a broken unit generation code in runMetaOp().
  • Fixed a wrong cleanup command, from "fleetctl stop" to "fleetctl destroy".
  • Removed unnecessary template index in the sample unit file metadata-op.service.

@dongsupark dongsupark force-pushed the master branch 3 times, most recently from 150d30c to 4002bf5 Compare August 16, 2016 08:54
@dongsupark dongsupark force-pushed the master branch 7 times, most recently from 3b60e93 to 875d938 Compare August 23, 2016 11:00
@dongsupark dongsupark force-pushed the master branch 2 times, most recently from bdc94e8 to fa5aa3a Compare August 30, 2016 12:26
@dongsupark dongsupark force-pushed the master branch 2 times, most recently from 20a3e96 to 3aaa1ab Compare November 10, 2016 15:24
@dongsupark dongsupark force-pushed the master branch 2 times, most recently from eb6872f to 365565e Compare November 24, 2016 15:35
@dongsupark dongsupark force-pushed the master branch 6 times, most recently from 39a99ba to 44591b0 Compare December 15, 2016 19:48
@dongsupark dongsupark force-pushed the master branch 3 times, most recently from 0132632 to 6974811 Compare February 8, 2017 10:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants