From 3a620897908321b547d29f19b99cedfc5a692c1b Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Tue, 7 Oct 2014 13:52:51 -0700 Subject: [PATCH 1/6] Fix malformed namespace json tag --- pkg/api/types.go | 2 +- pkg/api/v1beta1/types.go | 2 +- pkg/api/v1beta2/types.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/api/types.go b/pkg/api/types.go index c1fe4eec4b0..a4491e3fb9b 100644 --- a/pkg/api/types.go +++ b/pkg/api/types.go @@ -252,7 +252,7 @@ type TypeMeta struct { SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"` ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` - Namespace string `json:"namespace",omitempty" yaml:"namespace,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` UID string `json:"uid,omitempty" yaml:"uid,omitempty"` // Annotations are unstructured key value data stored with a resource that may be set by diff --git a/pkg/api/v1beta1/types.go b/pkg/api/v1beta1/types.go index 6548303103e..b0180d3ddb5 100644 --- a/pkg/api/v1beta1/types.go +++ b/pkg/api/v1beta1/types.go @@ -262,7 +262,7 @@ type TypeMeta struct { SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"` ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` - Namespace string `json:"namespace",omitempty" yaml:"namespace,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` // Annotations are unstructured key value data stored with a resource that may be set by // external tooling. They are not queryable and should be preserved when modifying diff --git a/pkg/api/v1beta2/types.go b/pkg/api/v1beta2/types.go index 1bb3e8e737d..0d45d527943 100644 --- a/pkg/api/v1beta2/types.go +++ b/pkg/api/v1beta2/types.go @@ -260,7 +260,7 @@ type TypeMeta struct { SelfLink string `json:"selfLink,omitempty" yaml:"selfLink,omitempty"` ResourceVersion uint64 `json:"resourceVersion,omitempty" yaml:"resourceVersion,omitempty"` APIVersion string `json:"apiVersion,omitempty" yaml:"apiVersion,omitempty"` - Namespace string `json:"namespace",omitempty" yaml:"namespace,omitempty"` + Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` // Annotations are unstructured key value data stored with a resource that may be set by // external tooling. They are not queryable and should be preserved when modifying From 7ffe7914865bc12ac70cae944c4702bafcd8de98 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Tue, 7 Oct 2014 13:54:41 -0700 Subject: [PATCH 2/6] fix error message in validation test --- pkg/api/validation/validation_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 47ddb1893a0..ca2ea7de104 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -28,8 +28,8 @@ import ( func expectPrefix(t *testing.T, prefix string, errs errors.ErrorList) { for i := range errs { - if !strings.HasPrefix(errs[i].(errors.ValidationError).Field, prefix) { - t.Errorf("expected prefix '%s' for %v", errs[i]) + if f, p := errs[i].(errors.ValidationError).Field, prefix; !strings.HasPrefix(f, p) { + t.Errorf("expected prefix '%s' for field '%s' (%v)", p, f, errs[i]) } } } From 2d048bc0f2f0a53f98ce375d1c873e5a7258d884 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Tue, 7 Oct 2014 13:57:30 -0700 Subject: [PATCH 3/6] fix captured loop variable --- pkg/kubelet/runonce.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/kubelet/runonce.go b/pkg/kubelet/runonce.go index 524972eee82..ca41dbf5029 100644 --- a/pkg/kubelet/runonce.go +++ b/pkg/kubelet/runonce.go @@ -59,7 +59,8 @@ func (kl *Kubelet) runOnce(pods []Pod) (results []RunPodResult, err error) { pods = filterHostPortConflicts(pods) ch := make(chan RunPodResult) - for _, pod := range pods { + for i := range pods { + pod := pods[i] // Make a copy go func() { info, err := kl.runPod(pod) ch <- RunPodResult{&pod, info, err} From 2dde76bd03ecadf2b3709df0a45d009558723bed Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Tue, 7 Oct 2014 14:01:45 -0700 Subject: [PATCH 4/6] Fix struct tag in apparently untested config struct --- pkg/proxy/config/file.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/proxy/config/file.go b/pkg/proxy/config/file.go index 6a90ce0a4aa..259bc3b46e2 100644 --- a/pkg/proxy/config/file.go +++ b/pkg/proxy/config/file.go @@ -44,12 +44,13 @@ import ( ) // serviceConfig is a deserialized form of the config file format which ConfigSourceFile accepts. +// TODO: this is apparently untested; is it used? type serviceConfig struct { Services []struct { Name string `json: "name"` Port int `json: "port"` Endpoints []string `json: "endpoints"` - } `json: "service"` + } `json:"service"` } // ConfigSourceFile periodically reads service configurations in JSON from a file, and sends the services and endpoints defined in the file to the specified channels. From 4dd3094035bd47b71a78b993792411444bc486d1 Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Tue, 7 Oct 2014 14:03:06 -0700 Subject: [PATCH 5/6] Fix mismatched arg and formatter in Errorf --- pkg/registry/minion/healthy_registry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/registry/minion/healthy_registry.go b/pkg/registry/minion/healthy_registry.go index 92fb24ba0c2..3fdb14a8c74 100644 --- a/pkg/registry/minion/healthy_registry.go +++ b/pkg/registry/minion/healthy_registry.go @@ -75,7 +75,7 @@ func (r *HealthyRegistry) ListMinions(ctx api.Context) (currentMinions *api.Mini for _, minion := range list.Items { status, err := health.DoHTTPCheck(r.makeMinionURL(minion.ID), r.client) if err != nil { - glog.Errorf("%s failed health check with error: %s", minion, err) + glog.Errorf("%#v failed health check with error: %s", minion, err) continue } if status == health.Healthy { From ee107d3fadb25f998ae2a57faf62f6fbb4a5551d Mon Sep 17 00:00:00 2001 From: Daniel Smith Date: Tue, 7 Oct 2014 14:08:18 -0700 Subject: [PATCH 6/6] fix extra un-cosmetic extraneous code. --- pkg/registry/pod/rest.go | 1 - pkg/runtime/scheme.go | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/pkg/registry/pod/rest.go b/pkg/registry/pod/rest.go index e8cea1fbfcc..597ff3df007 100644 --- a/pkg/registry/pod/rest.go +++ b/pkg/registry/pod/rest.go @@ -340,5 +340,4 @@ func (rs *REST) waitForPodRunning(ctx api.Context, pod *api.Pod) (runtime.Object time.Sleep(rs.podPollPeriod) } } - return pod, nil } diff --git a/pkg/runtime/scheme.go b/pkg/runtime/scheme.go index 74ba81c9fa9..015534c2a35 100644 --- a/pkg/runtime/scheme.go +++ b/pkg/runtime/scheme.go @@ -368,6 +368,9 @@ func (s *Scheme) CopyOrDie(obj Object) Object { return newObj } +// ObjectDiff writes the two objects out as JSON and prints out the identical part of +// the objects followed by the remaining part of 'a' and finally the remaining part of 'b'. +// For debugging tests. func ObjectDiff(a, b Object) string { ab, err := json.Marshal(a) if err != nil { @@ -378,10 +381,13 @@ func ObjectDiff(a, b Object) string { panic(fmt.Sprintf("b: %v", err)) } return util.StringDiff(string(ab), string(bb)) +} - // An alternate diff attempt, in case json isn't showing you - // the difference. (reflect.DeepEqual makes a distinction between - // nil and empty slices, for example.) +// ObjectGoPrintDiff is like ObjectDiff, but uses go's %#v formatter to print the +// objects, in case json isn't showing you the difference. (reflect.DeepEqual makes +// a distinction between nil and empty slices, for example, even though nothing else +// really does.) +func ObjectGoPrintDiff(a, b Object) string { return util.StringDiff( fmt.Sprintf("%#v", a), fmt.Sprintf("%#v", b),