Commit Graph

934 Commits

Author SHA1 Message Date
Clayton Coleman
b03fbf90f8 Make RESTClient more generic to API version, simplify version handling
RESTClient is an abstraction on top of arbitrary HTTP endpoints that
follow the Kubernetes API conventions. Refactored RESTClientFor so that
assumptions that are Kube specific happen outside of that method (so
others can reuse the RESTClient). Added more validation to client.New
to ensure clients give good input. Exposed APIVersion on RESTClient
as a method so that wrapper code (code that adds typed / structured
methods over rest endpoints like client.Client) can more easily make
decisions about what APIVersion it is running under.
2015-01-07 18:03:34 -05:00
derekwaynecarr
abb6632d75 Do not use namespace in url paths pre v1beta3 from client 2014-12-19 16:32:42 -05:00
derekwaynecarr
7cf664439f Move namespace from query param to path part 2014-12-16 15:55:47 -05:00
Brian Grant
9b539262a8 Count only non-dead pods in replicationController current state replicas count. 2014-12-12 22:23:14 +00:00
markturansky
8159c8fd25 Refactor PodCondition to PodPhase 2014-11-21 15:28:38 -05:00
Tim Hockin
95a9098311 fix 'go vet' warnings 2014-11-21 09:45:28 +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
markturansky
8af4ccb111 v1beta3 Pod refactor 2014-11-18 09:25:42 -05: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
0348a67413 Merge pull request #2195 from smarterclayton/prepare_pod_template_v1beta3
Allow an internal pod template reference or object
2014-11-12 10:55:08 -08:00
Clayton Coleman
8a59000472 Warn if pod has no labels 2014-11-11 17:03:20 -05:00
Clayton Coleman
94c873e7a4 Remaining refactor for PodTemplateSpec and fixing test cases 2014-11-11 17:03:20 -05:00
Brendan Burns
2c1221864d Make a standalone binary. 2014-11-10 13:34:11 -08:00
markturansky
119f654a13 Refactor PodStatus to PodCondition in internal API for v1beta3 2014-11-05 17:26:47 -05:00
Deyuan Deng
acf9d23b32 Stop httptest server. 2014-10-30 21:37:08 -04:00
Tim Hockin
37ffb41b81 Merge pull request #1830 from markturansky/label_validation
add RFC952 validation to labels
2014-10-27 09:54:18 -07:00
markturansky
e2365b1f96 add RFC952 label validation 2014-10-24 16:01:52 -04:00
derekwaynecarr
c6eb371c93 Fixup unit tests 2014-10-24 11:49:04 -04:00
derekwaynecarr
580cb5ea4f Rework client.Interface 2014-10-24 11:47:30 -04:00
Clayton Coleman
644eb70085 Refactor tests to split ObjectMeta from TypeMeta 2014-10-24 11:22:21 -04:00
Clayton Coleman
1ffc82dfe6 createPod should copy the labels, not edit them in place 2014-10-24 11:22:21 -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
Daniel Smith
d34914517f Shorten 'CodecForVersionOrDie' name, add 'ResourceVersioner' to testapi 2014-10-13 14:58:06 -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
derekwaynecarr
d5ec260db8 Fixup tests 2014-10-02 12:52:01 -04:00
derekwaynecarr
fc67d822c6 Add context as parameter to client interface functions 2014-10-02 12:51:36 -04:00
Clayton Coleman
ff2eca97d9 Refactor the client (again) to better support auth
* Allows consumers to provide their own transports for common cases.
* Supports KUBE_API_VERSION on test cases for controlling which
  api version they test against
* Provides a common flag registration method for CLIs that need
  to connect to an API server (to avoid duplicating flags)
* Ensures errors are properly returned by the server
* Add a Context field to client.Config
2014-10-01 15:23:37 -04:00
derekwaynecarr
02e1a2e79d Update unit tests to pass a context on client create 2014-09-30 14:27:56 -04:00
Clayton Coleman
4e56dafecc Introduce some default log verbosity control
Move a lot of common error logging into better buckets:

glog.Errorf() - Always an error
glog.Warningf() - Something unexpected, but probably not an error
glog.V(0) - Generally useful for this to ALWAYS be visible
            to an operator
            * Programmer errors
            * Logging extra info about a panic
            * CLI argument handling
