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.

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