Commit Graph

178 Commits

Author SHA1 Message Date
nikhiljindal
08d9e244f7 Removing some references to v1beta1 from test code 2015-04-08 17:28:06 -07:00
Tim Hockin
8ae203825b Implement multi-port endpoints
Instead of endpoints being a flat list, it is now a list of "subsets"
where each is a struct of {Addresses, Ports}.  To generate the list of
endpoints you need to take union of the Cartesian products of the
subsets.  This is compact in the vast majority of cases, yet still
represents named ports and corner cases (e.g. each pod has a different
port number).

This also stores subsets in a deterministic order (sorted by hash) to
avoid spurious updates and comparison problems.

This is a fully compatible change - old objects and clients will
keepworking as long as they don't need the new functionality.

This is the prep for multi-port Services, which will add API to produce
endpoints in this new structure.
2015-03-27 12:36:32 -07:00
Prashanth Balasubramanian
b0068d05f8 Add the ability to watch fields of an rc 2015-03-26 11:01:56 -07:00
Clayton Coleman
65425f690c Move field errors to pkg/util/fielderrors
Allows pkg/api to take a reference to labels.Selector and fields.Selector
2015-03-22 17:43:34 -04:00
Clayton Coleman
428d2263e5 Graceful deletion of resources
This commit adds support to core resources to enable deferred deletion
of resources.  Clients may optionally specify a time period after which
resources must be deleted via an object sent with their DELETE. That
object may define an optional grace period in seconds, or allow the
default "preferred" value for a resource to be used. Once the object
is marked as pending deletion, the deletionTimestamp field will be set
and an etcd TTL will be in place.

Clients should assume resources that have deletionTimestamp set will
be deleted at some point in the future.  Other changes will come later
to enable graceful deletion on a per resource basis.
2015-03-19 15:33:32 -04:00
Clayton Coleman
bddef32193 Prepare EtcdHelper to extract more data from Node
In order to support graceful deletion, the resource object will
need access to the TTL value in etcd.  Also, in the future we
may want to get the creation index (distinct from modifiedindex)
and expose it to clients.  Change EtcdResourceVersioner to be
more type specific (objects vs lists) and provide a default
implementation that relies on the internal API convention.

Also, rename etcd_tools.go to etcd_helper.go and split a few
things up.
2015-03-16 15:33:50 -04:00
Clayton Coleman
4ca90e0343 FakeEtcdClient should return KeyNotFound on Delete 2015-03-16 14:22:03 -04:00
Clayton Coleman
143015025a Support TTL in genericetcd#Update 2015-03-16 14:22:01 -04:00
Dawn Chen
34e9c82c70 Convert RestartPolicy to string for v1beta3.
Fixed #3607 and spiritually support #5475
2015-03-13 18:38:07 -07:00
Mike Danese
438052c453 fix variable shadowing bug in etcd_tools.go 2015-03-05 22:34:28 -08:00
Daniel Smith
4e7bccab02 Merge pull request #4991 from fabioy/etcdcheck-fix
Fix the etcd version check and have it return the version string.
2015-03-04 14:55:49 -08:00
Daniel Smith
4cd59e629a Merge pull request #5010 from smarterclayton/update_resource_version
genericetcd.Etcd should test resourceVersion
2015-03-04 14:49:05 -08:00
Mike Danese
4f6e09d854 add tests to pkg/tools/etcd_tools_test.go 2015-03-04 10:38:42 -08:00
Mike Danese
e1ca63f569 SetObj and CreateObj optionally accept an object to fill with the result of the get 2015-03-04 10:38:42 -08:00
Fabio Yeon
c38c6f0dad Fix the etcd version check and have it return the version string. 2015-03-03 16:59:00 -08:00
Clayton Coleman
3d52aac13c genericetcd.Etcd should test resourceVersion
Also fix that Update was returning AlreadyExists instead of
NotFound (when create is disabled) and that Update when CreateOnUpdate
was true was not populating the returned object.

