Skip to content

Commit

Permalink
Merge pull request #95 from uselagoon/cluster-meta-log
Browse files Browse the repository at this point in the history
feat: add cluster to log meta
  • Loading branch information
shreddedbacon authored Dec 22, 2021
2 parents 8635699 + a4c7615 commit 812e59d
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions api/v1alpha1/lagoonmessaging_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type LagoonLogMeta struct {
Task *LagoonTaskInfo `json:"task,omitempty"`
Key string `json:"key,omitempty"`
AdvancedData string `json:"advancedData,omitempty"`
Cluster string `json:"clusterName,omitempty"`
}

// LagoonMessage is used for sending build info back to Lagoon
Expand Down
1 change: 1 addition & 0 deletions controllers/lagoonbuild_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type LagoonBuildReconciler struct {
LFFQoSEnabled bool
BuildQoS BuildQoS
NativeCronPodMinFrequency int
LagoonTargetName string
}

// +kubebuilder:rbac:groups=lagoon.amazee.io,resources=lagoonbuilds,verbs=get;list;watch;create;update;patch;delete
Expand Down
3 changes: 3 additions & 0 deletions controllers/lagoonbuild_deletionhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ func (r *LagoonBuildReconciler) cancelledBuildLogsToLagoonLogs(ctx context.Conte
BuildPhase: condition,
RemoteID: string(lagoonBuild.ObjectMeta.UID),
LogLink: lagoonBuild.Spec.Project.UILink,
Cluster: r.LagoonTargetName,
},
}
// add the actual build log message
Expand Down Expand Up @@ -285,6 +286,7 @@ func (r *LagoonBuildReconciler) updateCancelledDeploymentAndEnvironmentTask(ctx
BuildName: lagoonBuild.ObjectMeta.Name,
LogLink: lagoonBuild.Spec.Project.UILink,
RemoteID: string(lagoonBuild.ObjectMeta.UID),
Cluster: r.LagoonTargetName,
},
}
labelRequirements1, _ := labels.NewRequirement("lagoon.sh/service", selection.NotIn, []string{"faketest"})
Expand Down Expand Up @@ -366,6 +368,7 @@ func (r *LagoonBuildReconciler) cancelledBuildStatusLogsToLagoonLogs(ctx context
BuildPhase: condition,
BuildName: lagoonBuild.ObjectMeta.Name,
LogLink: lagoonBuild.Spec.Project.UILink,
Cluster: r.LagoonTargetName,
},
Message: fmt.Sprintf("*[%s]* %s Build `%s` %s",
lagoonBuild.Spec.Project.Name,
Expand Down
3 changes: 3 additions & 0 deletions controllers/lagoonmonitor_buildhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ func (r *LagoonMonitorReconciler) buildLogsToLagoonLogs(ctx context.Context,
BuildPhase: condition,
RemoteID: string(jobPod.ObjectMeta.UID),
LogLink: lagoonBuild.Spec.Project.UILink,
Cluster: r.LagoonTargetName,
},
}
// add the actual build log message
Expand Down Expand Up @@ -233,6 +234,7 @@ func (r *LagoonMonitorReconciler) updateDeploymentAndEnvironmentTask(ctx context
BuildName: lagoonBuild.ObjectMeta.Name,
LogLink: lagoonBuild.Spec.Project.UILink,
RemoteID: string(jobPod.ObjectMeta.UID),
Cluster: r.LagoonTargetName,
},
}
labelRequirements1, _ := labels.NewRequirement("lagoon.sh/service", selection.NotIn, []string{"faketest"})
Expand Down Expand Up @@ -340,6 +342,7 @@ func (r *LagoonMonitorReconciler) buildStatusLogsToLagoonLogs(ctx context.Contex
BuildPhase: condition,
BuildName: lagoonBuild.ObjectMeta.Name,
LogLink: lagoonBuild.Spec.Project.UILink,
Cluster: r.LagoonTargetName,
},
}
// if we aren't being provided the lagoon config, we can skip adding the routes etc
Expand Down
1 change: 1 addition & 0 deletions controllers/lagoonmonitor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type LagoonMonitorReconciler struct {
Messaging *handlers.Messaging
ControllerNamespace string
EnableDebug bool
LagoonTargetName string
}

// slice of the different failure states of pods that we care about
Expand Down
3 changes: 3 additions & 0 deletions controllers/lagoonmonitor_taskhandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (r *LagoonMonitorReconciler) taskLogsToLagoonLogs(opLog logr.Logger,
JobStatus: condition,
RemoteID: string(jobPod.ObjectMeta.UID),
Key: lagoonTask.Spec.Key,
Cluster: r.LagoonTargetName,
},
Message: fmt.Sprintf(`========================================
Logs on pod %s
Expand Down Expand Up @@ -208,6 +209,7 @@ func (r *LagoonMonitorReconciler) updateLagoonTask(opLog logr.Logger,
JobStatus: condition,
RemoteID: string(jobPod.ObjectMeta.UID),
Key: lagoonTask.Spec.Key,
Cluster: r.LagoonTargetName,
},
}
if _, ok := jobPod.ObjectMeta.Annotations["lagoon.sh/taskData"]; ok {
Expand Down Expand Up @@ -272,6 +274,7 @@ func (r *LagoonMonitorReconciler) taskStatusLogsToLagoonLogs(opLog logr.Logger,
JobStatus: condition,
RemoteID: string(jobPod.ObjectMeta.UID),
Key: lagoonTask.Spec.Key,
Cluster: r.LagoonTargetName,
},
Message: fmt.Sprintf("*[%s]* Task `%s` *%s* %s",
lagoonTask.Spec.Project.Name,
Expand Down
1 change: 1 addition & 0 deletions controllers/lagoontask_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type LagoonTaskReconciler struct {
ControllerNamespace string
TaskSettings LagoonTaskSettings
EnableDebug bool
LagoonTargetName string
}

// LagoonTaskSettings is for the settings for task API/SSH host/ports
Expand Down
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ func main() {
LFFQoSEnabled: lffQoSEnabled,
BuildQoS: buildQoSConfig,
NativeCronPodMinFrequency: nativeCronPodMinFrequency,
LagoonTargetName: lagoonTargetName,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "LagoonBuild")
os.Exit(1)
Expand All @@ -633,6 +634,7 @@ func main() {
Messaging: messaging,
ControllerNamespace: controllerNamespace,
EnableDebug: enableDebug,
LagoonTargetName: lagoonTargetName,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "LagoonMonitor")
os.Exit(1)
Expand All @@ -648,7 +650,8 @@ func main() {
SSHHost: lagoonSSHHost,
SSHPort: lagoonSSHPort,
},
EnableDebug: enableDebug,
EnableDebug: enableDebug,
LagoonTargetName: lagoonTargetName,
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "LagoonTask")
os.Exit(1)
Expand Down

0 comments on commit 812e59d

Please sign in to comment.