Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3f9c4b0

Browse files
committedApr 10, 2017
started and complete events only
1 parent a7484fe commit 3f9c4b0

File tree

13 files changed

+102
-243
lines changed

13 files changed

+102
-243
lines changed
 

‎pkg/build/api/types.go

+9-17
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

-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

‎pkg/build/generator/generator_test.go

+79-132
Original file line numberDiff line numberDiff line change
@@ -103,53 +103,48 @@ func TestInstantiateRetry(t *testing.T) {
103103

104104
func TestInstantiateDeletingError(t *testing.T) {
105105
source := mocks.MockSource()
106-
recorder := &mocks.MockEventRecorder{}
107-
buildGetter := &mocks.MockBuildGetter{}
108-
generator := BuildGenerator{
109-
Builds: buildGetter,
110-
Recorder: recorder,
111-
Client: Client{
112-
GetBuildConfigFunc: func(ctx kapi.Context, name string) (*buildapi.BuildConfig, error) {
113-
bc := &buildapi.BuildConfig{
114-
ObjectMeta: kapi.ObjectMeta{
115-
Annotations: map[string]string{
116-
buildapi.BuildConfigPausedAnnotation: "true",
117-
},
106+
generator := BuildGenerator{Client: Client{
107+
GetBuildConfigFunc: func(ctx kapi.Context, name string) (*buildapi.BuildConfig, error) {
108+
bc := &buildapi.BuildConfig{
109+
ObjectMeta: kapi.ObjectMeta{
110+
Annotations: map[string]string{
111+
buildapi.BuildConfigPausedAnnotation: "true",
118112
},
119-
Spec: buildapi.BuildConfigSpec{
120-
CommonSpec: buildapi.CommonSpec{
121-
Source: source,
122-
Revision: &buildapi.SourceRevision{
123-
Git: &buildapi.GitSourceRevision{
124-
Commit: "1234",
125-
},
113+
},
114+
Spec: buildapi.BuildConfigSpec{
115+
CommonSpec: buildapi.CommonSpec{
116+
Source: source,
117+
Revision: &buildapi.SourceRevision{
118+
Git: &buildapi.GitSourceRevision{
119+
Commit: "1234",
126120
},
127121
},
128122
},
129-
}
130-
return bc, nil
131-
},
132-
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
133-
build := &buildapi.Build{
134-
Spec: buildapi.BuildSpec{
135-
CommonSpec: buildapi.CommonSpec{
136-
Source: source,
137-
Revision: &buildapi.SourceRevision{
138-
Git: &buildapi.GitSourceRevision{
139-
Commit: "1234",
140-
},
123+
},
124+
}
125+
return bc, nil
126+
},
127+
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
128+
build := &buildapi.Build{
129+
Spec: buildapi.BuildSpec{
130+
CommonSpec: buildapi.CommonSpec{
131+
Source: source,
132+
Revision: &buildapi.SourceRevision{
133+
Git: &buildapi.GitSourceRevision{
134+
Commit: "1234",
141135
},
142136
},
143137
},
144-
Status: buildapi.BuildStatus{
145-
Config: &kapi.ObjectReference{
146-
Name: "buildconfig",
147-
},
138+
},
139+
Status: buildapi.BuildStatus{
140+
Config: &kapi.ObjectReference{
141+
Name: "buildconfig",
148142
},
149-
}
150-
return build, nil
151-
},
152-
}}
143+
},
144+
}
145+
return build, nil
146+
},
147+
}}
153148
_, err := generator.Instantiate(kapi.NewDefaultContext(), &buildapi.BuildRequest{})
154149
if err == nil || !strings.Contains(err.Error(), "BuildConfig is paused") {
155150
t.Errorf("Expected error, got different %v", err)
@@ -216,25 +211,20 @@ func TestInstantiateBinaryRemoved(t *testing.T) {
216211
}
217212

218213
func TestInstantiateGetBuildConfigError(t *testing.T) {
219-
recorder := &mocks.MockEventRecorder{}
220-
buildGetter := &mocks.MockBuildGetter{}
221-
generator := BuildGenerator{
222-
Builds: buildGetter,
223-
Recorder: recorder,
224-
Client: Client{
225-
GetBuildConfigFunc: func(ctx kapi.Context, name string) (*buildapi.BuildConfig, error) {
226-
return nil, fmt.Errorf("get-error")
227-
},
228-
GetImageStreamFunc: func(ctx kapi.Context, name string) (*imageapi.ImageStream, error) {
229-
return nil, fmt.Errorf("get-error")
230-
},
231-
GetImageStreamImageFunc: func(ctx kapi.Context, name string) (*imageapi.ImageStreamImage, error) {
232-
return nil, fmt.Errorf("get-error")
233-
},
234-
GetImageStreamTagFunc: func(ctx kapi.Context, name string) (*imageapi.ImageStreamTag, error) {
235-
return nil, fmt.Errorf("get-error")
236-
},
237-
}}
214+
generator := BuildGenerator{Client: Client{
215+
GetBuildConfigFunc: func(ctx kapi.Context, name string) (*buildapi.BuildConfig, error) {
216+
return nil, fmt.Errorf("get-error")
217+
},
218+
GetImageStreamFunc: func(ctx kapi.Context, name string) (*imageapi.ImageStream, error) {
219+
return nil, fmt.Errorf("get-error")
220+
},
221+
GetImageStreamImageFunc: func(ctx kapi.Context, name string) (*imageapi.ImageStreamImage, error) {
222+
return nil, fmt.Errorf("get-error")
223+
},
224+
GetImageStreamTagFunc: func(ctx kapi.Context, name string) (*imageapi.ImageStreamTag, error) {
225+
return nil, fmt.Errorf("get-error")
226+
},
227+
}}
238228

239229
_, err := generator.Instantiate(kapi.NewDefaultContext(), &buildapi.BuildRequest{})
240230
if err == nil || !strings.Contains(err.Error(), "get-error") {
@@ -247,11 +237,7 @@ func TestInstantiateGenerateBuildError(t *testing.T) {
247237
for _, s := range mocks.MockBuilderSecrets() {
248238
fakeSecrets = append(fakeSecrets, s)
249239
}
250-
recorder := &mocks.MockEventRecorder{}
251-
buildGetter := &mocks.MockBuildGetter{}
252240
generator := BuildGenerator{
253-
Builds: buildGetter,
254-
Recorder: recorder,
255241
Secrets: fake.NewSimpleClientset(fakeSecrets...).Core(),
256242
ServiceAccounts: mocks.MockBuilderServiceAccount(mocks.MockBuilderSecrets()),
257243
Client: Client{
@@ -806,24 +792,19 @@ func TestFindImageTrigger(t *testing.T) {
806792
}
807793

808794
func TestClone(t *testing.T) {
809-
recorder := &mocks.MockEventRecorder{}
810-
buildGetter := &mocks.MockBuildGetter{}
811-
generator := BuildGenerator{
812-
Builds: buildGetter,
813-
Recorder: recorder,
814-
Client: Client{
815-
CreateBuildFunc: func(ctx kapi.Context, build *buildapi.Build) error {
816-
return nil
817-
},
818-
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
819-
return &buildapi.Build{
820-
ObjectMeta: kapi.ObjectMeta{
821-
Name: "test-build-1",
822-
Namespace: kapi.NamespaceDefault,
823-
},
824-
}, nil
825-
},
826-
}}
795+
generator := BuildGenerator{Client: Client{
796+
CreateBuildFunc: func(ctx kapi.Context, build *buildapi.Build) error {
797+
return nil
798+
},
799+
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
800+
return &buildapi.Build{
801+
ObjectMeta: kapi.ObjectMeta{
802+
Name: "test-build-1",
803+
Namespace: kapi.NamespaceDefault,
804+
},
805+
}, nil
806+
},
807+
}}
827808

828809
_, err := generator.Clone(kapi.NewDefaultContext(), &buildapi.BuildRequest{})
829810
if err != nil {
@@ -832,16 +813,11 @@ func TestClone(t *testing.T) {
832813
}
833814

834815
func TestCloneError(t *testing.T) {
835-
recorder := &mocks.MockEventRecorder{}
836-
buildGetter := &mocks.MockBuildGetter{}
837-
generator := BuildGenerator{
838-
Builds: buildGetter,
839-
Recorder: recorder,
840-
Client: Client{
841-
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
842-
return nil, fmt.Errorf("get-error")
843-
},
844-
}}
816+
generator := BuildGenerator{Client: Client{
817+
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
818+
return nil, fmt.Errorf("get-error")
819+
},
820+
}}
845821

846822
_, err := generator.Clone(kapi.NewContext(), &buildapi.BuildRequest{})
847823
if err == nil || !strings.Contains(err.Error(), "get-error") {
@@ -856,20 +832,14 @@ func TestCreateBuild(t *testing.T) {
856832
Namespace: kapi.NamespaceDefault,
857833
},
858834
}
859-
860-
recorder := &mocks.MockEventRecorder{}
861-
buildGetter := &mocks.MockBuildGetter{}
862-
generator := BuildGenerator{
863-
Builds: buildGetter,
864-
Recorder: recorder,
865-
Client: Client{
866-
CreateBuildFunc: func(ctx kapi.Context, build *buildapi.Build) error {
867-
return nil
868-
},
869-
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
870-
return build, nil
871-
},
872-
}}
835+
generator := BuildGenerator{Client: Client{
836+
CreateBuildFunc: func(ctx kapi.Context, build *buildapi.Build) error {
837+
return nil
838+
},
839+
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
840+
return build, nil
841+
},
842+
}}
873843

874844
build, err := generator.createBuild(kapi.NewDefaultContext(), build)
875845
if err != nil {
@@ -901,16 +871,11 @@ func TestCreateBuildCreateError(t *testing.T) {
901871
Namespace: kapi.NamespaceDefault,
902872
},
903873
}
904-
recorder := &mocks.MockEventRecorder{}
905-
buildGetter := &mocks.MockBuildGetter{}
906-
generator := BuildGenerator{
907-
Builds: buildGetter,
908-
Recorder: recorder,
909-
Client: Client{
910-
CreateBuildFunc: func(ctx kapi.Context, build *buildapi.Build) error {
911-
return fmt.Errorf("create-error")
912-
},
913-
}}
874+
generator := BuildGenerator{Client: Client{
875+
CreateBuildFunc: func(ctx kapi.Context, build *buildapi.Build) error {
876+
return fmt.Errorf("create-error")
877+
},
878+
}}
914879

915880
_, err := generator.createBuild(kapi.NewDefaultContext(), build)
916881
if err == nil || !strings.Contains(err.Error(), "create-error") {
@@ -1038,11 +1003,7 @@ func TestGenerateBuildWithImageTagForSourceStrategyImageRepository(t *testing.T)
10381003
for _, s := range mocks.MockBuilderSecrets() {
10391004
fakeSecrets = append(fakeSecrets, s)
10401005
}
1041-
recorder := &mocks.MockEventRecorder{}
1042-
buildGetter := &mocks.MockBuildGetter{}
10431006
generator := BuildGenerator{
1044-
Builds: buildGetter,
1045-
Recorder: recorder,
10461007
Secrets: fake.NewSimpleClientset(fakeSecrets...).Core(),
10471008
ServiceAccounts: mocks.MockBuilderServiceAccount(mocks.MockBuilderSecrets()),
10481009
Client: Client{
@@ -1121,11 +1082,7 @@ func TestGenerateBuildWithImageTagForDockerStrategyImageRepository(t *testing.T)
11211082
for _, s := range mocks.MockBuilderSecrets() {
11221083
fakeSecrets = append(fakeSecrets, s)
11231084
}
1124-
recorder := &mocks.MockEventRecorder{}
1125-
buildGetter := &mocks.MockBuildGetter{}
11261085
generator := BuildGenerator{
1127-
Builds: buildGetter,
1128-
Recorder: recorder,
11291086
Secrets: fake.NewSimpleClientset(fakeSecrets...).Core(),
11301087
ServiceAccounts: mocks.MockBuilderServiceAccount(mocks.MockBuilderSecrets()),
11311088
Client: Client{
@@ -1203,11 +1160,7 @@ func TestGenerateBuildWithImageTagForCustomStrategyImageRepository(t *testing.T)
12031160
for _, s := range mocks.MockBuilderSecrets() {
12041161
fakeSecrets = append(fakeSecrets, s)
12051162
}
1206-
recorder := &mocks.MockEventRecorder{}
1207-
buildGetter := &mocks.MockBuildGetter{}
12081163
generator := BuildGenerator{
1209-
Builds: buildGetter,
1210-
Recorder: recorder,
12111164
Secrets: fake.NewSimpleClientset(fakeSecrets...).Core(),
12121165
ServiceAccounts: mocks.MockBuilderServiceAccount(mocks.MockBuilderSecrets()),
12131166
Client: Client{
@@ -1783,16 +1736,10 @@ func mockBuildGenerator() *BuildGenerator {
17831736
for _, s := range mocks.MockBuilderSecrets() {
17841737
fakeSecrets = append(fakeSecrets, s)
17851738
}
1786-
17871739
var b *buildapi.Build
1788-
1789-
recorder := &mocks.MockEventRecorder{}
1790-
buildGetter := &mocks.MockBuildGetter{}
17911740
return &BuildGenerator{
17921741
Secrets: fake.NewSimpleClientset(fakeSecrets...).Core(),
17931742
ServiceAccounts: mocks.MockBuilderServiceAccount(mocks.MockBuilderSecrets()),
1794-
Builds: buildGetter,
1795-
Recorder: recorder,
17961743
Client: Client{
17971744
GetBuildConfigFunc: func(ctx kapi.Context, name string) (*buildapi.BuildConfig, error) {
17981745
return mocks.MockBuildConfig(mocks.MockSource(), mocks.MockSourceStrategyForImageRepository(), mocks.MockOutput()), nil

‎pkg/build/generator/test/mocks.go

-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"fmt"
55

66
kapi "k8s.io/kubernetes/pkg/api"
7-
"k8s.io/kubernetes/pkg/api/unversioned"
87
"k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/fake"
98
kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
109
"k8s.io/kubernetes/pkg/runtime"
@@ -203,22 +202,3 @@ func MockImage(name, dockerSpec string) *imageapi.Image {
203202
DockerImageReference: dockerSpec,
204203
}
205204
}
206-
207-
type MockBuildGetter struct {
208-
Build *buildapi.Build
209-
Error error
210-
}
211-
212-
func (m *MockBuildGetter) Get(namespace, name string) (*buildapi.Build, error) {
213-
return m.Build, m.Error
214-
}
215-
216-
type MockEventRecorder struct{}
217-
218-
func (m *MockEventRecorder) Event(object runtime.Object, eventtype, reason, message string) {}
219-
220-
func (m *MockEventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{}) {
221-
}
222-
223-
func (m *MockEventRecorder) PastEventf(object runtime.Object, timestamp unversioned.Time, eventtype, reason, messageFmt string, args ...interface{}) {
224-
}

‎pkg/build/registry/buildclone/rest_test.go

+8-14
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,17 @@ import (
88
buildapi "github.com/openshift/origin/pkg/build/api"
99
_ "github.com/openshift/origin/pkg/build/api/install"
1010
"github.com/openshift/origin/pkg/build/generator"
11-
mocks "github.com/openshift/origin/pkg/build/generator/test"
1211
)
1312

1413
func TestCreateClone(t *testing.T) {
15-
recorder := &mocks.MockEventRecorder{}
16-
buildGetter := &mocks.MockBuildGetter{}
17-
rest := CloneREST{&generator.BuildGenerator{
18-
Builds: buildGetter,
19-
Recorder: recorder,
20-
Client: generator.Client{
21-
CreateBuildFunc: func(ctx kapi.Context, build *buildapi.Build) error {
22-
return nil
23-
},
24-
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
25-
return &buildapi.Build{}, nil
26-
},
27-
}}}
14+
rest := CloneREST{&generator.BuildGenerator{Client: generator.Client{
15+
CreateBuildFunc: func(ctx kapi.Context, build *buildapi.Build) error {
16+
return nil
17+
},
18+
GetBuildFunc: func(ctx kapi.Context, name string) (*buildapi.Build, error) {
19+
return &buildapi.Build{}, nil
20+
},
21+
}}}
2822

2923
_, err := rest.Create(kapi.NewDefaultContext(), &buildapi.BuildRequest{ObjectMeta: kapi.ObjectMeta{Name: "name"}})
3024
if err != nil {

‎pkg/build/registry/buildconfiginstantiate/rest_test.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ func TestCreateInstantiate(t *testing.T) {
2121
for _, s := range mocks.MockBuilderSecrets() {
2222
fakeSecrets = append(fakeSecrets, s)
2323
}
24-
recorder := &mocks.MockEventRecorder{}
25-
buildGetter := &mocks.MockBuildGetter{}
2624
rest := InstantiateREST{&generator.BuildGenerator{
27-
Builds: buildGetter,
28-
Recorder: recorder,
2925
Secrets: fake.NewSimpleClientset(fakeSecrets...).Core(),
3026
ServiceAccounts: mocks.MockBuilderServiceAccount(mocks.MockBuilderSecrets()),
3127
Client: generator.Client{
@@ -62,6 +58,6 @@ func TestCreateInstantiateValidationError(t *testing.T) {
6258
rest := InstantiateREST{&generator.BuildGenerator{}}
6359
_, err := rest.Create(kapi.NewDefaultContext(), &buildapi.BuildRequest{})
6460
if err == nil {
65-
t.Error("Expected error, got none!")
61+
t.Error("Expected object got none!")
6662
}
6763
}

‎pkg/cmd/server/origin/master.go

-7
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ import (
2828
"k8s.io/kubernetes/pkg/apiserver"
2929
kapiserverfilters "k8s.io/kubernetes/pkg/apiserver/filters"
3030
kclientset "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset"
31-
kcoreclient "k8s.io/kubernetes/pkg/client/clientset_generated/internalclientset/typed/core/internalversion"
32-
"k8s.io/kubernetes/pkg/client/record"
3331
"k8s.io/kubernetes/pkg/client/restclient"
3432
"k8s.io/kubernetes/pkg/genericapiserver"
3533
kgenericfilters "k8s.io/kubernetes/pkg/genericapiserver/filters"
@@ -745,9 +743,6 @@ func (c *MasterConfig) GetRestStorage() map[unversioned.GroupVersion]map[string]
745743
imageStreamImageStorage := imagestreamimage.NewREST(imageRegistry, imageStreamRegistry)
746744
imageStreamImageRegistry := imagestreamimage.NewRegistry(imageStreamImageStorage)
747745

748-
eventBroadcaster := record.NewBroadcaster()
749-
eventBroadcaster.StartRecordingToSink(&kcoreclient.EventSinkImpl{Interface: c.KubeClientset().Core().Events("")})
750-
generatorBuildClient, _ := c.BuildConfigChangeControllerClients()
751746
buildGenerator := &buildgenerator.BuildGenerator{
752747
Client: buildgenerator.Client{
753748
GetBuildConfigFunc: buildConfigRegistry.GetBuildConfig,
@@ -761,8 +756,6 @@ func (c *MasterConfig) GetRestStorage() map[unversioned.GroupVersion]map[string]
761756
},
762757
ServiceAccounts: c.KubeClientset(),
763758
Secrets: c.KubeClientset(),
764-
Builds: buildclient.NewOSClientBuildClient(generatorBuildClient),
765-
Recorder: eventBroadcaster.NewRecorder(kapi.EventSource{Component: "build-generator"}),
766759
}
767760

768761
// TODO: with sharding, this needs to be changed

‎test/common/build/controllers.go

+2-18
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
buildapi "github.com/openshift/origin/pkg/build/api"
1616
"github.com/openshift/origin/pkg/client"
1717
imageapi "github.com/openshift/origin/pkg/image/api"
18+
exutil "github.com/openshift/origin/test/extended/util"
1819
testutil "github.com/openshift/origin/test/util"
1920
)
2021

@@ -624,24 +625,7 @@ func RunBuildRunningPodDeleteTest(t testingT, clusterAdminClient *client.Client,
624625
if newBuild.Status.Phase != buildapi.BuildPhaseError {
625626
t.Fatalf("expected build status to be marked error, but was marked %s", newBuild.Status.Phase)
626627
}
627-
events, err := clusterAdminKubeClientset.Core().Events(testutil.Namespace()).Search(newBuild)
628-
if err != nil {
629-
t.Fatalf("error getting build events: %v", err)
630-
}
631-
foundFailed := false
632-
for _, event := range events.Items {
633-
switch event.Reason {
634-
case buildapi.BuildFailedEventReason:
635-
foundFailed = true
636-
expect := fmt.Sprintf(buildapi.BuildFailedEventMessage, newBuild.Namespace, newBuild.Name)
637-
if event.Message != expect {
638-
t.Fatalf("expected failed event message to be %s, got %s", expect, event.Message)
639-
}
640-
}
641-
}
642-
if !foundFailed {
643-
t.Fatalf("expected to find a failed event on the build %s/%s", newBuild.Namespace, newBuild.Name)
644-
}
628+
exutil.CheckForEvent(clusterAdminKubeClientset.Core(), newBuild, buildapi.BuildFailedEventReason, buildapi.BuildFailedEventMessage)
645629
}
646630

647631
func RunBuildCompletePodDeleteTest(t testingT, clusterAdminClient *client.Client, clusterAdminKubeClientset *kclientset.Clientset) {

‎test/extended/builds/s2i_quota.go

-2
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ var _ = g.Describe("[builds][Conformance] s2i build with a quota", func() {
5858
o.Expect(err).NotTo(o.HaveOccurred(), "Should be able to get events from the build")
5959
o.Expect(events).NotTo(o.BeNil(), "Build event list should not be nil")
6060

61-
exutil.CheckForEvent(oc.KubeClient().Core(), br.Build, buildapi.BuildCreatedEventReason, buildapi.BuildCreatedEventMessage)
6261
exutil.CheckForEvent(oc.KubeClient().Core(), br.Build, buildapi.BuildStartedEventReason, buildapi.BuildStartedEventMessage)
63-
exutil.CheckForEvent(oc.KubeClient().Core(), br.Build, buildapi.BuildRunningEventReason, buildapi.BuildRunningEventMessage)
6462
exutil.CheckForEvent(oc.KubeClient().Core(), br.Build, buildapi.BuildCompletedEventReason, buildapi.BuildCompletedEventMessage)
6563

6664
})

0 commit comments

Comments
 (0)
Please sign in to comment.