Skip to content

Commit c353381

Browse files
committed
started and complete events only
1 parent a7484fe commit c353381

File tree

16 files changed

+119
-261
lines changed

16 files changed

+119
-261
lines changed

pkg/build/api/types.go

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,21 @@ const (
6464
// for a resync.
6565
BuildAcceptedAnnotation = "build.openshift.io/accepted"
6666

67-
// BuildCreatedEvent is the reason associated with the event registered when a build is created.
68-
BuildCreatedEventReason = "BuildCreated"
69-
// BuildCreatedEventMessage is the message associatd with the event registered when a build is created.
70-
BuildCreatedEventMessage = "Build %s/%s has been created"
71-
// BuildStartedEvent is the reason associated with the event registered when a build is started (pod is created).
67+
// BuildStartedEventReason is the reason associated with the event registered when a build is started (pod is created).
7268
BuildStartedEventReason = "BuildStarted"
73-
// BuildStartedEvent is the message associated with the event registered when a build is started (pod is created).
74-
BuildStartedEventMessage = "Pod has been created to run build %s/%s"
75-
// BuildRunningEvent is the reason associated with the event registered when the build pod starts running.
76-
BuildRunningEventReason = "BuildRunning"
77-
// BuildRunningEvent is the message associated with the event registered when the build pod starts running.
78-
BuildRunningEventMessage = "Pod for build %s/%s started running"
79-
// BuildCompletedEvent is the reason associated with the event registered when build completes successfully.
69+
// BuildStartedEventMessage is the message associated with the event registered when a build is started (pod is created).
70+
BuildStartedEventMessage = "Build %s/%s is now running"
71+
// BuildCompletedEventReason is the reason associated with the event registered when build completes successfully.
8072
BuildCompletedEventReason = "BuildCompleted"
81-
// BuildCompletedEvent is the message associated with the event registered when build completes successfully.
73+
// BuildCompletedEventMessage is the message associated with the event registered when build completes successfully.
8274
BuildCompletedEventMessage = "Build %s/%s completed successfully"
83-
// BuildFailedEvent is the reason associated with the event registered when build fails.
75+
// BuildFailedEventReason is the reason associated with the event registered when build fails.
8476
BuildFailedEventReason = "BuildFailed"
85-
// BuildFailedEvent is the message associated with the event registered when build fails.
77+
// BuildFailedEventMessage is the message associated with the event registered when build fails.
8678
BuildFailedEventMessage = "Build %s/%s failed"
87-
// BuildCancelledEvent is the reason associated with the event registered when build is cancelled.
79+
// BuildCancelledEventReason is the reason associated with the event registered when build is cancelled.
8880
BuildCancelledEventReason = "BuildCancelled"
89-
// BuildCancelledEvent is the message associated with the event registered when build is cancelled.
81+
// BuildCancelledEventMessage is the message associated with the event registered when build is cancelled.
9082
BuildCancelledEventMessage = "Build %s/%s has been cancelled"
9183
)
9284

pkg/build/client/clients.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@ func (c OSClientBuildConfigClient) Update(buildConfig *buildapi.BuildConfig) err
3737
return err
3838
}
3939

40-
// BuildGetter provides methods for getting existing Builds.
41-
type BuildGetter interface {
42-
Get(namespace, name string) (*buildapi.Build, error)
43-
}
44-
4540
// BuildUpdater provides methods for updating existing Builds.
4641
type BuildUpdater interface {
4742
Update(namespace string, build *buildapi.Build) error
@@ -62,11 +57,6 @@ func NewOSClientBuildClient(client osclient.Interface) *OSClientBuildClient {
6257
return &OSClientBuildClient{Client: client}
6358
}
6459

65-
// Get returns a Build using the OpenShift client.
66-
func (c OSClientBuildClient) Get(namespace, name string) (*buildapi.Build, error) {
67-
return c.Client.Builds(namespace).Get(name)
68-
}
69-
7060
// Update updates builds using the OpenShift client.
7161
func (c OSClientBuildClient) Update(namespace string, build *buildapi.Build) error {
7262
_, e := c.Client.Builds(namespace).Update(build)

pkg/build/controller/buildpod/controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (bc *BuildPodController) HandlePod(pod *kapi.Pod) error {
204204
if build.Status.Phase == buildapi.BuildPhaseRunning {
205205
now := unversioned.Now()
206206
build.Status.StartTimestamp = &now
207-
bc.recorder.Eventf(build, kapi.EventTypeNormal, buildapi.BuildRunningEventReason, fmt.Sprintf(buildapi.BuildRunningEventMessage, build.Namespace, build.Name))
207+
bc.recorder.Eventf(build, kapi.EventTypeNormal, buildapi.BuildStartedEventReason, fmt.Sprintf(buildapi.BuildStartedEventMessage, build.Namespace, build.Name))
208208
}
209209
}
210210

pkg/build/controller/controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,8 @@ func (bc *BuildController) nextBuildPhase(build *buildapi.Build) error {
220220
build.Status.Message = buildapi.StatusMessageCannotCreateBuildPod
221221
return fmt.Errorf("failed to create build pod: %v", err)
222222
}
223-
glog.V(4).Infof("Created pod for build: %#v", podSpec)
224-
bc.Recorder.Eventf(build, kapi.EventTypeNormal, buildapi.BuildStartedEventReason, fmt.Sprintf(buildapi.BuildStartedEventMessage, build.Namespace, build.Name))
225223
common.SetBuildPodNameAnnotation(build, podSpec.Name)
224+
glog.V(4).Infof("Created pod for build: %#v", podSpec)
226225

227226
// Set the build phase, which will be persisted.
228227
build.Status.Phase = buildapi.BuildPhasePending

pkg/build/controller/image_change_controller_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
buildapi "github.com/openshift/origin/pkg/build/api"
1414
buildtest "github.com/openshift/origin/pkg/build/controller/test"
1515
buildgenerator "github.com/openshift/origin/pkg/build/generator"
16-
mocks "github.com/openshift/origin/pkg/build/generator/test"
1716
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
1817
imageapi "github.com/openshift/origin/pkg/image/api"
1918
)
@@ -387,11 +386,7 @@ func mockBuildConfigInstantiator(buildcfg *buildapi.BuildConfig, imageStream *im
387386
}
388387
instantiator := &buildConfigInstantiator{}
389388
instantiator.buildConfigUpdater = &mockBuildConfigUpdater{}
390-
recorder := &mocks.MockEventRecorder{}
391-
buildGetter := &mocks.MockBuildGetter{}
392389
generator := buildgenerator.BuildGenerator{
393-
Builds: buildGetter,
394-
Recorder: recorder,
395390
Secrets: fake.NewSimpleClientset().Core(),
396391
ServiceAccounts: fake.NewSimpleClientset(&builderAccount).Core(),
397392
Client: buildgenerator.Client{

pkg/build/generator/generator.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ import (
1313
"k8s.io/kubernetes/pkg/api/errors"
1414
"k8s.io/kubernetes/pkg/api/unversioned"
1515
kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
16-
"k8s.io/kubernetes/pkg/client/record"
1716
"k8s.io/kubernetes/pkg/credentialprovider"
1817
kvalidation "k8s.io/kubernetes/pkg/util/validation"
1918

2019
buildapi "github.com/openshift/origin/pkg/build/api"
21-
buildclient "github.com/openshift/origin/pkg/build/client"
2220
buildutil "github.com/openshift/origin/pkg/build/util"
2321
"github.com/openshift/origin/pkg/cmd/admin/policy"
2422
"github.com/openshift/origin/pkg/cmd/server/bootstrappolicy"
@@ -51,8 +49,6 @@ type BuildGenerator struct {
5149
DefaultServiceAccountName string
5250
ServiceAccounts kcoreclient.ServiceAccountsGetter
5351
Secrets kcoreclient.SecretsGetter
54-
Recorder record.EventRecorder
55-
Builds buildclient.BuildGetter
5652
}
5753

5854
// GeneratorClient is the API client used by the generator
@@ -434,12 +430,7 @@ func (g *BuildGenerator) createBuild(ctx kapi.Context, build *buildapi.Build) (*
434430
if err != nil {
435431
return nil, err
436432
}
437-
b, err := g.Builds.Get(build.Namespace, build.Name)
438-
//b, err := g.Client.GetBuild(ctx, build.Name)
439-
if err == nil {
440-
g.Recorder.Eventf(b, kapi.EventTypeNormal, buildapi.BuildCreatedEventReason, fmt.Sprintf(buildapi.BuildCreatedEventMessage, build.Namespace, build.Name))
441-
}
442-
return build, err
433+
return g.Client.GetBuild(ctx, build.Name)
443434
}
444435

445436
// generateBuildFromConfig generates a build definition based on the current imageid

0 commit comments

Comments
 (0)