Skip to content

Commit

Permalink
Fix capitalization inconsistency in reconciler
Browse files Browse the repository at this point in the history
Fix the first task in #7266

Update error messages returned in pkg/reconciler to begin with lowercase.

Update error logs in pkg/reconciler to begin with uppercase.
  • Loading branch information
mlschmithorst committed Oct 31, 2023
1 parent 7069889 commit 7039282
Show file tree
Hide file tree
Showing 14 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion pkg/reconciler/events/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func EventKey(event *cloudevents.Event) (string, error) {
return "", err
}
if data.CustomRun == nil {
return "", fmt.Errorf("Invalid CustomRun data in %v", event)
return "", fmt.Errorf("invalid CustomRun data in %v", event)
}
resourceName = data.CustomRun.Name
resourceNamespace = data.CustomRun.Namespace
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/events/cloudevent/cloud_event_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func SendCloudEventWithRetries(ctx context.Context, object runtime.Object) error
if isCustomRun {
cloudEventSent, err := cache.ContainsOrAddCloudEvent(cacheClient, event)
if err != nil {
logger.Errorf("error while checking cache: %s", err)
logger.Errorf("Error while checking cache: %s", err)
}
if cloudEventSent {
logger.Infof("cloudevent %v already sent", event)
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/events/k8sevent/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func eventsFromChannel(c chan string, wantEvents []string) error {
for {
select {
case event := <-c:
return fmt.Errorf("Unexpected event: %q", event)
return fmt.Errorf("unexpected event: %q", event)
default:
return nil
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/cancel.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func cancelPipelineTaskRunsForTaskNames(ctx context.Context, logger *zap.Sugared
logger.Infof("cancelling TaskRun %s", taskRunName)

if err := cancelTaskRun(ctx, taskRunName, pr.Namespace, clientSet); err != nil {
errs = append(errs, fmt.Errorf("Failed to patch TaskRun `%s` with cancellation: %w", taskRunName, err).Error())
errs = append(errs, fmt.Errorf("failed to patch TaskRun `%s` with cancellation: %w", taskRunName, err).Error())
continue
}
}
Expand All @@ -148,7 +148,7 @@ func cancelPipelineTaskRunsForTaskNames(ctx context.Context, logger *zap.Sugared
logger.Infof("cancelling CustomRun %s", runName)

if err := cancelCustomRun(ctx, runName, pr.Namespace, clientSet); err != nil {
errs = append(errs, fmt.Errorf("Failed to patch CustomRun `%s` with cancellation: %w", runName, err).Error())
errs = append(errs, fmt.Errorf("failed to patch CustomRun `%s` with cancellation: %w", runName, err).Error())
continue
}
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/pipelinerun/pipelinerun.go
Original file line number Diff line number Diff line change
Expand Up @@ -1371,13 +1371,13 @@ func (c *Reconciler) updatePipelineRunStatusFromInformer(ctx context.Context, pr
pipelineRunLabels := getTaskrunLabels(pr, "", false)
taskRuns, err := c.taskRunLister.TaskRuns(pr.Namespace).List(k8slabels.SelectorFromSet(pipelineRunLabels))
if err != nil {
logger.Errorf("could not list TaskRuns %#v", err)
logger.Errorf("Could not list TaskRuns %#v", err)
return err
}

customRuns, err := c.customRunLister.CustomRuns(pr.Namespace).List(k8slabels.SelectorFromSet(pipelineRunLabels))
if err != nil {
logger.Errorf("could not list CustomRuns %#v", err)
logger.Errorf("Could not list CustomRuns %#v", err)
return err
}
return updatePipelineRunStatusFromChildObjects(ctx, logger, pr, taskRuns, customRuns)
Expand Down Expand Up @@ -1525,7 +1525,7 @@ func conditionFromVerificationResult(verificationResult *trustedresources.Verifi
var err error
switch verificationResult.VerificationResultType {
case trustedresources.VerificationError:
err = fmt.Errorf("PipelineRun %s/%s referred resource %s failed signature verification: %w", pr.Namespace, pr.Name, resourceName, verificationResult.Err)
err = fmt.Errorf("pipelineRun %s/%s referred resource %s failed signature verification: %w", pr.Namespace, pr.Name, resourceName, verificationResult.Err)
condition = &apis.Condition{
Type: trustedresources.ConditionTrustedResourcesVerified,
Status: corev1.ConditionFalse,
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/pipelinerun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ spec:
permanentError: true,
wantEvents: []string{
"Normal Started",
"Warning Failed PipelineRun foo/pipeline-missing-object-param-keys parameters is missing object keys required by Pipeline foo/a-pipeline-with-object-params's parameters: PipelineRun missing object keys for parameters",
"Warning Failed PipelineRun foo/pipeline-missing-object-param-keys parameters is missing object keys required by Pipeline foo/a-pipeline-with-object-params's parameters: pipelineRun missing object keys for parameters",
},
}, {
name: "invalid-pipeline-array-index-out-of-bound",
Expand Down Expand Up @@ -12264,7 +12264,7 @@ spec:
wantEvents :=
[]string{
"Normal Started",
"Warning Failed PipelineRun foo/pr can't be Run; couldn't resolve all references: Array Result Index 3 for Task pt-with-result Result platforms is out of bound of size 3",
"Warning Failed PipelineRun foo/pr can't be Run; couldn't resolve all references: array Result Index 3 for Task pt-with-result Result platforms is out of bound of size 3",
"Warning InternalError 1 error occurred:",
}
prt := newPipelineRunTest(t, d)
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconciler/pipelinerun/resources/pipelineref.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type LocalPipelineRefResolver struct {
func (l *LocalPipelineRefResolver) GetPipeline(ctx context.Context, name string) (*v1.Pipeline, *v1.RefSource, *trustedresources.VerificationResult, error) {
// If we are going to resolve this reference locally, we need a namespace scope.
if l.Namespace == "" {
return nil, nil, nil, fmt.Errorf("Must specify namespace to resolve reference to pipeline %s", name)
return nil, nil, nil, fmt.Errorf("must specify namespace to resolve reference to pipeline %s", name)
}

pipeline, err := l.Tektonclient.TektonV1().Pipelines(l.Namespace).Get(ctx, name, metav1.GetOptions{})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func ValidateTaskRunSpecs(p *v1.PipelineSpec, pr *v1.PipelineRun) error {

for _, taskrunSpec := range pr.Spec.TaskRunSpecs {
if _, ok := pipelineTasks[taskrunSpec.PipelineTaskName]; !ok {
return fmt.Errorf("PipelineRun's taskrunSpecs defined wrong taskName: %q, does not exist in Pipeline", taskrunSpec.PipelineTaskName)
return fmt.Errorf("pipelineRun's taskrunSpecs defined wrong taskName: %q, does not exist in Pipeline", taskrunSpec.PipelineTaskName)
}
}
return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func validateArrayResultsIndex(allResolvedResultRefs ResolvedResultRefs) error {
for _, r := range allResolvedResultRefs {
if r.Value.Type == v1.ParamTypeArray {
if r.ResultReference.ResultsIndex >= len(r.Value.ArrayVal) {
return fmt.Errorf("Array Result Index %d for Task %s Result %s is out of bound of size %d", r.ResultReference.ResultsIndex, r.ResultReference.PipelineTask, r.ResultReference.Result, len(r.Value.ArrayVal))
return fmt.Errorf("array Result Index %d for Task %s Result %s is out of bound of size %d", r.ResultReference.ResultsIndex, r.ResultReference.PipelineTask, r.ResultReference.Result, len(r.Value.ArrayVal))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ func TestValidateArrayResultsIndex(t *testing.T) {
},
FromTaskRun: "aTaskRun",
}},
wantErr: "Array Result Index 1 for Task aTask Result aResult is out of bound of size 0",
wantErr: "array Result Index 1 for Task aTask Result aResult is out of bound of size 0",
}, {
name: "In Bounds Array",
refs: ResolvedResultRefs{{
Expand Down Expand Up @@ -787,7 +787,7 @@ func TestValidateArrayResultsIndex(t *testing.T) {
},
FromTaskRun: "aTaskRun",
}},
wantErr: "Array Result Index 3 for Task aTask Result aResult is out of bound of size 3",
wantErr: "array Result Index 3 for Task aTask Result aResult is out of bound of size 3",
}, {
name: "In Bounds and Out of Bounds Array",
refs: ResolvedResultRefs{{
Expand All @@ -813,7 +813,7 @@ func TestValidateArrayResultsIndex(t *testing.T) {
},
FromTaskRun: "aTaskRun",
}},
wantErr: "Array Result Index 3 for Task aTask Result aResult is out of bound of size 3",
wantErr: "array Result Index 3 for Task aTask Result aResult is out of bound of size 3",
}} {
t.Run(tt.name, func(t *testing.T) {
err := validateArrayResultsIndex(tt.refs)
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/resources/validate_params.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func ValidateRequiredParametersProvided(pipelineParameters *v1.ParamSpecs, pipel

// Return an error with the missing parameters' names, or return nil if there are none.
if len(missingParams) != 0 {
return fmt.Errorf("PipelineRun missing parameters: %s", missingParams)
return fmt.Errorf("pipelineRun missing parameters: %s", missingParams)
}
return nil
}
Expand All @@ -80,7 +80,7 @@ func ValidateRequiredParametersProvided(pipelineParameters *v1.ParamSpecs, pipel
func ValidateObjectParamRequiredKeys(pipelineParameters []v1.ParamSpec, pipelineRunParameters []v1.Param) error {
missings := taskrun.MissingKeysObjectParamNames(pipelineParameters, pipelineRunParameters)
if len(missings) != 0 {
return fmt.Errorf("PipelineRun missing object keys for parameters: %v", missings)
return fmt.Errorf("pipelineRun missing object keys for parameters: %v", missings)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/pipelinerun/timeout.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func timeoutPipelineTasksForTaskNames(ctx context.Context, logger *zap.SugaredLo
logger.Infof("cancelling TaskRun %s for timeout", taskRunName)

if _, err := clientSet.TektonV1().TaskRuns(pr.Namespace).Patch(ctx, taskRunName, types.JSONPatchType, timeoutTaskRunPatchBytes, metav1.PatchOptions{}, ""); err != nil {
errs = append(errs, fmt.Errorf("Failed to patch TaskRun `%s` with cancellation: %w", taskRunName, err).Error())
errs = append(errs, fmt.Errorf("failed to patch TaskRun `%s` with cancellation: %w", taskRunName, err).Error())
continue
}
}
Expand All @@ -122,7 +122,7 @@ func timeoutPipelineTasksForTaskNames(ctx context.Context, logger *zap.SugaredLo
logger.Infof("cancelling CustomRun %s for timeout", custonRunName)

if err := timeoutCustomRun(ctx, custonRunName, pr.Namespace, clientSet); err != nil {
errs = append(errs, fmt.Errorf("Failed to patch CustomRun `%s` with cancellation: %w", custonRunName, err).Error())
errs = append(errs, fmt.Errorf("failed to patch CustomRun `%s` with cancellation: %w", custonRunName, err).Error())
continue
}
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/reconciler/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1660,14 +1660,14 @@ status:
- reason: ToBeRetried
status: Unknown
type: Succeeded
message: "Provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\""
message: "provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\""
sideCars:
retriesStatus:
- conditions:
- reason: TaskRunValidationFailed
status: "False"
type: "Succeeded"
message: "Provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\""
message: "provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\""
startTime: "2021-12-31T23:59:59Z"
completionTime: "2022-01-01T00:00:00Z"
podName: "test-taskrun-results-type-mismatched-pod"
Expand Down Expand Up @@ -1696,7 +1696,7 @@ status:
MaxResultSize: 4096
Coschedule: "workspaces"
`)
reconciliatonError = fmt.Errorf("1 error occurred:\n\t* Provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\"")
reconciliatonError = fmt.Errorf("1 error occurred:\n\t* provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\"")
toBeRetriedTaskRun = parse.MustParseV1TaskRun(t, `
metadata:
name: test-taskrun-to-be-retried
Expand Down Expand Up @@ -5140,7 +5140,7 @@ status:
name: "taskrun results type mismatched",
taskRun: taskRunResultsTypeMismatched,
wantFailedReason: podconvert.ReasonFailedValidation,
expectedError: fmt.Errorf("1 error occurred:\n\t* Provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\", \"objectResult\": task result is expected to be \"object\" type but was initialized to a different type \"string\""),
expectedError: fmt.Errorf("1 error occurred:\n\t* provided results don't match declared results; may be invalid JSON or missing result declaration: \"aResult\": task result is expected to be \"array\" type but was initialized to a different type \"string\", \"objectResult\": task result is expected to be \"object\" type but was initialized to a different type \"string\""),
expectedResults: nil,
}, {
name: "taskrun results object miss key",
Expand Down
6 changes: 3 additions & 3 deletions pkg/reconciler/taskrun/validate_taskrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,13 @@ func validateTaskSpecRequestResources(taskSpec *v1.TaskSpec) error {
// First validate the limit in step
if limit, ok := step.ComputeResources.Limits[k]; ok {
if (&limit).Cmp(request) == -1 {
return fmt.Errorf("Invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String())
return fmt.Errorf("invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String())
}
} else if taskSpec.StepTemplate != nil {
// If step doesn't configure the limit, validate the limit in stepTemplate
if limit, ok := taskSpec.StepTemplate.ComputeResources.Limits[k]; ok {
if (&limit).Cmp(request) == -1 {
return fmt.Errorf("Invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String())
return fmt.Errorf("invalid request resource value: %v must be less or equal to limit %v", request.String(), limit.String())
}
}
}
Expand Down Expand Up @@ -251,7 +251,7 @@ func validateTaskRunResults(tr *v1.TaskRun, resolvedTaskSpec *v1.TaskSpec) error
s = append(s, fmt.Sprintf(" \"%v\": %v", k, v))
}
sort.Strings(s)
return fmt.Errorf("Provided results don't match declared results; may be invalid JSON or missing result declaration: %v", strings.Join(s, ","))
return fmt.Errorf("provided results don't match declared results; may be invalid JSON or missing result declaration: %v", strings.Join(s, ","))
}

// When get the results, for object value need to check if they have missing keys.
Expand Down

0 comments on commit 7039282

Please sign in to comment.