Skip to content

Commit cdda2bb

Browse files
committed
rename to outputexcerpt
1 parent b94d9f5 commit cdda2bb

17 files changed

+297
-310
lines changed

api/protobuf-spec/github_com_openshift_origin_pkg_build_apis_build_v1.proto

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/swagger-spec/oapi-v1.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24587,9 +24587,9 @@
2458724587
},
2458824588
"description": "stages contains details about each stage that occurs during the build including start time, duration (in milliseconds), and the steps that occured within each stage."
2458924589
},
24590-
"logTail": {
24590+
"outputExcerpt": {
2459124591
"type": "string",
24592-
"description": "LogTail is the last few lines of the build log. This value is only set for builds that failed."
24592+
"description": "OutputExcerpt is the last few lines of the build log. This value is only set for builds that failed."
2459324593
}
2459424594
}
2459524595
},

api/swagger-spec/openshift-openapi-spec.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -82826,10 +82826,6 @@
8282682826
"type": "integer",
8282782827
"format": "int64"
8282882828
},
82829-
"logTail": {
82830-
"description": "LogTail is the last few lines of the build log. This value is only set for builds that failed.",
82831-
"type": "string"
82832-
},
8283382829
"message": {
8283482830
"description": "message is a human-readable message indicating details about why the build has this status.",
8283582831
"type": "string"
@@ -82842,6 +82838,10 @@
8284282838
"description": "outputDockerImageReference contains a reference to the Docker image that will be built by this build. Its value is computed from Build.Spec.Output.To, and should include the registry address, so that it can be used to push and pull the image.",
8284382839
"type": "string"
8284482840
},
82841+
"outputExcerpt": {
82842+
"description": "OutputExcerpt is the last few lines of the build log. This value is only set for builds that failed.",
82843+
"type": "string"
82844+
},
8284582845
"phase": {
8284682846
"description": "phase is the point in the build lifecycle. Possible values are \"New\", \"Pending\", \"Running\", \"Complete\", \"Failed\", \"Error\", and \"Cancelled\".",
8284782847
"type": "string"

pkg/build/apis/build/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,8 @@ type BuildStatus struct {
305305
// occured within each stage.
306306
Stages []StageInfo
307307

308-
// LogTail is the last few lines of the build log. This value is only set for builds that failed.
309-
LogTail *string
308+
// OutputExcerpt is the last few lines of the build log. This value is only set for builds that failed.
309+
OutputExcerpt string
310310
}
311311

312312
// StageInfo contains details about a build stage.

pkg/build/apis/build/v1/generated.pb.go

+251-256
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/build/apis/build/v1/generated.proto

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/build/apis/build/v1/swagger_doc.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ var map_BuildStatus = map[string]string{
204204
"config": "config is an ObjectReference to the BuildConfig this Build is based on.",
205205
"output": "output describes the Docker image the build has produced.",
206206
"stages": "stages contains details about each stage that occurs during the build including start time, duration (in milliseconds), and the steps that occured within each stage.",
207-
"logTail": "LogTail is the last few lines of the build log. This value is only set for builds that failed.",
207+
"outputExcerpt": "OutputExcerpt is the last few lines of the build log. This value is only set for builds that failed.",
208208
}
209209

210210
func (BuildStatus) SwaggerDoc() map[string]string {

pkg/build/apis/build/v1/types.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ type BuildStatus struct {
214214
// occured within each stage.
215215
Stages []StageInfo `json:"stages,omitempty" protobuf:"bytes,11,opt,name=stages"`
216216

217-
// LogTail is the last few lines of the build log. This value is only set for builds that failed.
218-
LogTail *string `json:"logTail,omitempty" protobuf:"bytes,12,opt,name=logTail"`
217+
// OutputExcerpt is the last few lines of the build log. This value is only set for builds that failed.
218+
OutputExcerpt string `json:"outputExcerpt,omitempty" protobuf:"bytes,12,opt,name=outputExcerpt"`
219219
}
220220

221221
// StageInfo contains details about a build stage.

pkg/build/apis/build/v1/zz_generated.conversion.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ func autoConvert_v1_BuildStatus_To_build_BuildStatus(in *BuildStatus, out *build
811811
return err
812812
}
813813
out.Stages = *(*[]build.StageInfo)(unsafe.Pointer(&in.Stages))
814-
out.LogTail = (*string)(unsafe.Pointer(in.LogTail))
814+
out.OutputExcerpt = in.OutputExcerpt
815815
return nil
816816
}
817817

@@ -841,7 +841,7 @@ func autoConvert_build_BuildStatus_To_v1_BuildStatus(in *build.BuildStatus, out
841841
return err
842842
}
843843
out.Stages = *(*[]StageInfo)(unsafe.Pointer(&in.Stages))
844-
out.LogTail = (*string)(unsafe.Pointer(in.LogTail))
844+
out.OutputExcerpt = in.OutputExcerpt
845845
return nil
846846
}
847847

