mirror of
https://github.com/tiennm99/coolify.git
synced 2026-04-20 05:20:56 +00:00
feat(proxy): enhance Traefik version notifications to show patch and minor upgrades
- Store both patch update and newer minor version information simultaneously - Display patch update availability alongside minor version upgrades in notifications - Add newer_branch_target and newer_branch_latest fields to traefik_outdated_info - Update all notification channels (Discord, Telegram, Slack, Pushover, Email, Webhook) - Show minor version in format (e.g., v3.6) for upgrade targets instead of patch version - Enhance UI callouts with clearer messaging about available upgrades - Remove verbose logging in favor of cleaner code structure - Handle edge case where SSH command returns empty response 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -11,7 +11,6 @@ use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class NotifyOutdatedTraefikServersJob implements ShouldQueue
|
||||
{
|
||||
@@ -32,67 +31,38 @@ class NotifyOutdatedTraefikServersJob implements ShouldQueue
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
try {
|
||||
Log::info('NotifyOutdatedTraefikServersJob: Starting notification aggregation');
|
||||
// Query servers that have outdated info stored
|
||||
$servers = Server::whereNotNull('proxy')
|
||||
->whereProxyType(ProxyTypes::TRAEFIK->value)
|
||||
->whereRelation('settings', 'is_reachable', true)
|
||||
->whereRelation('settings', 'is_usable', true)
|
||||
->get();
|
||||
|
||||
// Query servers that have outdated info stored
|
||||
$servers = Server::whereNotNull('proxy')
|
||||
->whereProxyType(ProxyTypes::TRAEFIK->value)
|
||||
->whereRelation('settings', 'is_reachable', true)
|
||||
->whereRelation('settings', 'is_usable', true)
|
||||
->get();
|
||||
$outdatedServers = collect();
|
||||
|
||||
$outdatedServers = collect();
|
||||
foreach ($servers as $server) {
|
||||
if ($server->traefik_outdated_info) {
|
||||
// Attach the outdated info as a dynamic property for the notification
|
||||
$server->outdatedInfo = $server->traefik_outdated_info;
|
||||
$outdatedServers->push($server);
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($servers as $server) {
|
||||
$outdatedInfo = $server->extra_attributes->get('traefik_outdated_info');
|
||||
if ($outdatedServers->isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($outdatedInfo) {
|
||||
// Attach the outdated info as a dynamic property for the notification
|
||||
$server->outdatedInfo = $outdatedInfo;
|
||||
$outdatedServers->push($server);
|
||||
}
|
||||
// Group by team and send notifications
|
||||
$serversByTeam = $outdatedServers->groupBy('team_id');
|
||||
|
||||
foreach ($serversByTeam as $teamId => $teamServers) {
|
||||
$team = Team::find($teamId);
|
||||
if (! $team) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$outdatedCount = $outdatedServers->count();
|
||||
Log::info("NotifyOutdatedTraefikServersJob: Found {$outdatedCount} outdated server(s)");
|
||||
|
||||
if ($outdatedCount === 0) {
|
||||
Log::info('NotifyOutdatedTraefikServersJob: No outdated servers found, no notifications to send');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Group by team and send notifications
|
||||
$serversByTeam = $outdatedServers->groupBy('team_id');
|
||||
$teamCount = $serversByTeam->count();
|
||||
|
||||
Log::info("NotifyOutdatedTraefikServersJob: Grouped outdated servers into {$teamCount} team(s)");
|
||||
|
||||
foreach ($serversByTeam as $teamId => $teamServers) {
|
||||
$team = Team::find($teamId);
|
||||
if (! $team) {
|
||||
Log::warning("NotifyOutdatedTraefikServersJob: Team ID {$teamId} not found, skipping");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$serverNames = $teamServers->pluck('name')->join(', ');
|
||||
Log::info("NotifyOutdatedTraefikServersJob: Sending notification to team '{$team->name}' for {$teamServers->count()} server(s): {$serverNames}");
|
||||
|
||||
// Send one notification per team with all outdated servers
|
||||
$team->notify(new TraefikVersionOutdated($teamServers));
|
||||
|
||||
Log::info("NotifyOutdatedTraefikServersJob: Notification sent to team '{$team->name}'");
|
||||
}
|
||||
|
||||
Log::info('NotifyOutdatedTraefikServersJob: Job completed successfully');
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('NotifyOutdatedTraefikServersJob: Error sending notifications: '.$e->getMessage(), [
|
||||
'exception' => $e,
|
||||
'trace' => $e->getTraceAsString(),
|
||||
]);
|
||||
throw $e;
|
||||
// Send one notification per team with all outdated servers
|
||||
$team->notify(new TraefikVersionOutdated($teamServers));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user