mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
[ArangoSync] Don't serialize and deprecate two DeploymentReplicationStatus fields (#1172)
Co-authored-by: Adam Janikowski <12255597+ajanikow@users.noreply.github.com>
This commit is contained in:
parent
c8248deae2
commit
3932750892
12 changed files with 17 additions and 78 deletions
|
@ -20,6 +20,7 @@
|
|||
- (Bugfix) Move Agency CommitIndex log message to Trace
|
||||
- (Feature) Force delete Pods which are stuck in init phase
|
||||
- (Bugfix) Do not tolerate False Bootstrap condition in UpToDate evaluation
|
||||
- (Improvement) Don't serialize and deprecate two DeploymentReplicationStatus fields
|
||||
|
||||
## [1.2.20](https://github.com/arangodb/kube-arangodb/tree/1.2.20) (2022-10-25)
|
||||
- (Feature) Add action progress
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package v1
|
||||
|
||||
// CollectionStatus contains the status of a single collection.
|
||||
// Deprecated
|
||||
type CollectionStatus struct {
|
||||
// Name of the collection
|
||||
Name string `json:"name"`
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package v1
|
||||
|
||||
// DatabaseStatus contains the status of a single database.
|
||||
// Deprecated
|
||||
type DatabaseStatus struct {
|
||||
// Name of the database
|
||||
Name string `json:"name"`
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package v1
|
||||
|
||||
// EndpointStatus contains the status of either the source or destination endpoint.
|
||||
// Deprecated
|
||||
type EndpointStatus struct {
|
||||
// Databases holds the replication status of all databases from the point of view of this endpoint.
|
||||
// List is ordered by name of the database.
|
||||
|
|
|
@ -31,8 +31,11 @@ type DeploymentReplicationStatus struct {
|
|||
// Conditions specific to the entire deployment replication
|
||||
Conditions ConditionList `json:"conditions,omitempty"`
|
||||
|
||||
// Deprecated: this field will be removed in future versions
|
||||
// Source contains the detailed status of the source endpoint
|
||||
Source EndpointStatus `json:"source"`
|
||||
|
||||
// Deprecated: this field will be removed in future versions
|
||||
// Destination contains the detailed status of the destination endpoint
|
||||
Destination EndpointStatus `json:"destination"`
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package v1
|
||||
|
||||
// ShardStatus contains the status of a single shard.
|
||||
// Deprecated
|
||||
type ShardStatus struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package v2alpha1
|
||||
|
||||
// CollectionStatus contains the status of a single collection.
|
||||
// Deprecated
|
||||
type CollectionStatus struct {
|
||||
// Name of the collection
|
||||
Name string `json:"name"`
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package v2alpha1
|
||||
|
||||
// DatabaseStatus contains the status of a single database.
|
||||
// Deprecated
|
||||
type DatabaseStatus struct {
|
||||
// Name of the database
|
||||
Name string `json:"name"`
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package v2alpha1
|
||||
|
||||
// EndpointStatus contains the status of either the source or destination endpoint.
|
||||
// Deprecated
|
||||
type EndpointStatus struct {
|
||||
// Databases holds the replication status of all databases from the point of view of this endpoint.
|
||||
// List is ordered by name of the database.
|
||||
|
|
|
@ -31,8 +31,11 @@ type DeploymentReplicationStatus struct {
|
|||
// Conditions specific to the entire deployment replication
|
||||
Conditions ConditionList `json:"conditions,omitempty"`
|
||||
|
||||
// Deprecated: this field will be removed in future versions
|
||||
// Source contains the detailed status of the source endpoint
|
||||
Source EndpointStatus `json:"source"`
|
||||
|
||||
// Deprecated: this field will be removed in future versions
|
||||
// Destination contains the detailed status of the destination endpoint
|
||||
Destination EndpointStatus `json:"destination"`
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
package v2alpha1
|
||||
|
||||
// ShardStatus contains the status of a single shard.
|
||||
// Deprecated
|
||||
type ShardStatus struct {
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ package replication
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/arangodb/arangosync-client/client"
|
||||
|
@ -107,10 +106,8 @@ func (dr *DeploymentReplication) inspectDeploymentReplication(lastInterval time.
|
|||
} else {
|
||||
if isIncomingEndpoint {
|
||||
// Destination is correctly configured
|
||||
|
||||
dr.status.Conditions.Update(api.ConditionTypeConfigured, true, api.ConditionConfiguredReasonActive,
|
||||
"Destination syncmaster is configured correctly and active")
|
||||
dr.status.Destination = createEndpointStatus(destStatus, "")
|
||||
dr.status.IncomingSynchronization = dr.inspectIncomingSynchronizationStatus(ctx, destClient,
|
||||
driver.Version(destArangosyncVersion.Version), destStatus.Shards)
|
||||
updateStatusNeeded = true
|
||||
|
@ -145,15 +142,10 @@ func (dr *DeploymentReplication) inspectDeploymentReplication(lastInterval time.
|
|||
}
|
||||
|
||||
//if sourceStatus.Status.IsActive() {
|
||||
outgoingID, hasOutgoingEndpoint, err := dr.hasOutgoingEndpoint(sourceStatus, spec.Destination, destEndpoint)
|
||||
_, hasOutgoingEndpoint, err := dr.hasOutgoingEndpoint(sourceStatus, spec.Destination, destEndpoint)
|
||||
if err != nil {
|
||||
dr.log.Err(err).Warn("Failed to check has-outgoing-endpoint")
|
||||
} else if hasOutgoingEndpoint {
|
||||
// Destination is know in source
|
||||
// Fetch shard status
|
||||
dr.status.Source = createEndpointStatus(sourceStatus, outgoingID)
|
||||
updateStatusNeeded = true
|
||||
} else {
|
||||
} else if !hasOutgoingEndpoint {
|
||||
// We cannot find the destination in the source status
|
||||
dr.log.Err(err).Info("Destination not yet known in source syncmasters")
|
||||
}
|
||||
|
@ -345,71 +337,3 @@ func (dr *DeploymentReplication) createDatabaseSynchronizationStatus(dbSyncStatu
|
|||
Errors: errs,
|
||||
}
|
||||
}
|
||||
|
||||
// createEndpointStatus creates an api EndpointStatus from the given sync status.
|
||||
func createEndpointStatus(status client.SyncInfo, outgoingID string) api.EndpointStatus {
|
||||
result := api.EndpointStatus{}
|
||||
if outgoingID == "" {
|
||||
return createEndpointStatusFromShards(status.Shards)
|
||||
}
|
||||
for _, o := range status.Outgoing {
|
||||
if o.ID != outgoingID {
|
||||
continue
|
||||
}
|
||||
return createEndpointStatusFromShards(o.Shards)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
// createEndpointStatusFromShards creates an api EndpointStatus from the given list of shard statuses.
|
||||
func createEndpointStatusFromShards(shards []client.ShardSyncInfo) api.EndpointStatus {
|
||||
result := api.EndpointStatus{}
|
||||
|
||||
getDatabase := func(name string) *api.DatabaseStatus {
|
||||
for i, d := range result.Databases {
|
||||
if d.Name == name {
|
||||
return &result.Databases[i]
|
||||
}
|
||||
}
|
||||
// Not found, add it
|
||||
result.Databases = append(result.Databases, api.DatabaseStatus{Name: name})
|
||||
return &result.Databases[len(result.Databases)-1]
|
||||
}
|
||||
|
||||
getCollection := func(db *api.DatabaseStatus, name string) *api.CollectionStatus {
|
||||
for i, c := range db.Collections {
|
||||
if c.Name == name {
|
||||
return &db.Collections[i]
|
||||
}
|
||||
}
|
||||
// Not found, add it
|
||||
db.Collections = append(db.Collections, api.CollectionStatus{Name: name})
|
||||
return &db.Collections[len(db.Collections)-1]
|
||||
}
|
||||
|
||||
// Sort shard by index
|
||||
sort.Slice(shards, func(i, j int) bool {
|
||||
return shards[i].ShardIndex < shards[j].ShardIndex
|
||||
})
|
||||
for _, s := range shards {
|
||||
db := getDatabase(s.Database)
|
||||
col := getCollection(db, s.Collection)
|
||||
|
||||
// Add "missing" shards if needed
|
||||
for len(col.Shards) < s.ShardIndex {
|
||||
col.Shards = append(col.Shards, api.ShardStatus{Status: ""})
|
||||
}
|
||||
|
||||
// Add current shard
|
||||
col.Shards = append(col.Shards, api.ShardStatus{Status: string(s.Status)})
|
||||
}
|
||||
|
||||
// Sort result
|
||||
sort.Slice(result.Databases, func(i, j int) bool { return result.Databases[i].Name < result.Databases[j].Name })
|
||||
for i, db := range result.Databases {
|
||||
sort.Slice(db.Collections, func(i, j int) bool { return db.Collections[i].Name < db.Collections[j].Name })
|
||||
result.Databases[i] = db
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue