Skip to content

Commit

Permalink
clustermesh: propagate synchronization info in remote cluster status
Browse files Browse the repository at this point in the history
Enrich the remote cluster status to additionally include information
concerning the synchronization status of each resource type. In
particular, a resource type is considered to be synchronized if the
initial list of entries has been completely received from the remote
cluster, and new events are currently being watched.

Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
  • Loading branch information
giorio94 authored and joestringer committed Jul 25, 2023
1 parent bc66a43 commit 5b34dd6
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 0 deletions.
46 changes: 46 additions & 0 deletions api/v1/models/remote_cluster.go

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

67 changes: 67 additions & 0 deletions api/v1/models/remote_cluster_synced.go

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

21 changes: 21 additions & 0 deletions api/v1/models/zz_generated.deepcopy.go

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

24 changes: 24 additions & 0 deletions api/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2379,6 +2379,9 @@ definitions:
ready:
description: Indicates readiness of the remote cluster
type: boolean
synced:
description: Synchronization status about each resource type
"$ref": "#/definitions/RemoteClusterSynced"
config:
description: Cluster configuration exposed by the remote cluster
"$ref": "#/definitions/RemoteClusterConfig"
Expand All @@ -2404,6 +2407,27 @@ definitions:
description: Time of last failure that occurred while attempting to reach the cluster
type: string
format: date-time
RemoteClusterSynced:
description: |-
Status of the synchronization with the remote cluster, about each resource
type. A given resource is considered to be synchronized if the initial
list of entries has been completely received from the remote cluster, and
new events are currently being watched.
+k8s:deepcopy-gen=true
properties:
nodes:
description: Nodes synchronization status
type: boolean
services:
description: Services synchronization status
type: boolean
endpoints:
description: Endpoints synchronization status
type: boolean
identities:
description: Identities synchronization status
type: boolean
RemoteClusterConfig:
description: |-
Cluster configuration exposed by the remote cluster
Expand Down
50 changes: 50 additions & 0 deletions api/v1/server/embedded_spec.go

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

5 changes: 5 additions & 0 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,11 @@ func FormatStatusResponse(w io.Writer, sr *models.StatusResponse, sd StatusDetai
fmt.Fprint(w, "expected=unknown, retrieved=unknown")
}
fmt.Fprint(w, "\n")

if cluster.Synced != nil {
fmt.Fprintf(w, " └ synchronization status: nodes=%v, endpoints=%v, identities=%v, services=%v\n",
cluster.Synced.Nodes, cluster.Synced.Endpoints, cluster.Synced.Identities, cluster.Synced.Services)
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions pkg/clustermesh/remote_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,14 @@ func (rc *remoteCluster) Status() *models.RemoteCluster {
status.NumSharedServices = int64(rc.remoteServices.NumEntries())
status.NumIdentities = int64(rc.remoteIdentityCache.NumEntries())
status.NumEndpoints = int64(rc.ipCacheWatcher.NumEntries())

status.Synced = &models.RemoteClusterSynced{
Nodes: rc.remoteNodes.Synced(),
Services: rc.remoteServices.Synced(),
Identities: rc.remoteIdentityCache.Synced(),
Endpoints: rc.ipCacheWatcher.Synced(),
}

return status
}

Expand Down

0 comments on commit 5b34dd6

Please sign in to comment.