Skip to content

Commit

Permalink
Prepare release 1.11 (#240)
Browse files Browse the repository at this point in the history
* update docs

* Fix deploy github pages

Signed-off-by: David VIEJO <[email protected]>

* change leader rotation

Signed-off-by: David VIEJO <[email protected]>

* Update

Signed-off-by: David VIEJO <[email protected]>

* Update readme

Signed-off-by: David VIEJO <[email protected]>

* Verify migration Raft -> BFT

Signed-off-by: David VIEJO <[email protected]>

---------

Signed-off-by: David VIEJO <[email protected]>
  • Loading branch information
dviejokfs authored Oct 31, 2024
1 parent 75b970b commit e5283bf
Show file tree
Hide file tree
Showing 7 changed files with 1,243 additions and 109 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/release_web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ on:

jobs:
deploy:
name: Deploy to GitHub Pages
name: Deploy to GitHub Page
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
Expand All @@ -28,12 +33,12 @@ jobs:
- name: Install dependencies
run: |
cd website-docs
bun install
yarn install --frozen-lockfile
- name: Build Docusaurus website
run: |
cd website-docs
bun run build
yarn run build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
Expand Down
35 changes: 8 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ To install helm: [https://helm.sh/docs/intro/install/](https://helm.sh/docs/intr
```bash
helm repo add kfs https://kfsoftware.github.io/hlf-helm-charts --force-update

helm install hlf-operator --version=1.10.0 -- kfs/hlf-operator
helm install hlf-operator --version=1.11.0-beta8-1 -- kfs/hlf-operator
```


Expand Down Expand Up @@ -218,36 +218,19 @@ EOF
## Deploy a `Peer` organization


### Environment Variables for AMD (Default)
### Environment Variables

```bash
export PEER_IMAGE=hyperledger/fabric-peer
export PEER_VERSION=2.5.10
export PEER_VERSION=3.0.0

export ORDERER_IMAGE=hyperledger/fabric-orderer
export ORDERER_VERSION=2.5.10
export ORDERER_VERSION=3.0.0

export CA_IMAGE=hyperledger/fabric-ca
export CA_VERSION=1.5.13
```


### Environment Variables for ARM (Mac M1)

```bash
export PEER_IMAGE=hyperledger/fabric-peer
export PEER_VERSION=2.5.10

export ORDERER_IMAGE=hyperledger/fabric-orderer
export ORDERER_VERSION=2.5.10

export CA_IMAGE=hyperledger/fabric-ca
export CA_VERSION=1.5.13

```



### Configure Internal DNS

```bash
Expand Down Expand Up @@ -704,8 +687,6 @@ echo "PACKAGE_ID=$PACKAGE_ID"

kubectl hlf chaincode install --path=./chaincode.tgz \
--config=org1.yaml --language=golang --label=$CHAINCODE_LABEL --user=admin --peer=org1-peer0.default
kubectl hlf chaincode install --path=./chaincode.tgz \
--config=org1.yaml --language=golang --label=$CHAINCODE_LABEL --user=admin --peer=org1-peer1.default

```

Expand Down Expand Up @@ -735,14 +716,14 @@ export VERSION="1.0"
kubectl hlf chaincode approveformyorg --config=org1.yaml --user=admin --peer=org1-peer0.default \
--package-id=$PACKAGE_ID \
--version "$VERSION" --sequence "$SEQUENCE" --name=asset \
--policy="OR('Org1MSP.member')" --channel=testbft02
--policy="OR('Org1MSP.member')" --channel=demo
```

## Commit chaincode
```bash
kubectl hlf chaincode commit --config=org1.yaml --user=admin --mspid=Org1MSP \
--version "$VERSION" --sequence "$SEQUENCE" --name=asset \
--policy="OR('Org1MSP.member')" --channel=testbft02
--policy="OR('Org1MSP.member')" --channel=demo
```


Expand All @@ -751,7 +732,7 @@ kubectl hlf chaincode commit --config=org1.yaml --user=admin --mspid=Org1MSP \
```bash
kubectl hlf chaincode invoke --config=org1.yaml \
--user=admin --peer=org1-peer0.default \
--chaincode=asset --channel=testbft02 \
--chaincode=asset --channel=demo \
--fcn=initLedger -a '[]'
```

Expand All @@ -760,7 +741,7 @@ kubectl hlf chaincode invoke --config=org1.yaml \
```bash
kubectl hlf chaincode query --config=org1.yaml \
--user=admin --peer=org1-peer0.default \
--chaincode=asset --channel=testbft02 \
--chaincode=asset --channel=demo \
--fcn=GetAllAssets -a '[]'
```

Expand Down
13 changes: 5 additions & 8 deletions controllers/mainchannel/mainchannel_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,9 @@ func (r *FabricMainChannelReconciler) mapToConfigTX(channel *hlfv1alpha1.FabricM
},
}
// if etcdraft, add BlockValidation policy
if channel.Spec.ChannelConfig.Orderer.OrdererType == hlfv1alpha1.OrdererConsensusEtcdraft {
adminOrdererPolicies["BlockValidation"] = configtx.Policy{
Type: "ImplicitMeta",
Rule: "ANY Writers",
}
adminOrdererPolicies["BlockValidation"] = configtx.Policy{
Type: "ImplicitMeta",
Rule: "ANY Writers",
}

var state orderer.ConsensusState
Expand Down Expand Up @@ -919,7 +917,6 @@ func (r *FabricMainChannelReconciler) mapToConfigTX(channel *hlfv1alpha1.FabricM
ServerTlsCert: utils.EncodeX509Certificate(serverTLSCert),
})
}
//

leader_rotation := sb.Options_ROTATION_ON
if channel.Spec.ChannelConfig.Orderer.SmartBFT.LeaderRotation == sb.Options_ROTATION_ON {
Expand Down Expand Up @@ -977,7 +974,7 @@ func (r *FabricMainChannelReconciler) mapToConfigTX(channel *hlfv1alpha1.FabricM
ordConfigtx := configtx.Orderer{
OrdererType: ordererType,
Organizations: ordererOrgs,
ConsenterMapping: consenterMapping, // TODO: map from channel.Spec.ConssenterMapping
ConsenterMapping: consenterMapping,
SmartBFT: smartBFTOptions,
EtcdRaft: etcdRaft,
Policies: adminOrdererPolicies,
Expand Down Expand Up @@ -1452,7 +1449,7 @@ func updateOrdererChannelConfigTx(currentConfigTX configtx.ConfigTx, newConfigTx
}

// update
if ord.OrdererType == "BFT" {
if ord.OrdererType == orderer.ConsensusTypeBFT {
err = currentConfigTX.Orderer().SetConfiguration(newConfigTx.Orderer)
if err != nil {
return errors.Wrapf(err, "failed to set orderer configuration")
Expand Down
106 changes: 106 additions & 0 deletions scripts/migrate-channel-raft-bft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,103 @@ async function updatePeers(peers: { name: string; namespace: string }[]) {
}
}

async function restartOrderers(orderers: { name: string; namespace: string }[]) {
for (const orderer of orderers) {
try {
console.log(`Restarting orderer ${orderer.name} in namespace ${orderer.namespace}...`)
const appsV1Api = kc.makeApiClient(k8s.AppsV1Api)

// Scale down to 0
const patch = [
{
op: 'replace',
path: '/spec/replicas',
value: 0,
},
]

await appsV1Api.patchNamespacedDeployment(orderer.name, orderer.namespace, patch, undefined, undefined, undefined, undefined, undefined, {
headers: { 'Content-Type': 'application/json-patch+json' },
})
await new Promise((resolve) => setTimeout(resolve, 1000))
// Wait for scale down by polling the deployment state
let scaledDown = false
const maxWaitTime = 10 * 60 * 1000 // 10 minutes in milliseconds
const pollInterval = 1000 // 1 second
const startTime = Date.now()

while (!scaledDown && Date.now() - startTime < maxWaitTime) {
try {
const res = await appsV1Api.readNamespacedDeployment(orderer.name, orderer.namespace)
const deployment = res.body
const isReady =
deployment.status?.conditions?.some((condition) => condition.type === 'Available' && condition.status === 'True') &&
deployment.status?.readyReplicas === deployment.status?.replicas

if (isReady) {
scaledDown = true
console.log(`Orderer ${orderer.name} in namespace ${orderer.namespace} has been scaled down to 0`)
} else {
const elapsedTime = Math.floor((Date.now() - startTime) / 1000)
console.log(`Waiting for orderer ${orderer.name} in namespace ${orderer.namespace} to scale down (${elapsedTime} seconds elapsed)...`)
await new Promise((resolve) => setTimeout(resolve, pollInterval))
}
} catch (err) {
console.error(`Error checking orderer ${orderer.name} in namespace ${orderer.namespace} scale down status:`, err)
await new Promise((resolve) => setTimeout(resolve, pollInterval))
}
}

if (!scaledDown) {
console.error(`Orderer ${orderer.name} in namespace ${orderer.namespace} did not scale down within the expected time.`)
continue
}

// Scale back up to 1
patch[0].value = 1
await appsV1Api.patchNamespacedDeployment(orderer.name, orderer.namespace, patch, undefined, undefined, undefined, undefined, undefined, {
headers: { 'Content-Type': 'application/json-patch+json' },
})

// Wait for the orderer to be back up by polling the deployment state
let ready = false
const startTimeUp = Date.now()
await new Promise((resolve) => setTimeout(resolve, 1000))

while (!ready && Date.now() - startTimeUp < maxWaitTime) {
try {
const res = await appsV1Api.readNamespacedDeployment(orderer.name, orderer.namespace)
const deployment = res.body

const isReady =
deployment.status?.conditions?.some((condition) => condition.type === 'Available' && condition.status === 'True') &&
deployment.status?.readyReplicas === deployment.status?.replicas

if (isReady) {
ready = true
console.log(`Orderer ${orderer.name} in namespace ${orderer.namespace} is back up and ready`)
} else {
const elapsedTime = Math.floor((Date.now() - startTimeUp) / 1000)
console.log(`Waiting for orderer ${orderer.name} in namespace ${orderer.namespace} to be back up (${elapsedTime} seconds elapsed)...`)
await new Promise((resolve) => setTimeout(resolve, pollInterval))
}
} catch (err) {
console.error(`Error checking orderer ${orderer.name} in namespace ${orderer.namespace} status:`, err)
await new Promise((resolve) => setTimeout(resolve, pollInterval))
}
}

if (!ready) {
console.error(`Orderer ${orderer.name} in namespace ${orderer.namespace} did not become ready within the expected time.`)
} else {
console.log(`Successfully restarted orderer ${orderer.name}`)
}
} catch (err) {
console.error(`Error restarting orderer ${orderer.name}:`, err)
}
}
}

async function main() {
const channelName = await input({ message: 'Enter the channel name:' })
const channel = await getChannelFromKubernetes(channelName)
Expand Down Expand Up @@ -624,6 +721,15 @@ async function main() {
await updateChannelToBFT(channelName)
}

// Add restart confirmation
const restartConfirmed = await confirm({
message: `Restart the orderers before setting channel to normal state?`,
default: true,
})
if (restartConfirmed) {
await restartOrderers(selectedOrderers)
}

const stateNormalConfirmed = await confirm({
message: `Set channel ${channelName} to STATE_NORMAL?`,
default: true,
Expand Down
Loading

0 comments on commit e5283bf

Please sign in to comment.