Skip to content

Commit

Permalink
chore(lint): fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
squakez committed May 19, 2023
1 parent 36f74b1 commit fbe85cf
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 30 deletions.
35 changes: 18 additions & 17 deletions pkg/controller/build/monitor_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,37 +301,38 @@ func (action *monitorPodAction) getTerminatedTime(pod *corev1.Pod) metav1.Time {
return finishedAt
}

// setConditionsFromTerminationMessages sets a condition for all those containers which have been terminated (successfully or not)
// setConditionsFromTerminationMessages sets a condition for all those containers which have been terminated (successfully or not).
func (action *monitorPodAction) setConditionsFromTerminationMessages(ctx context.Context, pod *corev1.Pod, buildStatus *v1.BuildStatus) {
var containers []corev1.ContainerStatus
containers = append(containers, pod.Status.InitContainerStatuses...)
containers = append(containers, pod.Status.ContainerStatuses...)

for _, container := range containers {
if t := container.State.Terminated; t != nil {
var err error
terminationMessage := t.Message
// Dynamic condition type (it depends on each container name)
containerConditionType := v1.BuildConditionType(fmt.Sprintf("Container %s succeeded", container.Name))
containerSucceeded := corev1.ConditionTrue
if t.ExitCode != 0 {
containerSucceeded = corev1.ConditionFalse
}

var maxLines int64
// TODO we can make it a user variable !?
maxLines = 10
logOptions := corev1.PodLogOptions{
Container: container.Name,
TailLines: &maxLines,
}
terminationMessage, err := log.DumpLog(ctx, action.client, pod, logOptions)
if err != nil {
action.L.Errorf(err, "Dumping log for %s container in %s Pod failed", container.Name, pod.Name)
terminationMessage = fmt.Sprintf(
"Operator was not able to retrieve the error message, please, check the container %s log directly from %s Pod",
container.Name,
pod.Name,
)
if terminationMessage == "" {
// TODO we can make it a user variable !?
var maxLines int64 = 10
logOptions := corev1.PodLogOptions{
Container: container.Name,
TailLines: &maxLines,
}
terminationMessage, err = log.DumpLog(ctx, action.client, pod, logOptions)
if err != nil {
action.L.Errorf(err, "Dumping log for %s container in %s Pod failed", container.Name, pod.Name)
terminationMessage = fmt.Sprintf(
"Operator was not able to retrieve the error message, please, check the container %s log directly from %s Pod",
container.Name,
pod.Name,
)
}
}

terminationReason := fmt.Sprintf("%s (%d)", t.Reason, t.ExitCode)
Expand Down
8 changes: 4 additions & 4 deletions pkg/trait/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,19 @@ func getImageName(e *Environment) string {
}

func (t *builderTrait) customTasks() []v1.Task {
var customTasks []v1.Task
for _, t := range t.Tasks {
customTasks := make([]v1.Task, 0, len(t.Tasks))
for i, t := range t.Tasks {
// TODO, better strategy than a simple split!
splitted := strings.Split(t, ";")
customTasks = append(customTasks, v1.Task{
customTasks[i] = v1.Task{
Custom: &v1.UserTask{
BaseTask: v1.BaseTask{
Name: splitted[0],
},
ContainerImage: splitted[1],
ContainerCommand: splitted[2],
},
})
}
}
return customTasks
}
9 changes: 0 additions & 9 deletions pkg/trait/quarkus.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,6 @@ func (t *quarkusTrait) isNativeKit(e *Environment) (bool, error) {
}
}

func (t *quarkusTrait) hasKitNativeType() bool {
for _, v := range t.PackageTypes {
if v == traitv1.NativePackageType {
return true
}
}
return false
}

func (t *quarkusTrait) applyWhenKitReady(e *Environment) error {
if e.IntegrationInRunningPhases() && t.isNativeIntegration(e) {
container := e.GetIntegrationContainer()
Expand Down

0 comments on commit fbe85cf

Please sign in to comment.