glog.V(1) - A reasonable default log level if you don't want
            verbosity
            * Information about config (listening on X, watching Y)
            * Errors that repeat frequently that relate to conditions
              that can be corrected (pod detected as unhealthy)
glog.V(2) - Useful steady state information about the service
            * Logging HTTP requests and their exit code
            * System state changing (killing pod)
            * Controller state change events (starting pods)
            * Scheduler log messages
glog.V(3) - Extended information about changes
            * More info about system state changes
glog.V(4) - Debug level verbosity (for now)
            * Logging in particularly thorny parts of code where
              you may want to come back later and check it
2014-09-25 16:30:14 -04:00
Clayton Coleman
5483333e29 Allow server and client to take api version as argument
* Defaults to v1beta1
* apiserver takes -storage_version which controls etcd storage version
  and the version of the client used to connect to other apiservers
* Changed signature of client.New to add version parameter
* All controller code and component code prefers the oldest (most common)
  server version
2014-09-18 23:27:28 -04: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
48ce23ac91 Make client use pointers 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
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
Clayton Coleman
818f357128 Client should validate the incoming host value
Convert host:port and URLs passed to client.New() into the proper
values, and return an error if the value is invalid.  Change CLI
to return an error if -master is invalid.  Remove Client.rawRequest
which was not in use, and fix the involved tests. Add NewOrDie

Preserves the behavior of the client to not auth when a non-https
URL is passed (although in the future this should be corrected).
2014-08-28 13:47:36 -04: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
f689d44d25 Add comment for clarity and logging for debugging. 2014-08-18 17:43:10 -07:00
Clayton Coleman
82b0ec5115 Replace pkg/kubecfg#FakeKubeClient with the fake in pkg/client 2014-08-15 17:15:53 -04:00
Daniel Smith
5cdce0e35a Prepare for external scheduler
1. Change names of Pod statuses (Waiting, Running, Terminated).
2. Store assigned host in etcd.
3. Change pod key to /registry/pods/<podid>. Container location remains
   the same (/registry/hosts/<machine>/kublet).
2014-08-10 15:05:36 -07:00
Daniel Smith
5dd130a350 Prevent accidental setting of sync or timeout 2014-08-08 14:09:14 -07:00
Daniel Smith
49cded3800 Simplify ResourceWatcher interface to one function. 2014-08-08 14:09:13 -07:00
Daniel Smith
71709ae09e Make replication controller use client 2014-08-08 14:09:13 -07:00
Daniel Smith
b430cebe72 Remove etcd dependency from controller manager. 2014-08-04 14:29:49 -07:00
Clayton Coleman
4448be2d95 Expose an Encoding/Versioning interface for use with etcd
etcd_tools.go is not dependent on the specific implementation
(which is provided by pkg/api).  All EtcdHelpers are created
with an encoding object which handles Encode/Decode/DecodeInto.
Additional tests added to verify simple atomic flows.

