Skip to content

Commit

Permalink
Merge pull request #258 from openshift-cherrypick-robot/cherry-pick-2…
Browse files Browse the repository at this point in the history
…57-to-release-4.18

DFBUGS-1596: [release-4.18] Fix StorageClusterPeer API endpoint
  • Loading branch information
openshift-merge-bot[bot] authored Feb 11, 2025
2 parents 67d65ad + 5e8a8d0 commit 78291a6
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 22 deletions.
34 changes: 20 additions & 14 deletions controllers/managedclusterview_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ const (
)

type ProviderInfo struct {
Version string `json:"version"`
DeploymentType string `json:"deploymentType"`
StorageSystemName string `json:"storageSystemName"`
ProviderManagedClusterName string `json:"providerManagedClusterName"`
NamespacedName types.NamespacedName `json:"namespacedName"`
StorageProviderEndpoint string `json:"storageProviderEndpoint"`
CephClusterFSID string `json:"cephClusterFSID"`
Version string `json:"version"`
DeploymentType string `json:"deploymentType"`
StorageSystemName string `json:"storageSystemName"`
ProviderManagedClusterName string `json:"providerManagedClusterName"`
NamespacedName types.NamespacedName `json:"namespacedName"`
StorageProviderEndpoint string `json:"storageProviderEndpoint"`
CephClusterFSID string `json:"cephClusterFSID"`
StorageProviderPublicEndpoint string `json:"storageProviderPublicEndpoint"`
}

