Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 2 additions & 16 deletions internal/database/convert_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (

"github.com/Azure/ARO-HCP/internal/api"
"github.com/Azure/ARO-HCP/internal/api/arm"
"github.com/Azure/ARO-HCP/internal/ocm"
)

func InternalToCosmosNodePool(internalObj *api.HCPOpenShiftClusterNodePool) (*NodePool, error) {
Expand All @@ -40,6 +39,7 @@ func InternalToCosmosNodePool(internalObj *api.HCPOpenShiftClusterNodePool) (*No
ResourceType: internalObj.ID.ResourceType.String(),
},
NodePoolProperties: NodePoolProperties{
HCPOpenShiftClusterNodePool: *internalObj,
CosmosMetadata: api.CosmosMetadata{
ResourceID: internalObj.ID,
},
Expand All @@ -58,20 +58,6 @@ func InternalToCosmosNodePool(internalObj *api.HCPOpenShiftClusterNodePool) (*No
},
}

// some pieces of data in the internalNodePool conflict with ResourceDocument fields. We may evolve over time, but for
// now avoid persisting those.
cosmosObj.InternalState.InternalAPI.TrackedResource = arm.TrackedResource{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we removing this?

Location: internalObj.Location, // this is the only TrackedResource value not present elsewhere in ResourceDcoument
}
cosmosObj.InternalState.InternalAPI.Identity = nil
cosmosObj.InternalState.InternalAPI.Properties.ProvisioningState = ""
cosmosObj.InternalState.InternalAPI.SystemData = nil
cosmosObj.InternalState.InternalAPI.Tags = nil
// we do this to keep serialization the same so that we can go to n-1 where this field isn't a pointer.
// on the reading side, we handle the pointer as expected.
cosmosObj.InternalState.InternalAPI.ServiceProviderProperties.ClusterServiceID = &ocm.InternalID{}
cosmosObj.InternalState.InternalAPI.ServiceProviderProperties.ActiveOperationID = ""

return cosmosObj, nil
}

