This patch consists of various corrections. (#73060)

* This patch consists of various corrections.

*) Remove unwanted `else` code block
*) Adjust variable intialization.
*) Correct error strings.
*) Use recommended variable increment method.

Signed-off-by: hchiramm <hchiramm@redhat.com>

* Remove cluster/images/cluster-version-monitor from hack/.golint_failures.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
pull/564/head
Humble Devassy Chirammal 2019-01-23 01:58:59 +05:30 committed by Kubernetes Prow Robot
parent e1e85f947e
commit 2651c72166
6 changed files with 11 additions and 12 deletions

View File

@ -191,7 +191,7 @@ func (m *monitorGatherer) rewriteExportedMetrics(metrics map[string]*dto.MetricF
return results, nil return results, nil
} }
// Struct for unmarshalling the json response from etcd's /version endpoint. // EtcdVersion struct for unmarshalling the json response from etcd's /version endpoint.
type EtcdVersion struct { type EtcdVersion struct {
BinaryVersion string `json:"etcdserver"` BinaryVersion string `json:"etcdserver"`
ClusterVersion string `json:"etcdcluster"` ClusterVersion string `json:"etcdcluster"`

View File

@ -1,4 +1,3 @@
cluster/images/etcd-version-monitor
cmd/cloud-controller-manager/app/apis/config/v1alpha1 cmd/cloud-controller-manager/app/apis/config/v1alpha1
cmd/hyperkube cmd/hyperkube
cmd/kube-apiserver/app cmd/kube-apiserver/app

View File

@ -593,9 +593,9 @@ func (r RealPodControl) DeletePod(namespace string, podID string, object runtime
if err := r.KubeClient.CoreV1().Pods(namespace).Delete(podID, nil); err != nil && !apierrors.IsNotFound(err) { if err := r.KubeClient.CoreV1().Pods(namespace).Delete(podID, nil); err != nil && !apierrors.IsNotFound(err) {
r.Recorder.Eventf(object, v1.EventTypeWarning, FailedDeletePodReason, "Error deleting: %v", err) r.Recorder.Eventf(object, v1.EventTypeWarning, FailedDeletePodReason, "Error deleting: %v", err)
return fmt.Errorf("unable to delete pods: %v", err) return fmt.Errorf("unable to delete pods: %v", err)
} else {
r.Recorder.Eventf(object, v1.EventTypeNormal, SuccessfulDeletePodReason, "Deleted pod: %v", podID)
} }
r.Recorder.Eventf(object, v1.EventTypeNormal, SuccessfulDeletePodReason, "Deleted pod: %v", podID)
return nil return nil
} }

View File

@ -36,8 +36,8 @@ import (
var ( var (
// schedule is hourly on the hour // schedule is hourly on the hour
onTheHour string = "0 * * * ?" onTheHour = "0 * * * ?"
errorSchedule string = "obvious error schedule" errorSchedule = "obvious error schedule"
) )
func justBeforeTheHour() time.Time { func justBeforeTheHour() time.Time {
@ -160,8 +160,8 @@ var (
A batchV1beta1.ConcurrencyPolicy = batchV1beta1.AllowConcurrent A batchV1beta1.ConcurrencyPolicy = batchV1beta1.AllowConcurrent
f batchV1beta1.ConcurrencyPolicy = batchV1beta1.ForbidConcurrent f batchV1beta1.ConcurrencyPolicy = batchV1beta1.ForbidConcurrent
R batchV1beta1.ConcurrencyPolicy = batchV1beta1.ReplaceConcurrent R batchV1beta1.ConcurrencyPolicy = batchV1beta1.ReplaceConcurrent
T bool = true T = true
F bool = false F = false
) )
func TestSyncOne_RunOrNot(t *testing.T) { func TestSyncOne_RunOrNot(t *testing.T) {
@ -347,7 +347,7 @@ func TestSyncOne_RunOrNot(t *testing.T) {
for i := 1; i <= len(recorder.Events); i++ { for i := 1; i <= len(recorder.Events); i++ {
e := <-recorder.Events e := <-recorder.Events
if strings.HasPrefix(e, v1.EventTypeWarning) { if strings.HasPrefix(e, v1.EventTypeWarning) {
numWarnings += 1 numWarnings++
} }
} }
if numWarnings != tc.expectedWarnings { if numWarnings != tc.expectedWarnings {

View File

@ -108,9 +108,9 @@ func TestPodTemplateSpecHash(t *testing.T) {
seenHashes := make(map[string]int) seenHashes := make(map[string]int)
for i := 0; i < 1000; i++ { for i := 0; i < 1000; i++ {
specJson := strings.Replace(podSpec, "@@VERSION@@", strconv.Itoa(i), 1) specJSON := strings.Replace(podSpec, "@@VERSION@@", strconv.Itoa(i), 1)
spec := v1.PodTemplateSpec{} spec := v1.PodTemplateSpec{}
json.Unmarshal([]byte(specJson), &spec) json.Unmarshal([]byte(specJSON), &spec)
hash := controller.ComputeHash(&spec, nil) hash := controller.ComputeHash(&spec, nil)
if v, ok := seenHashes[hash]; ok { if v, ok := seenHashes[hash]; ok {
t.Errorf("Hash collision, old: %d new: %d", v, i) t.Errorf("Hash collision, old: %d new: %d", v, i)

View File

@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
// namespace contains a controller that handles namespace lifecycle // Package namespace contains a controller that handles namespace lifecycle
package namespace // import "k8s.io/kubernetes/pkg/controller/namespace" package namespace // import "k8s.io/kubernetes/pkg/controller/namespace"