-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: backport AZ Blob Provisioner (#1537)
* fix: add Azure Blob Provisioner extension (#1536) * add dedicated cloud e2e test module * added test without container * add s3 provision and e2e test (wip) * backport/copy upstream AZ Blob Provisioner * add s3 destination credentials * fix lic header format * avoid NPE in the generator * DEPENDENCIES * re-enable FCC crawling in tests * DEPENDENCIES * add documentation * add JSON annotations * fix tests
- Loading branch information
1 parent
7a0c2a9
commit 75d1526
Showing
26 changed files
with
1,811 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
All modules in this directory are only temporary and they should be replaced with their upstream counterparts at the | ||
earliest opportunity. changes made here should be upstreamed ASAP, lest we run the risk of feature divergence! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Backport of the Azure Blob Storage Provisioner | ||
|
||
This module is a backport, that means the contents of | ||
the [upstream module](https://github.com/eclipse-edc/Technology-Azure/tree/main/extensions/control-plane/provision/provision-blob) | ||
are copied here. | ||
|
||
## Defining an `Asset` located in AzBlob | ||
|
||
Create an asset similar to this on the provider connector's Management API: | ||
|
||
```json | ||
{ | ||
"@context": { | ||
"@vocab": "https://w3id.org/edc/v0.0.1/ns/" | ||
}, | ||
"@id": "blob-test-asset", | ||
"properties": {}, | ||
"dataAddress": { | ||
"keyName": "provider-key-alias", | ||
"type": "AzureStorage", | ||
"@type": "DataAddress", | ||
"name": "transfer-test", | ||
"container": "provider-container", | ||
"account": "provider", | ||
"blobPrefix": "folder/" | ||
} | ||
} | ||
``` | ||
|
||
Explanation: | ||
|
||
- `keyName`: alias under which the Storage Account Key is located in the provider's vault, stored as plain `String` | ||
- `type`: **must** be `AzureStorage` | ||
- `container`: the name of the source AzBlob container on the provider side | ||
- `account`: the name of the AzBlob account on the provider side | ||
- `blobPrefix`: in case all contents of a "folder" are to be copied, this is the "folder name" | ||
|
||
## Creating an AzBlob-to-AzBlob transfer request | ||
|
||
Assuming the contract negotiation has succeeded, execute a transfer process request on the consumer's Management API | ||
endpoint with the following content: | ||
|
||
```json | ||
{ | ||
"@context": { | ||
"@vocab": "https://w3id.org/edc/v0.0.1/ns/" | ||
}, | ||
"@type": "TransferRequest", | ||
"protocol": "dataspace-protocol-http", | ||
"contractId": "416aed9c-7258-45c8-bdee-c09d5da7c255", | ||
"connectorId": "PROVIDER-BPN", | ||
"counterPartyAddress": "http://localhost:40950/protocol", | ||
"dataDestination": { | ||
"@type": "https://w3id.org/edc/v0.0.1/ns/DataAddress", | ||
"https://w3id.org/edc/v0.0.1/ns/type": "AzureStorage", | ||
"https://w3id.org/edc/v0.0.1/ns/properties": { | ||
"https://w3id.org/edc/v0.0.1/ns/type": "AzureStorage", | ||
"https://w3id.org/edc/v0.0.1/ns/account": "consumer", | ||
"https://w3id.org/edc/v0.0.1/ns/container": "consumer-container" | ||
} | ||
}, | ||
"transferType": "AzureStorage-PUSH" | ||
} | ||
``` | ||
|
||
Explanation: | ||
- `type`: **must** be `AzureStorage` | ||
- `account`: the consumer account name | ||
- `container`: the destination container in the consumer's Azure Blob account | ||
- `transferType`: **must** be `AzureStorage-PUSH` for the provider to push the data into the consumer's AzBlob container | ||
|
||
> Note that the Storage Account Key on the consumer side is expected in the Vault under the alias `<ACCOUNTNAME>-key1`, | ||
here that would be `consumer-key1`. The key **must** be the raw Account Key (no SAS token), stored as plain String. | ||
|
||
The AzBlob provisioner on the consumer side will generate a temporary SAS token for the consumer container ( | ||
`"consumer-container"`) and send it to the provider in a DSP `TransferRequestMessage`. The provider will then store it | ||
in its own Vault, where it gets resolved from the provider Data Plane. |
27 changes: 27 additions & 0 deletions
27
edc-extensions/backport/azblob-provisioner/build.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright (c) 2020, 2021 Microsoft Corporation | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Contributors: | ||
* Microsoft Corporation - initial API and implementation | ||
* | ||
*/ | ||
|
||
plugins { | ||
`java-library` | ||
} | ||
|
||
dependencies { | ||
api(libs.edc.spi.core) | ||
api(libs.edc.azure.blob.core) | ||
|
||
implementation(libs.azure.storage.blob) | ||
testImplementation(testFixtures(libs.edc.azure.test)) | ||
} | ||
|
||
|
77 changes: 77 additions & 0 deletions
77
...oner/src/main/java/org/eclipse/edc/connector/provision/azure/AzureProvisionExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020,2021 Microsoft Corporation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
package org.eclipse.edc.connector.provision.azure; | ||
|
||
import dev.failsafe.RetryPolicy; | ||
import org.eclipse.edc.azure.blob.AzureSasToken; | ||
import org.eclipse.edc.azure.blob.api.BlobStoreApi; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ProvisionManager; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.Provisioner; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ResourceManifestGenerator; | ||
import org.eclipse.edc.connector.provision.azure.blob.ObjectContainerProvisionedResource; | ||
import org.eclipse.edc.connector.provision.azure.blob.ObjectStorageConsumerResourceDefinitionGenerator; | ||
import org.eclipse.edc.connector.provision.azure.blob.ObjectStorageProvisioner; | ||
import org.eclipse.edc.connector.provision.azure.blob.ObjectStorageResourceDefinition; | ||
import org.eclipse.edc.runtime.metamodel.annotation.Inject; | ||
import org.eclipse.edc.spi.system.ServiceExtension; | ||
import org.eclipse.edc.spi.system.ServiceExtensionContext; | ||
import org.eclipse.edc.spi.types.TypeManager; | ||
|
||
/** | ||
* Provides data transfer {@link Provisioner}s backed by Azure services. | ||
*/ | ||
public class AzureProvisionExtension implements ServiceExtension { | ||
|
||
@Inject | ||
private BlobStoreApi blobStoreApi; | ||
|
||
@Inject | ||
private RetryPolicy<Object> retryPolicy; | ||
|
||
@Inject | ||
private ResourceManifestGenerator manifestGenerator; | ||
|
||
@Inject | ||
private TypeManager typeManager; | ||
|
||
@Override | ||
public String name() { | ||
return "Azure Provision"; | ||
} | ||
|
||
@Override | ||
public void initialize(ServiceExtensionContext context) { | ||
|
||
var monitor = context.getMonitor(); | ||
var provisionManager = context.getService(ProvisionManager.class); | ||
|
||
provisionManager.register(new ObjectStorageProvisioner(retryPolicy, monitor, blobStoreApi)); | ||
|
||
// register the generator | ||
manifestGenerator.registerGenerator(new ObjectStorageConsumerResourceDefinitionGenerator()); | ||
|
||
registerTypes(typeManager); | ||
} | ||
|
||
private void registerTypes(TypeManager typeManager) { | ||
typeManager.registerTypes(ObjectContainerProvisionedResource.class, ObjectStorageResourceDefinition.class, AzureSasToken.class); | ||
} | ||
|
||
} |
86 changes: 86 additions & 0 deletions
86
...va/org/eclipse/edc/connector/provision/azure/blob/ObjectContainerProvisionedResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020,2021 Microsoft Corporation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
package org.eclipse.edc.connector.provision.azure.blob; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonTypeName; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder; | ||
import org.eclipse.edc.azure.blob.AzureBlobStoreSchema; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ProvisionedDataDestinationResource; | ||
|
||
import static org.eclipse.edc.azure.blob.AzureBlobStoreSchema.ACCOUNT_NAME; | ||
import static org.eclipse.edc.azure.blob.AzureBlobStoreSchema.CONTAINER_NAME; | ||
import static org.eclipse.edc.azure.blob.AzureBlobStoreSchema.FOLDER_NAME; | ||
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_NAMESPACE; | ||
|
||
@JsonDeserialize(builder = ObjectContainerProvisionedResource.Builder.class) | ||
@JsonTypeName("dataspaceconnector:objectcontainerprovisionedresource") | ||
public class ObjectContainerProvisionedResource extends ProvisionedDataDestinationResource { | ||
|
||
private ObjectContainerProvisionedResource() { | ||
} | ||
|
||
public String getAccountName() { | ||
return getDataAddress().getStringProperty(ACCOUNT_NAME); | ||
} | ||
|
||
public String getContainerName() { | ||
return getDataAddress().getStringProperty(CONTAINER_NAME); | ||
} | ||
|
||
@JsonPOJOBuilder(withPrefix = "") | ||
public static class Builder extends ProvisionedDataDestinationResource.Builder<ObjectContainerProvisionedResource, Builder> { | ||
|
||
private Builder() { | ||
super(new ObjectContainerProvisionedResource()); | ||
dataAddressBuilder.type(AzureBlobStoreSchema.TYPE); | ||
} | ||
|
||
@JsonCreator | ||
public static Builder newInstance() { | ||
return new Builder(); | ||
} | ||
|
||
public Builder accountName(String accountName) { | ||
dataAddressBuilder.property(EDC_NAMESPACE + ACCOUNT_NAME, accountName); | ||
return this; | ||
} | ||
|
||
public Builder containerName(String containerName) { | ||
dataAddressBuilder.property(EDC_NAMESPACE + CONTAINER_NAME, containerName); | ||
return this; | ||
} | ||
|
||
@Override | ||
public Builder resourceName(String name) { | ||
dataAddressBuilder.keyName(name); | ||
super.resourceName(name); | ||
return this; | ||
} | ||
|
||
public Builder folderName(String folderName) { | ||
if (folderName != null) { | ||
dataAddressBuilder.property(EDC_NAMESPACE + FOLDER_NAME, folderName); | ||
} | ||
return this; | ||
} | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
.../edc/connector/provision/azure/blob/ObjectStorageConsumerResourceDefinitionGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2020,2021 Microsoft Corporation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
|
||
package org.eclipse.edc.connector.provision.azure.blob; | ||
|
||
import org.eclipse.edc.azure.blob.AzureBlobStoreSchema; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.provision.ConsumerResourceDefinitionGenerator; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.types.ResourceDefinition; | ||
import org.eclipse.edc.connector.controlplane.transfer.spi.types.TransferProcess; | ||
import org.eclipse.edc.policy.model.Policy; | ||
import org.eclipse.edc.spi.types.domain.DataAddress; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import static java.util.Optional.ofNullable; | ||
import static java.util.UUID.randomUUID; | ||
|
||
public class ObjectStorageConsumerResourceDefinitionGenerator implements ConsumerResourceDefinitionGenerator { | ||
|
||
@Override | ||
public @Nullable ResourceDefinition generate(TransferProcess transferProcess, Policy policy) { | ||
var destination = transferProcess.getDataDestination(); | ||
var id = randomUUID().toString(); | ||
var account = destination.getStringProperty(AzureBlobStoreSchema.ACCOUNT_NAME); | ||
var container = destination.getStringProperty(AzureBlobStoreSchema.CONTAINER_NAME); | ||
var folderName = destination.getStringProperty(AzureBlobStoreSchema.FOLDER_NAME); | ||
|
||
if (container == null) { | ||
container = randomUUID().toString(); | ||
} | ||
return ObjectStorageResourceDefinition.Builder.newInstance() | ||
.id(id) | ||
.accountName(account) | ||
.containerName(container) | ||
.folderName(folderName) | ||
.build(); | ||
} | ||
|
||
@Override | ||
public boolean canGenerate(TransferProcess dataRequest, Policy policy) { | ||
var type = ofNullable(dataRequest.getDataDestination()).map(DataAddress::getType).orElse(null); | ||
return AzureBlobStoreSchema.TYPE.equals(type); | ||
} | ||
} |
Oops, something went wrong.