Added more tests
2015-03-03 19:54:43 -05:00
Daniel Smith
650f6cb826 Revert "Multi-port Endpoints" 2015-02-23 13:53:21 -08:00
Tim Hockin
160f288832 Implement multi-port Endpoints
This is a part of multi-port services.
2015-02-22 09:35:12 -08:00
Tim Hockin
ae0062d001 Part 2 of plural ports: make endpoints a struct
Includes conversions for v1b[12] and tests and fixups for call sites.
2015-02-18 19:54:15 -08:00
Clayton Coleman
23d199ded9 Make generic etcd more powerful and return operations from etcd
When we complete an operation, etcd usually provides a response
object.  Return that object up instead of querying etcd twice.
2015-02-13 13:11:33 -05:00
Yu-Ju Hong
6813683ee2 Allow AtomicUpdate() to surface the error when the key doesn't exist
In some cases, when the key doesn't exist, AtomicUpdate should simply fail and
surface the error. This change adds a new function parameter "ignoreNotFound"
for this purpose.
2015-02-11 21:56:28 -08:00
saadali
a41f520bf0 Add "Update Event" to Kubernetes API 2015-02-05 00:07:51 -08:00
Yu-Ju Hong
4a72addaeb Factor out API defaulting from validation logic
Currently, the validation logic validates fields in an object and supply default
values wherever applies. This change factors out defaulting to a set of
defaulting callback functions for decoding (see #1502 for more discussion).

 * This change is based on pull request 2587.

 * Most defaulting has been migrated to defaults.go where the defaulting
   functions are added.

 * validation_test.go and converter_test.go have been adapted to not testing the
   default values.

 * Fixed all tests with that create invalid objects with the absence of
   defaulting logic.
2015-02-03 00:55:42 -08:00
Deyuan Deng
d30da9a812 List objects in deterministic order 2015-01-27 09:29:40 -05:00
Clayton Coleman
ce36431954 WatchList should not convey events for the root key
It's possible to watch /foo/bar, get events for /foo/bar/baz,
and then if someone deletes /foo/bar you'll get an event for /foo/bar
without a value.  This results in an error being printed in the logs
because /foo/bar has value "" and we can't decode that.

This commit excludes the parent directory from watch events for now.
2015-01-15 16:00:49 -05:00
Clayton Coleman
880ecef6fe Move locks on watch to allow testing blocking 2015-01-07 14:38:38 -05:00
Mike Danese
a98faa1f62 fixed bug in tools.NewEtcdClientStartServerIfNecessary 2014-12-03 12:58:03 -08:00
Sam Ghods
6399854240 Remove unused YAML tags and GetYAML/SetYAML methods
Unneeded after move to ghodss/yaml.
2014-12-02 16:25:28 -08:00
Tim Hockin
ff8c5f9415 Add a Detail field to Validation Error 2014-11-24 17:28:42 -08:00
Tim Hockin
ea960711ff Clean up error logs.
Use %v for errors, tidy some messages, make error messages start lowe-case
(as per go guidelines).  Just accumulated nits.
2014-11-21 09:45:26 +08:00
Clayton Coleman
6d31c2bf8a util.EncodeJSON proven harmful, remove it everywhere
People were misusing EncodeJSON in tests when they should be using
runtime.EncodeOrDie(testapi.Codec(), obj).  Removing the potential
for cutting self on sharp objects.
2014-11-13 10:38:13 -05:00
Daniel Smith
178d0af795 Fix watch for events; add test for interface implementation so it won't break again. 2014-11-12 15:22:08 -08:00
Dawn Chen
30fcf24131 Merge pull request #2121 from brendandburns/standalone
Create a standalone k8s binary, capable of running a full cluster
2014-11-10 22:04:28 -08:00
Brendan Burns
2c1221864d Make a standalone binary. 2014-11-10 13:34:11 -08:00
Brendan Burns
d7dc20fd6a Add etcd to the list of services to validate.
Also add minions.
2014-11-05 21:22:01 -08:00
Brendan Burns
cf4fd8753f Fix a missing lock in the fake etcd client. 2014-10-31 21:36:03 -07:00
Daniel Smith
94e736e286 Merge pull request #2009 from smarterclayton/unify_meta
Unify Accessor for ObjectMeta/TypeMeta/ListMeta
2014-10-29 09:58:46 -07:00
Vojtech Vitek (V-Teq)
90809c270d Use conversion.EnforcePtr() where appropriate
Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
2014-10-28 16:36:09 +01:00
Clayton Coleman
66ace4c270 Begin to unify ResourceVersioner and SelfLinker
Create a new MetadataAccessor interface that combines both
and use it where previously latest.ResourceVersioner and SelfLinker
were being used.

Adds Namespace to the get/set interface. Adds TODO about future
fast path for metadata (as per thockin's comment)
2014-10-27 16:00:55 -04:00
Clayton Coleman
644eb70085 Refactor tests to split ObjectMeta from TypeMeta 2014-10-24 11:22:21 -04:00
Daniel Smith
e46af6e37f Merge pull request #1969 from smarterclayton/new_typemeta
Allow Meta lookup to work across ObjectType and ListMeta
2014-10-23 15:29:57 -07:00
Clayton Coleman
3a89883223 EtcdHelper.decodeList was not properly returning errors 2014-10-23 16:48:16 -04:00
Clayton Coleman
1ccb86c760 Rename methods in api/meta to be cleaner 2014-10-22 22:59:12 -04:00
Clayton Coleman
64d98cba73 Move typemeta.go to api/meta/meta.go
Prepares for the meta object to front multiple underlying types
when TypeMeta and ObjectMeta is split in internal and v1beta3, but
combined in v1beta1 and v1beta2
2014-10-22 22:28:06 -04:00
Clayton Coleman
bb77a5d15f Rename ID -> Name 2014-10-22 15:00:26 -04:00
derekwaynecarr
085ca40291 Enforce unique constraint at namespace boundary in etcd, make client and server namespace aware 2014-10-16 13:02:52 -04:00
derekwaynecarr
b63974bd21 Extract list must flatten nodes across directories 2014-10-16 13:02:52 -04:00
Daniel Smith
9a9362e896 Add generic registry object so we can stop rewriting this code 2014-10-10 15:46:49 -07:00
Eric Tune
800284164a Fix format specifiers in Printf-type functions. 2014-10-09 17:06:32 -07:00
Clayton Coleman
82bcdd3b3b Make ResourceVersion a string internally instead of uint64
Allows us to define different watch versioning regimes in the future
as well as to encode information with the resource version.

This changes /watch/resources?resourceVersion=3 to start the watch at
4 instead of 3, which means clients can read a resource version and
then send it back to the server. Clients should no longer do math on
resource versions.
2014-10-07 19:00:26 -04:00
Clayton Coleman
d3e51a0f24 Rename JSONBase -> TypeMeta in preparation for v1beta3
Will make subsequent refactor much easier
2014-10-07 11:12:16 -04:00
Daniel Smith
4d4ebcd38e Add ttl parameter to CreateObj 2014-09-25 12:08:14 -07:00
Daniel Smith
3ea383d073 Make ExtractToList, deprecate ExtractList. 2014-09-25 12:07:16 -07:00
Daniel Smith
265f889260 convert etcd errors to watch errors 2014-09-22 17:06:03 -07:00
Daniel Smith
0d69393a43 make watch actually return an error when there's an error 2014-09-19 17:53:55 -07:00
Clayton Coleman
61e3ce7ddc Make runtime less global for Codec
* Make Codec separate from Scheme
* Move EncodeOrDie off Scheme to take a Codec
* Make Copy work without a Codec
* Create a "latest" package that imports all versions and
  sets global defaults for "most recent encoding"
  * v1beta1 is the current "latest", v1beta2 exists
  * Kill DefaultCodec, replace it with "latest.Codec"
  * This updates the client and etcd to store the latest known version
* EmbeddedObject is per schema and per package now
* Move runtime.DefaultScheme to api.Scheme
* Split out WatchEvent since it's not an API object today, treat it
like a special object in api
* Kill DefaultResourceVersioner, instead place it on "latest" (as the
  package that understands all packages)
* Move objDiff to runtime.ObjectDiff
2014-09-16 16:26:43 -04:00
Clayton Coleman
154a91cd33 Rename runtime.DefaultScheme to latest.Codec for ease of readability 2014-09-16 16:19:35 -04:00
Clayton Coleman
fe614aeda2 Simple refactor for ease of readability
runtime.DefaultCodec -> latest.Codec
2014-09-16 16:12:35 -04:00
Daniel Smith
fc09f988b4 Make tests pass again 2014-09-07 22:26:42 -07:00
Daniel Smith
0d30a656ef Do interface{} -> runtime.Object rename everywhere 2014-09-07 22:19:24 -07:00
Daniel Smith
1c2b65788d Rename Codec and ResourceVersioner to add Default in front, to allow for types of those names 2014-09-07 22:19:24 -07:00
Daniel Smith
7790961011 Rename Object to EmbeddedObject 2014-09-05 14:43:35 -07:00
Daniel Smith
a63966e73c Combine pkg/apitools and pkg/api/common and call the result pkg/runtime 2014-09-02 11:15:44 -07:00
Daniel Smith
099c8fd36f Propagate rename; tests pass again. 2014-09-02 10:42:06 -07:00
Vojtech Vitek (V-Teq)
59f58cd043 Unify Godoc formatting, fix various typos
Signed-off-by: Vojtech Vitek (V-Teq) <vvitek@redhat.com>
2014-09-02 13:41:03 +02:00
Joe Beda
2d8e160775 Merge pull request #1117 from lavalamp/fixApi
Invert api and api/v1beta1 dependencies
2014-08-29 14:59:15 -07:00
Daniel Smith
aa9b9b9fa8 Invert api and api/v1beta1 dependencies
This is some cleanup that has been needed for a while.
There's still one more step that could usefully be done, which is to
split up our api package into the part that provides the helper
functions and the part that provides the internal types. That can come
later.

The v1beta1 package is now a good example of what an api plugin should
do to version its types.
2014-08-29 12:15:30 -07:00
Clayton Coleman
bafc422ac0 Add the resource version to api.*List items from etcd
Allows clients to watch more easily (can invoke Get, then
Watch).
2014-08-28 23:17:00 -04:00
Clayton Coleman
083d81b6d7 Expose REST resource for endpoints and watch on services/endpoints
Will allow kube-proxies to listen on endpoints.
2014-08-27 15:49:01 -04:00
Brendan Burns
d83091ea52 Fix a flake by extending the time out, so we don't race a go routine.
Empirically this eliminates a flake.
2014-08-26 17:09:38 -07:00
Daniel Smith
6b69ed402b Change 'sendCreate' to 'sendAdd'; integration passes. 2014-08-25 15:56:55 -07:00
Daniel Smith
db1c0db5c7 Move etcd watch code to its own files 2014-08-25 15:56:54 -07:00
Daniel Smith
72b35816cd Need to remove pods that change labels. 2014-08-25 15:56:54 -07:00
Tim Hockin
0f97a73c1b Rename a bunch of "Make" functions to "New"
Also rename some to other names that make better reading.  There are still a
bunch of "make" functions but they do things like assemble a string from parts
or build an array of things.  It seemed that "make" there seemed fine.  "New"
is for "constructors".
2014-08-20 21:27:19 -07:00
Daniel Smith
daab393562 Merge pull request #780 from brendandburns/native
Add a utility for doing master election via etcd.
2014-08-15 11:48:13 -07:00
Brendan Burns
a17acd30ee Add a utility for doing master election via etcd. 2014-08-15 11:42:16 -07:00
brendandburns
39d2020392 Merge pull request #897 from smarterclayton/watch_starting_too_early
Watch should start from next index when getting the initial state
2014-08-15 09:46:13 -07:00
Clayton Coleman
befbf8466f Only write to etcd if values have changed
This prevents certain loops from writing data to etcd every few
seconds (when data hasn't changed).
2014-08-14 20:34:36 -04:00
Clayton Coleman
7c67cbff04 Watch should start from next index when getting the initial state
Also, the fake response we return should have an Action that is
appropriate for the operation.
2014-08-14 20:32:46 -04:00
brendandburns
8daf8c7a30 Merge pull request #896 from smarterclayton/return_correct_index_for_delete
Delete should use current node, not prev node index
2014-08-14 14:59:52 -07:00
Eric Tune
7de0df0be8 Remove unreachable code. 2014-08-14 13:56:42 -07:00
Clayton Coleman
2872e565a2 Delete should use current node, not prev node index
The index an object was deleted on should be resp.Node.ModifiedIndex
2014-08-14 16:14:24 -04:00
Kelsey Hightower
c21a0ca39f Breakup the registry package into separate packages.
Currently all registry implementations live in a single package,
which makes it bit harder to maintain. The different registry
implementations do not follow the same coding style and naming
conventions, which makes the code harder to read.

Breakup the registry package into smaller packages based on
the registry implementation. Refactor the registry packages
to follow a similar coding style and naming convention.

This patch does not introduce any changes in behavior.
2014-08-11 20:58:09 -07:00
brendandburns
3222f61bca Merge pull request #557 from lavalamp/podLocation
Prepare for external scheduler
2014-08-11 15:27:24 -07:00
Daniel Smith
5e34a9784f Merge pull request #852 from smarterclayton/deliver_state_on_nil_version
Watch delivers current state for resourceVersion=0
2014-08-11 15:13:15 -07:00
Dan Mace
b986c520a7 Apply resource versioning to list extractions from etcd
Set the resource version on lists of objects extracted from etcd to prevent
them from always being interpreted as new during updates.
2014-08-11 21:11:08 +00:00
Clayton Coleman
c5630a9567 Watch delivers current state for resourceVersion=0
Allows clients to get the current state without having to execute
a get followed by a watch.  Makes integration with action loops
much cleaner.
2014-08-11 17:07:14 -04:00
Daniel Smith
b7752a86d4 Add debugging info printing to etcd fake
And make tests pass again.
2014-08-11 13:09:24 -07:00
Daniel Smith
49cded3800 Simplify ResourceWatcher interface to one function. 2014-08-08 14:09:13 -07:00
Daniel Smith
283fdba6ab Add more parameters to Watch
* Add labels selector (same as List)
* Add fields selector
 * Plan to let you select pods by Host and/or Status
* Add resourceVersion to let you resume a watch where you left off.
2014-08-08 14:09:13 -07:00
Clayton Coleman
67dbd15929 Address remaining comments from #756
Rename Encoding to Codec, Versioning to ResourceVersioner.  Add
GoDoc.  Add Delete(key, recursive) to EtcdHelper
2014-08-06 11:25:35 -04:00
Kouhei Ueno
c1ec1d6d72 Remove duplicated def of IsEtcdNodeExist 2014-08-06 03:45:50 +09:00
Kouhei Ueno
c7947abd9c Revert "Revert "Use atomic create in EtcdHelper.AtomicUpdate""
This reverts commit 73b64aa490.
2014-08-06 03:43:19 +09:00
Daniel Smith
73b64aa490 Revert "Use atomic create in EtcdHelper.AtomicUpdate" 2014-08-05 11:34:00 -07:00
Daniel Smith
51872d65c9 Merge pull request #694 from nyaxt/atomicetcd
Use atomic create in EtcdHelper.AtomicUpdate
2014-08-05 11:19:22 -07:00
Daniel Smith
5ff072030c Merge pull request #746 from smarterclayton/atomic_create
Make create atomic for etcd on Services/ReplControllers
2014-08-05 11:08:55 -07:00
Kouhei Ueno
dea1b8c48b Remove 10ms timeout from TestWatch 2014-08-06 01:02:58 +09:00
Kouhei Ueno
cf117d5b48 Add test for EtcdHelper.AtomicUpdate concurrent create 2014-08-06 00:30:55 +09:00
Kouhei Ueno
4799b546c9 Make fake_etcd_client threadsafe 2014-08-05 23:37:32 +09:00
Kouhei Ueno
3f9ec452e4 use atomic create in EtcdHelper.AtomicUpdate 2014-08-05 23:37:32 +09:00