Begins to break up api singleton pattern.
2014-08-03 21:35:33 -04:00
Daniel Smith
928092e79e Etcd watcher verification
To make sure the etcd watcher works, I changed the replication
controller to use watch.Interface. I made apiserver support watches on
controllers, so replicationController can be run only off of the
apiserver. I made sure all the etcd watch testing that used to be in
replicationController is now tested on the new etcd watcher in
pkg/tools/.
2014-07-31 14:54:30 -07:00
Dan McPherson
d94f5c3360 Fixing typo 2014-07-30 16:45:53 +02:00
Daniel Smith
31a78c3e2b Merge pull request #619 from brendandburns/controller
Make individual controller actions asynchronous.
2014-07-28 15:35:19 -07:00
Daniel Smith
e3927b428d Merge pull request #618 from brendandburns/async
Make replication controller synchronizations independent.
2014-07-24 22:58:45 -07:00
Brendan Burns
51c5907c55 Make individual controller actions asynchronous. 2014-07-24 22:57:56 -07:00
Brendan Burns
ae0baf3fab Make replication controller synchronizations independent. 2014-07-24 22:46:04 -07:00
Brendan Burns
bf5ae4bb9d Fork API types. 2014-07-24 21:47:08 -07:00
Daniel Smith
91375f4c04 Split httpWatcher into watch.StreamWatcher and tools.APIEventDecoder. 2014-07-21 16:07:58 -07:00
Kelsey Hightower
a9e0b0d1a3 use %v instead of %#v when logging failures 2014-07-20 11:58:22 -07:00
Kelsey Hightower
3b9029ee94 remove unnecessary expectNoError helper function
This patch completes a TODO item for the replication_controller test
suite by removing the expectNoError helper function, which does not
reduce enough typing to justify its usage.
2014-07-20 09:13:11 -07:00
Clayton Coleman
1831cf1711 Remove some verbose logging 2014-07-18 10:48:21 -04:00
Claire Li
ba9c370014 pkg/controller: cleanup replication_controller.go 2014-07-12 14:21:51 -07:00
Tim Hockin
f532038281 Merge pull request #345 from smarterclayton/fix_ids
Ensure pod and manifest have a UUID in apiserver
2014-07-11 11:29:00 -07:00
Andrew Gerrand
a9fdf1f6b5 rename client.ClientInterface to client.Interface 2014-07-11 09:51:34 +10:00
Clayton Coleman
5896ac14da Ensure pod and manifest always have a UUID
* Fixes implication #2 in docs/identifiers.md
* Replication controller lets the apiserver set the pod ID
2014-07-10 18:03:48 -04:00
Yuki Sonoda (Yugui)
056f871bed Fixes golint errors in pkg/controller 2014-07-10 21:27:01 +09:00
Daniel Smith
a6144f656c Move etcd helpers to tools package so they can depend on api package. Add ResourceVersion, hook it up to etcd index to get atomic PUTs. 2014-07-02 15:42:05 -07:00
Daniel Smith
229b8fca2a Don't double-close the channel when etcd returns an error. 2014-07-01 12:49:57 -07:00
Daniel Smith
9da5fed7f4 Merge pull request #277 from brendandburns/sync
Add sync behavior to the pod registry.  Expand tests.
2014-07-01 11:43:40 -07:00
Brendan Burns
13d7a5959a Add sync behavior to the pod registry. Expand tests. 2014-07-01 11:31:21 -07:00
Nan Deng
905c6dcb10 gofmt -r "WaitToWatch->WaitForWatchCompletion" 2014-06-30 16:09:15 -07:00
Nan Deng
62055090b4 fix data races in controller 2014-06-30 14:48:57 -07:00
Brendan Burns
78d9538358 Set id width at 8 and pad with zeros. 2014-06-26 19:24:12 -07:00
Tim Hockin
9f9e75f508 Switch to glog for logging, bridge logging to glog.
1) imported glog to third_party (previous commit)
2) add support for third_party/update.sh to update just one pkg
3) search-and-replace:
  s/log.Printf/glog.Infof/
  s/log.Print/glog.Info/
  s/log.Fatalf/glog.Fatalf/
  s/log.Fatal/glog.Fatal/
4) convert glog.Info.*, err into glog.Error*

Adds some util interfaces to logging and calls them from each cmd, which
will set the default log output to write to glog.  Pass glog-wrapped
Loggers to etcd for logging.

Log files will go to /tmp - we should probably follow this up with a
default log dir for each cmd.

The glog lib is sort of weak in that it only flushes every 30 seconds, so
we spin up our own flushing goroutine.
2014-06-24 20:51:57 -07:00
Daniel Smith
5ce54bb77b Use new method. 2014-06-24 09:38:22 -07:00
Daniel Smith
61a494d303 First step of combination. 2014-06-24 09:38:22 -07:00
Daniel Smith
cfce408266 Rename ReplicasInSet to ReplicaSelector 2014-06-19 13:31:42 -07:00
Brendan Burns
84b2a9e9f3 On delete, also attempt to update controller state, in case we
missed a previous update.  Add a test to validate that this works
2014-06-18 21:32:55 -07:00
Daniel Smith
a253209a2c Add test for watch goroutine handling, fix other review comments 2014-06-18 13:10:39 -07:00
Daniel Smith
1b94f7b244 Fix race 2014-06-18 13:10:39 -07:00
Daniel Smith
7e464aa55c Test controller's synchronize method. Requires fake etcd client to be relocated. 2014-06-18 13:10:39 -07:00
Daniel Smith
3737b4e4e2 Fix bad lock handling. 2014-06-18 13:10:39 -07:00
Daniel Smith
e74ac01a62 Move run logic into package 2014-06-18 13:10:39 -07:00
Daniel Smith
a24116c7bd Move controller to it's own package, it's not part of the registry. 2014-06-18 13:10:39 -07:00