type ClientInfo struct {
Expand Down Expand Up @@ -139,14 +140,19 @@ func createOrUpdateConfigMap(ctx context.Context, c client.Client, managedCluste
return fmt.Errorf("failed to unmarshal ODF info data for key %s: %w", key, err)
}

providerPublicEndpoint := odfInfo.StorageCluster.Annotations[ocsv1alpha1.ApiServerExportedAddressAnnotationName]
if providerPublicEndpoint == "" {
logger.Info("StorageProviderPublicEndpoint is not available.")
}
providerInfo := ProviderInfo{
Version: odfInfo.Version,
DeploymentType: odfInfo.DeploymentType,
CephClusterFSID: odfInfo.StorageCluster.CephClusterFSID,
StorageProviderEndpoint: odfInfo.StorageCluster.StorageProviderEndpoint,
NamespacedName: odfInfo.StorageCluster.NamespacedName,
StorageSystemName: odfInfo.StorageSystemName,
ProviderManagedClusterName: managedClusterView.Namespace,
Version: odfInfo.Version,
DeploymentType: odfInfo.DeploymentType,
CephClusterFSID: odfInfo.StorageCluster.CephClusterFSID,
StorageProviderEndpoint: odfInfo.StorageCluster.StorageProviderEndpoint,
NamespacedName: odfInfo.StorageCluster.NamespacedName,
StorageSystemName: odfInfo.StorageSystemName,
ProviderManagedClusterName: managedClusterView.Namespace,
StorageProviderPublicEndpoint: providerPublicEndpoint,
}

for _, client := range odfInfo.Clients {
Expand Down
10 changes: 7 additions & 3 deletions controllers/managedclusterview_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ storageCluster:
namespace: "openshift-storage"
storageProviderEndpoint: ""
cephClusterFSID: "7a3d6b81-a55d-44fe-84d0-46c67cd395ca"
annotations:
ocs.openshift.io/api-server-exported-address: ""
storageSystemName: "ocs-storagecluster-storagesystem"
`,
}
Expand All @@ -105,7 +107,7 @@ storageSystemName: "ocs-storagecluster-storagesystem"
assert.NotNil(t, cm)

expectedData := map[string]string{
"cluster1-name_client1": `{"clusterId":"cluster1","name":"client1","providerInfo":{"version":"4.Y.Z","deploymentType":"internal","storageSystemName":"ocs-storagecluster-storagesystem","providerManagedClusterName":"cluster1","namespacedName":{"Namespace":"openshift-storage","Name":"ocs-storagecluster"},"storageProviderEndpoint":"","cephClusterFSID":"7a3d6b81-a55d-44fe-84d0-46c67cd395ca"},"clientManagedClusterName":"cluster1-name","clientId":"client1"}`,
"cluster1-name_client1": `{"clusterId":"cluster1","name":"client1","providerInfo":{"version":"4.Y.Z","deploymentType":"internal","storageSystemName":"ocs-storagecluster-storagesystem","providerManagedClusterName":"cluster1","namespacedName":{"Namespace":"openshift-storage","Name":"ocs-storagecluster"},"storageProviderEndpoint":"","cephClusterFSID":"7a3d6b81-a55d-44fe-84d0-46c67cd395ca","storageProviderPublicEndpoint":""},"clientManagedClusterName":"cluster1-name","clientId":"client1"}`,
}

assert.Equal(t, expectedData, cm.Data)
Expand All @@ -132,6 +134,8 @@ storageCluster:
namespace: "openshift-storage"
storageProviderEndpoint: ""
cephClusterFSID: "8b3d6b81-b55d-55fe-94d0-56c67cd495ca"
annotations:
ocs.openshift.io/api-server-exported-address: ""
storageSystemName: "ocs-storagecluster-storagesystem"
`,
}
Expand All @@ -152,8 +156,8 @@ storageSystemName: "ocs-storagecluster-storagesystem"
assert.NotNil(t, cm)

expectedData := map[string]string{
"cluster1-name_client1": `{"clusterId":"cluster1","name":"client1","providerInfo":{"version":"4.Y.Z","deploymentType":"internal","storageSystemName":"ocs-storagecluster-storagesystem","providerManagedClusterName":"cluster1","namespacedName":{"Namespace":"openshift-storage","Name":"ocs-storagecluster"},"storageProviderEndpoint":"","cephClusterFSID":"7a3d6b81-a55d-44fe-84d0-46c67cd395ca"},"clientManagedClusterName":"cluster1-name","clientId":"client1"}`,
"cluster2-name_client2": `{"clusterId":"cluster2","name":"client2","providerInfo":{"version":"4.Y.Z","deploymentType":"internal","storageSystemName":"ocs-storagecluster-storagesystem","providerManagedClusterName":"cluster2","namespacedName":{"Namespace":"openshift-storage","Name":"ocs-storagecluster"},"storageProviderEndpoint":"","cephClusterFSID":"8b3d6b81-b55d-55fe-94d0-56c67cd495ca"},"clientManagedClusterName":"cluster2-name","clientId":"client2"}`,
"cluster1-name_client1": `{"clusterId":"cluster1","name":"client1","providerInfo":{"version":"4.Y.Z","deploymentType":"internal","storageSystemName":"ocs-storagecluster-storagesystem","providerManagedClusterName":"cluster1","namespacedName":{"Namespace":"openshift-storage","Name":"ocs-storagecluster"},"storageProviderEndpoint":"","cephClusterFSID":"7a3d6b81-a55d-44fe-84d0-46c67cd395ca","storageProviderPublicEndpoint":""},"clientManagedClusterName":"cluster1-name","clientId":"client1"}`,
"cluster2-name_client2": `{"clusterId":"cluster2","name":"client2","providerInfo":{"version":"4.Y.Z","deploymentType":"internal","storageSystemName":"ocs-storagecluster-storagesystem","providerManagedClusterName":"cluster2","namespacedName":{"Namespace":"openshift-storage","Name":"ocs-storagecluster"},"storageProviderEndpoint":"","cephClusterFSID":"8b3d6b81-b55d-55fe-94d0-56c67cd495ca","storageProviderPublicEndpoint":""},"clientManagedClusterName":"cluster2-name","clientId":"client2"}`,
}

assert.Equal(t, expectedData, cm.Data)
Expand Down
9 changes: 8 additions & 1 deletion controllers/mirrorpeer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,13 @@ func createStorageClusterPeer(ctx context.Context, client client.Client, logger
if err != nil {
return ctrl.Result{}, fmt.Errorf("failed to fetch onboarding token for provider %s. %w", oppositeClient.ProviderInfo.ProviderManagedClusterName, err)
}

apiEndpoint := oppositeClient.ProviderInfo.StorageProviderPublicEndpoint
if apiEndpoint == "" {
logger.Error("'StorageProviderPublicEndpoint' not found. Using 'StorageProviderEndpoint' instead. It might not be accessible externally.")
apiEndpoint = oppositeClient.ProviderInfo.StorageProviderEndpoint
}

storageClusterPeer := ocsv1.StorageClusterPeer{
TypeMeta: metav1.TypeMeta{
Kind: "StorageClusterPeer",
Expand All @@ -448,7 +455,7 @@ func createStorageClusterPeer(ctx context.Context, client client.Client, logger
},
Spec: ocsv1.StorageClusterPeerSpec{
OnboardingToken: onboardingToken,
ApiEndpoint: oppositeClient.ProviderInfo.StorageProviderEndpoint,
ApiEndpoint: apiEndpoint,
},
}
storageClusterPeerJson, err := json.Marshal(storageClusterPeer)
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/openshift/api v0.0.0-20241216151652-de9de05a8e43
github.com/openshift/library-go v0.0.0-20240124134907-4dfbf6bc7b11
github.com/ramendr/ramen/api v0.0.0-20241001141243-29d6f22ad237
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20241112092644-99fdb662050d
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20250211080844-377e36d6d211
github.com/rook/rook/pkg/apis v0.0.0-20250204173727-c0a3db95a25f
github.com/spf13/cobra v1.8.1
github.com/stolostron/multicloud-operators-foundation v0.0.0-20220824091202-e9cd9710d009
Expand Down Expand Up @@ -81,7 +81,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/noobaa/noobaa-operator/v5 v5.0.0-20240827070548-002966de315a // indirect
github.com/noobaa/noobaa-operator/v5 v5.0.0-20241112075542-b62bb7eb535d // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/openshift/custom-resource-status v1.1.3-0.20220503160415-f2fdb4999d87 // indirect
github.com/pkg/errors v0.9.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,8 @@ github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoG
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
github.com/ramendr/ramen/api v0.0.0-20241001141243-29d6f22ad237 h1:ig6ePD0yopC5Qi5BRmhsIsKaOkdsGXTSmG3HTYIpquo=
github.com/ramendr/ramen/api v0.0.0-20241001141243-29d6f22ad237/go.mod h1:nO6VM/+PEhcPGyFIQJdhY6ip822cA61PAy/s6IjenAA=
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20241112092644-99fdb662050d h1:+5S4F665PL+8TK9OGHX/2A+N9jPoT2PRHO69g7z7ZLk=
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20241112092644-99fdb662050d/go.mod h1:fcFoM7FdQba/2m0CecUGNu38JaTt8quRKXhCqt8C3Jg=
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20250211080844-377e36d6d211 h1:mwMsRE4lSd+i5525UFCpPYc+S4VNfH8/1GUBeEeh+lI=
github.com/red-hat-storage/ocs-operator/api/v4 v4.0.0-20250211080844-377e36d6d211/go.mod h1:j3lmbipdPLkLsH3zRPNkb7AsiDB/E3LYGaiKtLrzM/Y=
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-charset v0.0.0-20180617210344-2471d30d28b4/go.mod h1:qgYeAmZ5ZIpBWTGllZSQnw97Dj+woV0toclVaRGI8pc=
Expand Down

0 comments on commit 78291a6

Please sign in to comment.