Skip to content

Commit

Permalink
Entity: Rename TypeNode to TypeClusterMember (#14040)
Browse files Browse the repository at this point in the history
Updates `TypeNode` to `TypeClusterMember` and its value from `node` to
`cluster_member`.
This is done because the term node is inappropriate to be exposed to
users, and it will be when the API metrics are introduced.
As of now this type is not exposed to users so an API extension is not
needed.
  • Loading branch information
tomponline authored Sep 4, 2024
2 parents d87d604 + 044bb4a commit 5d0135e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions lxd/cluster/heartbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func (hbState *APIHeartbeat) Send(ctx context.Context, networkCert *shared.CertI
heartbeatData.Unlock()
logger.Debug("Successful heartbeat", logger.Ctx{"remote": address})

err = warnings.ResolveWarningsByLocalNodeAndProjectAndTypeAndEntity(hbState.cluster, "", warningtype.OfflineClusterMember, entity.TypeNode, int(nodeID))
err = warnings.ResolveWarningsByLocalNodeAndProjectAndTypeAndEntity(hbState.cluster, "", warningtype.OfflineClusterMember, entity.TypeClusterMember, int(nodeID))
if err != nil {
logger.Warn("Failed to resolve warning", logger.Ctx{"err": err})
}
Expand All @@ -187,7 +187,7 @@ func (hbState *APIHeartbeat) Send(ctx context.Context, networkCert *shared.CertI

if ctx.Err() == nil {
err = hbState.cluster.Transaction(context.TODO(), func(ctx context.Context, tx *db.ClusterTx) error {
return tx.UpsertWarningLocalNode(ctx, "", entity.TypeNode, int(nodeID), warningtype.OfflineClusterMember, err.Error())
return tx.UpsertWarningLocalNode(ctx, "", entity.TypeClusterMember, int(nodeID), warningtype.OfflineClusterMember, err.Error())
})
if err != nil {
logger.Warn("Failed to create warning", logger.Ctx{"err": err})
Expand Down Expand Up @@ -557,7 +557,7 @@ func HeartbeatNode(taskCtx context.Context, address string, networkCert *shared.
defer func() { _ = response.Body.Close() }()

if response.StatusCode != http.StatusOK {
return fmt.Errorf("Heartbeat request failed with status: %w", api.StatusErrorf(response.StatusCode, response.Status))
return fmt.Errorf("Heartbeat request failed with status: %w", api.NewStatusError(response.StatusCode, response.Status))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion lxd/db/cluster/entities.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var entityTypes = map[entity.Type]entityTypeDBInfo{
entity.TypeInstanceSnapshot: entityTypeInstanceSnapshot{},
entity.TypeNetwork: entityTypeNetwork{},
entity.TypeNetworkACL: entityTypeNetworkACL{},
entity.TypeNode: entityTypeClusterMember{},
entity.TypeClusterMember: entityTypeClusterMember{},
entity.TypeOperation: entityTypeOperation{},
entity.TypeStoragePool: entityTypeStoragePool{},
entity.TypeStorageVolume: entityTypeStorageVolume{},
Expand Down
6 changes: 3 additions & 3 deletions shared/entity/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ const (
// TypeNetworkACL represents network acl resources.
TypeNetworkACL Type = "network_acl"

// TypeNode represents node resources.
TypeNode Type = "node"
// TypeClusterMember represents node resources.
TypeClusterMember Type = "cluster_member"

// TypeOperation represents operation resources.
TypeOperation Type = "operation"
Expand Down Expand Up @@ -141,7 +141,7 @@ var entityTypes = map[Type]typeInfo{
TypeInstanceSnapshot: instanceSnapshot{},
TypeNetwork: network{},
TypeNetworkACL: networkACL{},
TypeNode: clusterMember{},
TypeClusterMember: clusterMember{},
TypeOperation: operation{},
TypeStoragePool: storagePool{},
TypeStorageVolume: storageVolume{},
Expand Down
2 changes: 1 addition & 1 deletion shared/entity/type_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func TestURL(t *testing.T) {
name: "cluster members",
rawURL: "/1.0/cluster/members/node01",
expectedNormalisedURL: "/1.0/cluster/members/node01",
expectedEntityType: TypeNode,
expectedEntityType: TypeClusterMember,
expectedProject: "",
expectedPathArgs: []string{"node01"},
expectedErr: nil,
Expand Down

0 comments on commit 5d0135e

Please sign in to comment.