Skip to content

Commit 3ce38a3

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

File tree

13 files changed

+93
-234
lines changed

13 files changed

+93
-234
lines changed

pkg/build/api/types.go

-8
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,10 @@ 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"
7167
// BuildStartedEvent is the reason associated with the event registered when a build is started (pod is created).
7268
BuildStartedEventReason = "BuildStarted"
7369
// BuildStartedEvent is the message associated with the event registered when a build is started (pod is created).
7470
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"
7971
// BuildCompletedEvent is the reason associated with the event registered when build completes successfully.
8072
BuildCompletedEventReason = "BuildCompleted"
8173
// BuildCompletedEvent is the message associated with the event registered when build completes successfully.

pkg/build/client/clients.go

-10
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

+1-1
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

+1-2
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

-5
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

+1-10
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)