Skip to content

Commit

Permalink
Implement the flow the agent that we don't send the updates over to c…
Browse files Browse the repository at this point in the history
…onsole.dot

Signed-off-by: Aviel Segev <[email protected]>
  • Loading branch information
AvielSegev committed Feb 3, 2025
1 parent 0e965ed commit 9cee781
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 38 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ components:
type: string
status:
type: string
enum: [not-connected, waiting-for-credentials, error, gathering-initial-inventory, up-to-date, source-gone]
enum: [not-connected, not-connected-to-service, waiting-for-credentials, error, gathering-initial-inventory, up-to-date, source-gone]
statusInfo:
type: string
credentialUrl:
Expand Down
64 changes: 32 additions & 32 deletions api/v1alpha1/spec.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions api/v1alpha1/types.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ func (a *Agent) start(ctx context.Context, plannerClient client.Planner) {

// TODO refactor health checker to call it from the main goroutine
healthChecker.Start(ctx, a.healtCheckStopCh)
statusUpdater.HealthChecker = healthChecker

collector := service.NewCollector(a.config.DataDir)
collector.Collect(ctx)
Expand Down
16 changes: 11 additions & 5 deletions internal/agent/service/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ const (
)

type StatusUpdater struct {
agentID uuid.UUID
version string
config *config.Config
client client.Planner
credUrl string
agentID uuid.UUID
version string
config *config.Config
client client.Planner
credUrl string
HealthChecker *HealthChecker
}

func NewStatusUpdater(agentID uuid.UUID, version, credUrl string, config *config.Config, client client.Planner) *StatusUpdater {
Expand Down Expand Up @@ -77,5 +78,10 @@ func (s *StatusUpdater) CalculateStatus() (api.AgentStatus, string, *api.Invento
if len(inventory.Error) > 0 {
return api.AgentStatusError, inventory.Error, &inventory.Inventory
}

if s.HealthChecker != nil && s.HealthChecker.State() == HealthCheckStateConsoleUnreachable {
return api.AgentStatusNotConnectedToService, "Migration Planner service is unreachable", &inventory.Inventory
}

return api.AgentStatusUpToDate, "Inventory successfully collected", &inventory.Inventory
}

0 comments on commit 9cee781

Please sign in to comment.