Skip to content

Commit 385a35b

Browse files
Fix KIND cluster creation for test-network-k8s (#1375)
This PR replaces deprecated containerd registry.mirrors configuration with config_path mode and hosts.toml, required for containerd 2.x (KIND v0.27.0+). The old configuration prevents the CRI plugin from loading, causing kubelet to fail on startup. Also, this fixes CA enrollment in create_node_local_MSP() to specify port 443 explicitly, and other minor issues, including removing redundant throws from Java close() methods. Signed-off-by: Tatsuya Sato <tatsuya.sato.so@hitachi.com> Co-authored-by: Mark S. Lewis <Mark.S.Lewis@outlook.com>
1 parent d669a3f commit 385a35b

File tree

6 files changed

+65
-8
lines changed

6 files changed

+65
-8
lines changed

.github/workflows/test-network-k8s.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,65 @@ jobs:
2222
- name: Checkout
2323
uses: actions/checkout@v6
2424
- name: Test the network
25+
id: run-test
2526
working-directory: test-network-k8s
2627
run: ../ci/scripts/run-k8s-test-network-basic.sh
2728
env:
2829
CLIENT_LANGUAGE: typescript
2930
CHAINCODE_LANGUAGE: java
31+
- name: Upload failure logs
32+
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
33+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
34+
with:
35+
name: ${{ github.job }}-logs
36+
path: test-network-k8s/network-debug.log
3037

3138
ccaas-external:
3239
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
3340
steps:
3441
- name: Checkout
3542
uses: actions/checkout@v6
3643
- name: Test the network
44+
id: run-test
3745
working-directory: test-network-k8s
3846
run: ../ci/scripts/run-k8s-test-network-basic.sh
3947
env:
4048
CLIENT_LANGUAGE: typescript
4149
CHAINCODE_LANGUAGE: external
50+
- name: Upload failure logs
51+
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
52+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
53+
with:
54+
name: ${{ github.job }}-logs
55+
path: test-network-k8s/network-debug.log
4256

4357
k8s-builder:
4458
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
4559
steps:
4660
- name: Checkout
4761
uses: actions/checkout@v6
4862
- name: Test the network
63+
id: run-test
4964
working-directory: test-network-k8s
5065
run: ../ci/scripts/run-k8s-test-network-basic.sh
5166
env:
5267
CHAINCODE_NAME: basic
5368
CHAINCODE_LANGUAGE: java
5469
CHAINCODE_BUILDER: k8s
70+
- name: Upload failure logs
71+
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
72+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
73+
with:
74+
name: ${{ github.job }}-logs
75+
path: test-network-k8s/network-debug.log
5576

5677
multi-namespace:
5778
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
5879
steps:
5980
- name: Checkout
6081
uses: actions/checkout@v6
6182
- name: Test the network
83+
id: run-test
6284
working-directory: test-network-k8s
6385
run: ../ci/scripts/run-k8s-test-network-basic.sh
6486
env:
@@ -68,6 +90,12 @@ jobs:
6890
CHAINCODE_NAME: basic
6991
CHAINCODE_LANGUAGE: java
7092
CHAINCODE_BUILDER: k8s
93+
- name: Upload failure logs
94+
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
95+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
96+
with:
97+
name: ${{ github.job }}-logs
98+
path: test-network-k8s/network-debug.log
7199

72100
bft-orderer:
73101
runs-on: ${{ github.repository == 'hyperledger/fabric-samples' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
@@ -78,6 +106,7 @@ jobs:
78106
- name: Checkout
79107
uses: actions/checkout@v6
80108
- name: Test the network
109+
id: run-test
81110
working-directory: test-network-k8s
82111
run: ../ci/scripts/run-k8s-test-network-basic.sh
83112
env:
@@ -87,3 +116,9 @@ jobs:
87116
# To test BFT Orderers, Fabric v3.x is explicitly specified here.
88117
FABRIC_VERSION: '3.1'
89118
ORDERER_TYPE: bft
119+
- name: Upload failure logs
120+
if: ${{ failure() && steps.run-test.conclusion == 'failure' }}
121+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
122+
with:
123+
name: ${{ github.job }}-logs
124+
path: test-network-k8s/network-debug.log

asset-transfer-basic/chaincode-java/src/test/java/org/hyperledger/fabric/samples/assettransfer/AssetTransferTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public Iterator<KeyValue> iterator() {
8383
}
8484

8585
@Override
86-
public void close() throws Exception {
86+
public void close() {
8787
// do nothing
8888
}
8989

asset-transfer-events/application-gateway-java/src/main/java/App.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private void replayChaincodeEvents(final long startBlock) {
169169
}
170170

171171
@Override
172-
public void close() throws Exception {
172+
public void close() {
173173
executor.shutdownNow();
174174
}
175175
}

test-network-k8s/scripts/kind.sh

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,32 @@ nodes:
4343
#networking:
4444
# kubeProxyMode: "ipvs"
4545
46-
# create a cluster with the local registry enabled in containerd
46+
# Create a cluster with the local registry enabled in containerd.
47+
# KIND v0.27.0+ uses containerd 2.x, which requires config_path mode
48+
# instead of the deprecated registry.mirrors configuration.
49+
# See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.27.0
50+
# See: https://github.com/containerd/containerd/blob/main/docs/hosts.md
4751
containerdConfigPatches:
4852
- |-
49-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
50-
endpoint = ["http://${reg_name}:${reg_port}"]
53+
[plugins."io.containerd.grpc.v1.cri".registry]
54+
config_path = "/etc/containerd/certs.d"
5155
5256
EOF
5357

58+
# Configure registry for containerd 2.x using config_path mode
59+
for node in $(kind get nodes --name $CLUSTER_NAME);
60+
do
61+
docker exec "$node" mkdir -p "/etc/containerd/certs.d/localhost:${reg_port}"
62+
docker exec "$node" sh -c "cat > /etc/containerd/certs.d/localhost:${reg_port}/hosts.toml <<EOT
63+
server = \"http://localhost:${reg_port}\"
64+
65+
[host.\"http://${reg_name}:${reg_port}\"]
66+
capabilities = [\"pull\", \"resolve\", \"push\"]
67+
EOT"
68+
done
69+
5470
# workaround for https://github.com/hyperledger/fabric-samples/issues/550 - pods can not resolve external DNS
55-
for node in $(kind get nodes);
71+
for node in $(kind get nodes --name $CLUSTER_NAME);
5672
do
5773
docker exec "$node" sysctl net.ipv4.conf.all.route_localnet=1;
5874
done

test-network-k8s/scripts/test_network.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,17 @@ function create_node_local_MSP() {
7474
export FABRIC_CA_CLIENT_HOME=/var/hyperledger/fabric-ca-client
7575
export FABRIC_CA_CLIENT_TLS_CERTFILES=/var/hyperledger/fabric/config/tls/ca.crt
7676
77+
# Enroll from inside the CA pod. Must specify port 443 explicitly.
78+
# CA server listens on port 443, but fabric-ca-client defaults to 7054 when port is omitted in the URL.
7779
fabric-ca-client enroll \
78-
--url https://${id_name}:${id_secret}@${ca_name} \
80+
--url https://${id_name}:${id_secret}@${ca_name}:443 \
7981
--csr.hosts ${csr_hosts} \
8082
--mspdir /var/hyperledger/fabric/organizations/${node_type}Organizations/${org}.example.com/${node_type}s/${id_name}.${org}.example.com/msp
8183
84+
# Copy CA cert to expected filename (fabric-ca-client saves it as <hostname>-<port>.pem)
85+
cp /var/hyperledger/fabric/organizations/${node_type}Organizations/${org}.example.com/${node_type}s/${id_name}.${org}.example.com/msp/cacerts/*.pem \
86+
/var/hyperledger/fabric/organizations/${node_type}Organizations/${org}.example.com/${node_type}s/${id_name}.${org}.example.com/msp/cacerts/${org}-ca.pem
87+
8288
# Create local MSP config.yaml
8389
echo "NodeOUs:
8490
Enable: true

token-erc-721/chaincode-java/src/test/java/org/hyperledger/fabric/samples/erc721/ERC721TokenContractTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public Iterator<KeyValue> iterator() {
7070
}
7171

7272
@Override
73-
public void close() throws Exception {
73+
public void close() {
7474
// do nothing
7575
}
7676
}

0 commit comments

Comments
 (0)