Replication controller gives failedCreate events

This commit is contained in:
derekwaynecarr 2015-04-14 15:42:49 -04:00
parent 88cf777dfd
commit 986c225311

View File

@ -25,6 +25,7 @@ import (
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/errors"
"github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation" "github.com/GoogleCloudPlatform/kubernetes/pkg/api/validation"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client" "github.com/GoogleCloudPlatform/kubernetes/pkg/client"
"github.com/GoogleCloudPlatform/kubernetes/pkg/client/record"
"github.com/GoogleCloudPlatform/kubernetes/pkg/fields" "github.com/GoogleCloudPlatform/kubernetes/pkg/fields"
"github.com/GoogleCloudPlatform/kubernetes/pkg/labels" "github.com/GoogleCloudPlatform/kubernetes/pkg/labels"
"github.com/GoogleCloudPlatform/kubernetes/pkg/util" "github.com/GoogleCloudPlatform/kubernetes/pkg/util"
@ -55,6 +56,7 @@ type PodControlInterface interface {
// RealPodControl is the default implementation of PodControllerInterface. // RealPodControl is the default implementation of PodControllerInterface.
type RealPodControl struct { type RealPodControl struct {
kubeClient client.Interface kubeClient client.Interface
recorder record.EventRecorder
} }
// Time period of main replication controller sync loop // Time period of main replication controller sync loop
@ -92,6 +94,7 @@ func (r RealPodControl) createReplica(namespace string, controller api.Replicati
return return
} }
if _, err := r.kubeClient.Pods(namespace).Create(pod); err != nil { if _, err := r.kubeClient.Pods(namespace).Create(pod); err != nil {
r.recorder.Eventf(&controller, "failedCreate", "Error creating: %v", err)
util.HandleError(fmt.Errorf("unable to create pod replica: %v", err)) util.HandleError(fmt.Errorf("unable to create pod replica: %v", err))
} }
} }
@ -102,12 +105,17 @@ func (r RealPodControl) deletePod(namespace, podID string) error {
// NewReplicationManager creates a new ReplicationManager. // NewReplicationManager creates a new ReplicationManager.
func NewReplicationManager(kubeClient client.Interface) *ReplicationManager { func NewReplicationManager(kubeClient client.Interface) *ReplicationManager {
eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartRecordingToSink(kubeClient.Events(""))
rm := &ReplicationManager{ rm := &ReplicationManager{
kubeClient: kubeClient, kubeClient: kubeClient,
podControl: RealPodControl{ podControl: RealPodControl{
kubeClient: kubeClient, kubeClient: kubeClient,
recorder: eventBroadcaster.NewRecorder(api.EventSource{Component: "replication-controller"}),
}, },
} }
rm.syncHandler = rm.syncReplicationController rm.syncHandler = rm.syncReplicationController
return rm return rm
} }