Expand Down Expand Up @@ -101,7 +87,7 @@ func CosmosToInternalNodePool(cosmosObj *NodePool) (*api.HCPOpenShiftClusterNode
// we carry over the CosmosETag from the cosmos object to the internal object into a
// temporary field until we have inlined and serialized CosmosMetadata in
// HCPOpenShiftClusterNodePool.
internalObj.CosmosETag = cosmosObj.CosmosETag
internalObj.CosmosETag = cosmosObj.BaseDocument.CosmosETag
internalObj.Identity = resourceDoc.Identity.DeepCopy()
internalObj.Properties.ProvisioningState = resourceDoc.ProvisioningState
internalObj.SystemData = resourceDoc.SystemData
Expand Down
8 changes: 7 additions & 1 deletion internal/database/types_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ type NodePool struct {
}

type NodePoolProperties struct {
// HCPOpenShiftClusterNodePool is where we're migrating to. It is compatible with a GenericDocument[api.HCPOpenShiftClusterNodePool]
// which is where we want to end up.
// * to be compatible with prior versions, we must continue writing all previous fields and this new field
// * to be compatible with prior versions, we must continue reading only from previous fields
api.HCPOpenShiftClusterNodePool `json:",inline"`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason it's a value and not a pointer?


// when we switch to inlining the internalObj, this will be in the right spot. We add it now so that we can switch our
// queries to select on cosmosMetata.ResourceID instead of resourceId
// queries to select on cosmosMetadata.ResourceID instead of resourceId
CosmosMetadata api.CosmosMetadata `json:"cosmosMetadata"`

// IntermediateResourceDoc exists so that we can stop inlining the resource document so that we can directly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"id": "b3b837bb-154f-5f52-8562-96a8c9d2bb05",
"partitionKey": "a433a095-1277-44f1-8453-8d61a4d848c2",
"properties": {
"id": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"intermediateResourceDoc": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"internalId": "/api/clusters_mgmt/v1/clusters/w9xhwccbjp/node_pools/k9xp9ghzh2",
Expand All @@ -21,7 +22,9 @@
},
"internalState": {
"internalAPI": {
"id": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"location": "fake-location",
"name": "basic",
"properties": {
"autoRepair": true,
"autoScaling": {
Expand All @@ -40,6 +43,7 @@
},
"vmSize": "large"
},
"provisioningState": "Accepted",
"taints": [
{
"effect": "NoExecute",
Expand All @@ -52,10 +56,61 @@
}
},
"serviceProviderProperties": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"clusterServiceID": ""
Comment thread
deads2k marked this conversation as resolved.
},
"systemData": {
"createdBy": "Unknown-ARO-HCP-frontend",
"createdByType": "Application",
"lastModifiedBy": "Unknown-ARO-HCP-frontend",
"lastModifiedByType": "Application"
},
"type": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
}
},
"location": "fake-location",
"name": "basic",
"properties": {
"autoRepair": true,
"autoScaling": {
"max": 5,
"min": 1
},
"labels": {
"label-ky": "label-value"
},
"nodeDrainTimeoutMinutes": 2,
"platform": {
"enableEncryptionAtHost": false,
"osDisk": {
"diskStorageAccountType": "Premium_LRS",
"sizeGiB": 64
},
"vmSize": "large"
},
"provisioningState": "Accepted",
"taints": [
{
"effect": "NoExecute",
"key": "foo.com/key",
"value": "valid"
}
],
"version": {
"channelGroup": "stable"
}
}
},
"serviceProviderProperties": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"clusterServiceID": "/api/clusters_mgmt/v1/clusters/w9xhwccbjp/node_pools/k9xp9ghzh2"
},
"systemData": {
"createdBy": "Unknown-ARO-HCP-frontend",
"createdByType": "Application",
"lastModifiedBy": "Unknown-ARO-HCP-frontend",
"lastModifiedByType": "Application"
},
"type": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
},
"resourceID": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"resourceType": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "b3b837bb-154f-5f52-8562-96a8c9d2bb05",
"partitionKey": "a433a095-1277-44f1-8453-8d61a4d848c2",
"properties": {
"id": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"intermediateResourceDoc": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"internalId": "/api/clusters_mgmt/v1/clusters/w9xhwccbjp/node_pools/k9xp9ghzh2",
Expand All @@ -16,21 +17,55 @@
},
"internalState": {
"internalAPI": {
"id": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"location": "fake-location",
"name": "basic",
"properties": {
"autoRepair": true,
"platform": {
"vmSize": "large"
},
"provisioningState": "Accepted",
"version": {
"channelGroup": "stable"
}
},
"serviceProviderProperties": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"clusterServiceID": ""
Comment thread
deads2k marked this conversation as resolved.
}
},
"systemData": {
"createdBy": "Unknown-ARO-HCP-frontend",
"createdByType": "Application",
"lastModifiedBy": "Unknown-ARO-HCP-frontend",
"lastModifiedByType": "Application"
},
"type": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
}
},
"location": "fake-location",
"name": "basic",
"properties": {
"autoRepair": true,
"platform": {
"vmSize": "large"
},
"provisioningState": "Accepted",
"version": {
"channelGroup": "stable"
}
}
},
"serviceProviderProperties": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"clusterServiceID": "/api/clusters_mgmt/v1/clusters/w9xhwccbjp/node_pools/k9xp9ghzh2"
},
"systemData": {
"createdBy": "Unknown-ARO-HCP-frontend",
"createdByType": "Application",
"lastModifiedBy": "Unknown-ARO-HCP-frontend",
"lastModifiedByType": "Application"
},
"type": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
},
"resourceID": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"resourceType": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"id": "b3b837bb-154f-5f52-8562-96a8c9d2bb05",
"partitionKey": "a433a095-1277-44f1-8453-8d61a4d848c2",
"properties": {
"id": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"intermediateResourceDoc": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"internalId": "/api/clusters_mgmt/v1/clusters/w9xhwccbjp/node_pools/k9xp9ghzh2",
Expand All @@ -16,21 +17,55 @@
},
"internalState": {
"internalAPI": {
"id": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"location": "fake-location",
"name": "basic",
"properties": {
"autoRepair": true,
"platform": {
"vmSize": "large"
},
"provisioningState": "Accepted",
"version": {
"channelGroup": "stable"
}
},
"serviceProviderProperties": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"clusterServiceID": ""
Comment thread
deads2k marked this conversation as resolved.
}
},
"systemData": {
"createdBy": "Unknown-ARO-HCP-frontend",
"createdByType": "Application",
"lastModifiedBy": "Unknown-ARO-HCP-frontend",
"lastModifiedByType": "Application"
},
"type": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
}
},
"location": "fake-location",
"name": "basic",
"properties": {
"autoRepair": true,
"platform": {
"vmSize": "large"
},
"provisioningState": "Accepted",
"version": {
"channelGroup": "stable"
}
}
},
"serviceProviderProperties": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"clusterServiceID": "/api/clusters_mgmt/v1/clusters/w9xhwccbjp/node_pools/k9xp9ghzh2"
},
"systemData": {
"createdBy": "Unknown-ARO-HCP-frontend",
"createdByType": "Application",
"lastModifiedBy": "Unknown-ARO-HCP-frontend",
"lastModifiedByType": "Application"
},
"type": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
},
"resourceID": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"resourceType": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"id": "b3b837bb-154f-5f52-8562-96a8c9d2bb05",
"partitionKey": "a433a095-1277-44f1-8453-8d61a4d848c2",
"properties": {
"id": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"intermediateResourceDoc": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"internalId": "/api/clusters_mgmt/v1/clusters/1243e9e9-d150-4ef1-9735-2bbc3cabc7d0/node_pools/k9xp9ghzh2",
Expand All @@ -21,7 +22,9 @@
},
"internalState": {
"internalAPI": {
"id": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"location": "fake-location",
"name": "basic",
"properties": {
"autoRepair": true,
"autoScaling": {
Expand All @@ -40,6 +43,7 @@
},
"vmSize": "large"
},
"provisioningState": "Accepted",
"taints": [
{
"effect": "NoExecute",
Expand All @@ -52,10 +56,61 @@
}
},
"serviceProviderProperties": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"clusterServiceID": ""
Comment thread
deads2k marked this conversation as resolved.
},
"systemData": {
"createdBy": "Unknown-ARO-HCP-frontend",
"createdByType": "Application",
"lastModifiedBy": "Unknown-ARO-HCP-frontend",
"lastModifiedByType": "Application"
},
"type": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
}
},
"location": "fake-location",
"name": "basic",
"properties": {
"autoRepair": true,
"autoScaling": {
"max": 5,
"min": 1
},
"labels": {
"label-ky": "label-value"
},
"nodeDrainTimeoutMinutes": 2,
"platform": {
"enableEncryptionAtHost": false,
"osDisk": {
"diskStorageAccountType": "Premium_LRS",
"sizeGiB": 64
},
"vmSize": "large"
},
"provisioningState": "Accepted",
"taints": [
{
"effect": "NoExecute",
"key": "foo.com/key",
"value": "valid"
}
],
"version": {
"channelGroup": "stable"
}
}
},
"serviceProviderProperties": {
"activeOperationId": "a7b69c90-242b-4a85-8187-0b3bd4979155",
"clusterServiceID": "/api/clusters_mgmt/v1/clusters/1243e9e9-d150-4ef1-9735-2bbc3cabc7d0/node_pools/k9xp9ghzh2"
},
"systemData": {
"createdBy": "Unknown-ARO-HCP-frontend",
"createdByType": "Application",
"lastModifiedBy": "Unknown-ARO-HCP-frontend",
"lastModifiedByType": "Application"
},
"type": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
},
"resourceID": "/subscriptions/a433a095-1277-44f1-8453-8d61a4d848c2/resourceGroups/unimportantpostponement/providers/Microsoft.RedHatOpenShift/hcpOpenShiftClusters/monstrousprecinct/nodePools/basic",
"resourceType": "Microsoft.RedHatOpenShift/hcpOpenShiftClusters/nodePools"
Expand Down
Loading