pkg/build/apis/build/v1/zz_generated.deepcopy.go

-5
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,6 @@ func DeepCopy_v1_BuildStatus(in interface{}, out interface{}, c *conversion.Clon
470470
}
471471
}
472472
}
473-
if in.LogTail != nil {
474-
in, out := &in.LogTail, &out.LogTail
475-
*out = new(string)
476-
**out = **in
477-
}
478473
return nil
479474
}
480475
}

pkg/build/apis/build/zz_generated.deepcopy.go

-5
Original file line numberDiff line numberDiff line change
@@ -471,11 +471,6 @@ func DeepCopy_build_BuildStatus(in interface{}, out interface{}, c *conversion.C
471471
}
472472
}
473473
}
474-
if in.LogTail != nil {
475-
in, out := &in.LogTail, &out.LogTail
476-
*out = new(string)
477-
**out = **in
478-
}
479474
return nil
480475
}
481476
}

pkg/build/controller/build/build_controller.go

+11-10
Original file line numberDiff line numberDiff line change
@@ -259,17 +259,17 @@ func shouldIgnore(build *buildapi.Build) bool {
259259
}
260260

261261
// If a build is in a terminal state, ignore it; unless it is in a succeeded or failed
262-
// state and its completion time or logtail is not set, then we should at least attempt to set its
263-
// completion time and logtail if possible because the build pod may have put the build in
264-
// this state and it would have not set the completion timestamp or logtail data.
262+
// state and its completion time or outputexcerpt is not set, then we should at least attempt to set its
263+
// completion time and outputexcerpt if possible because the build pod may have put the build in
264+
// this state and it would have not set the completion timestamp or outputexcerpt data.
265265
if buildutil.IsBuildComplete(build) {
266266
switch build.Status.Phase {
267267
case buildapi.BuildPhaseComplete:
268268
if build.Status.CompletionTimestamp == nil {
269269
return false
270270
}
271271
case buildapi.BuildPhaseFailed:
272-
if build.Status.CompletionTimestamp == nil || build.Status.LogTail == nil {
272+
if build.Status.CompletionTimestamp == nil || len(build.Status.OutputExcerpt) == 0 {
273273
return false
274274
}
275275
}
@@ -551,8 +551,8 @@ func (bc *BuildController) handleActiveBuild(build *buildapi.Build, pod *v1.Pod)
551551
// handleCompletedBuild will only be called on builds that are already in a terminal phase however, their completion timestamp
552552
// has not been set.
553553
func (bc *BuildController) handleCompletedBuild(build *buildapi.Build, pod *v1.Pod) (*buildUpdate, error) {
554-
// No-op if the completion timestamp and logtail data(for failed builds only) has already been set
555-
if build.Status.CompletionTimestamp != nil && (build.Status.LogTail != nil || build.Status.Phase != buildapi.BuildPhaseFailed) {
554+
// No-op if the completion timestamp and outputexcerpt data(for failed builds only) has already been set
555+
if build.Status.CompletionTimestamp != nil && (len(build.Status.OutputExcerpt) > 0 || build.Status.Phase != buildapi.BuildPhaseFailed) {
556556
return nil, nil
557557
}
558558

@@ -849,13 +849,14 @@ func setBuildCompletionData(build *buildapi.Build, pod *v1.Pod, update *buildUpd
849849
}
850850
excerpt := parts[len(parts)-excerptLength:]
851851
for i, line := range excerpt {
852-
if len(line) > 100 {
853-
excerpt[i] = line[0:97] + "..."
852+
if len(line) > 120 {
853+
middle := len(line) / 2
854+
excess := (len(line) - 117) / 2
855+
excerpt[i] = line[0:middle-excess] + "..." + line[middle+excess:]
854856
}
855857
}
856858
msg = strings.Join(excerpt, "\n")
857-
858-
update.setLogTail(msg)
859+
update.setOutputExcerpt(msg)
859860
}
860861
}
861862

pkg/build/controller/build/build_controller_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,9 @@ func TestSetBuildCompletionTimestampAndDuration(t *testing.T) {
773773

774774
for _, test := range tests {
775775
update := &buildUpdate{}
776-
setBuildCompletionTimestampAndDuration(test.build, test.podStartTime, update)
776+
pod := &v1.Pod{}
777+
pod.Status.StartTime = test.podStartTime
778+
setBuildCompletionData(test.build, pod, update)
777779
// Ensure that only the fields in the expected update are set
778780
if test.expected.podNameAnnotation == nil && (test.expected.podNameAnnotation != update.podNameAnnotation) {
779781
t.Errorf("%s: podNameAnnotation should not be set", test.name)

pkg/build/controller/build/buildupdate.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type buildUpdate struct {
2626
completionTime *metav1.Time
2727
duration *time.Duration
2828
outputRef *string
29-
logTail *string
29+
outputExcerpt *string
3030
}
3131

3232
func (u *buildUpdate) setPhase(phase buildapi.BuildPhase) {
@@ -61,8 +61,8 @@ func (u *buildUpdate) setPodNameAnnotation(podName string) {
6161
u.podNameAnnotation = &podName
6262
}
6363

64-
func (u *buildUpdate) setLogTail(message string) {
65-
u.logTail = &message
64+
func (u *buildUpdate) setOutputExcerpt(message string) {
65+
u.outputExcerpt = &message
6666
}
6767

6868
func (u *buildUpdate) reset() {
@@ -74,7 +74,7 @@ func (u *buildUpdate) reset() {
7474
u.completionTime = nil
7575
u.duration = nil
7676
u.outputRef = nil
77-
u.logTail = nil
77+
u.outputExcerpt = nil
7878
}
7979

8080
func (u *buildUpdate) isEmpty() bool {
@@ -86,7 +86,7 @@ func (u *buildUpdate) isEmpty() bool {
8686
u.completionTime == nil &&
8787
u.duration == nil &&
8888
u.outputRef == nil &&
89-
u.logTail == nil
89+
u.outputExcerpt == nil
9090
}
9191

9292
func (u *buildUpdate) apply(build *buildapi.Build) {
@@ -114,8 +114,8 @@ func (u *buildUpdate) apply(build *buildapi.Build) {
114114
if u.outputRef != nil {
115115
build.Status.OutputDockerImageReference = *u.outputRef
116116
}
117-
if u.logTail != nil {
118-
build.Status.LogTail = u.logTail
117+
if u.outputExcerpt != nil {
118+
build.Status.OutputExcerpt = *u.outputExcerpt
119119
}
120120
}
121121

@@ -147,8 +147,8 @@ func (u *buildUpdate) String() string {
147147
if u.podNameAnnotation != nil {
148148
updates = append(updates, fmt.Sprintf("podName: %q", *u.podNameAnnotation))
149149
}
150-
if u.logTail != nil {
151-
updates = append(updates, fmt.Sprintf("logTail: %q", *u.logTail))
150+
if u.outputExcerpt != nil {
151+
updates = append(updates, fmt.Sprintf("outputExcerpt: %q", *u.outputExcerpt))
152152
}
153153
return fmt.Sprintf("buildUpdate(%s)", strings.Join(updates, ", "))
154154
}

pkg/cmd/cli/describe/describer.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ func (d *BuildDescriber) Describe(namespace, name string, settings kprinters.Des
170170

171171
describeCommonSpec(build.Spec.CommonSpec, out)
172172
describeBuildTriggerCauses(build.Spec.TriggeredBy, out)
173-
if build.Status.LogTail != nil {
174-
formatString(out, "Log Tail", *build.Status.LogTail)
173+
if len(build.Status.OutputExcerpt) != 0 {
174+
formatString(out, "Log Tail", build.Status.OutputExcerpt)
175175
}
176176
if settings.ShowEvents {
177177
kinternalprinters.DescribeEvents(events, kinternalprinters.NewPrefixWriter(out))

pkg/openapi/zz_generated.openapi.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3084,9 +3084,9 @@ func GetOpenAPIDefinitions(ref openapi.ReferenceCallback) map[string]openapi.Ope
30843084
},
30853085
},
30863086
},
3087-
"logTail": {
3087+
"outputExcerpt": {
30883088
SchemaProps: spec.SchemaProps{
3089-
Description: "LogTail is the last few lines of the build log. This value is only set for builds that failed.",
3089+
Description: "OutputExcerpt is the last few lines of the build log. This value is only set for builds that failed.",
30903090
Type: []string{"string"},
30913091
Format: "",
30923092
},

test/extended/builds/failure_status.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ var _ = g.Describe("[builds][Slow] update failure status", func() {
6060

6161
exutil.CheckForBuildEvent(oc.KubeClient().Core(), br.Build, buildapi.BuildFailedEventReason, buildapi.BuildFailedEventMessage)
6262

63-
// wait for the build to be updated w/ completiontimestamp which should also mean the logtail
63+
// wait for the build to be updated w/ completiontimestamp which should also mean the outputexcerpt
6464
// is set if one is going to be set.
6565
err = wait.Poll(time.Second, 30*time.Second, func() (bool, error) {
6666
// note this is the same build variable used in the test scope
@@ -74,8 +74,7 @@ var _ = g.Describe("[builds][Slow] update failure status", func() {
7474
return false, nil
7575
})
7676
o.Expect(err).NotTo(o.HaveOccurred())
77-
o.Expect(build.Status.LogTail).NotTo(o.BeNil(), "LogTail should be set to something for failed builds")
78-
o.Expect(len(*build.Status.LogTail)).NotTo(o.Equal(0), "LogTail should be set to something for failed builds")
77+
o.Expect(len(build.Status.OutputExcerpt)).NotTo(o.Equal(0), "OutputExcerpt should be set to something for failed builds")
7978
})
8079
})
8180

0 commit comments

Comments
 (0)