Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Porting changes from V1.0.6 to master #139

Closed
wants to merge 14 commits into from
Closed
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
10 changes: 7 additions & 3 deletions .github/workflows/endtoend-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ name: Sample Network E2E Test

on:
push:
branches: [main]
branches: [v1.*]
pull_request:
branches: [main]
branches: [v1.*]

jobs:
suite:
Expand All @@ -31,4 +31,8 @@ jobs:
- uses: actions/checkout@v3

- name: Sample Network E2E Test
run: sample-network/scripts/run-e2e-test.sh || cat sample-network/network-debug.log
run: sample-network/scripts/run-e2e-test.sh

- name: Show Debug Log
if: ${{ always() }}
run: cat sample-network/network-debug.log
2 changes: 1 addition & 1 deletion .github/workflows/image-build-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build Operator image

on:
pull_request:
branches: [main]
branches: [v1.*]

jobs:
image:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/image-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build Operator image

on:
push:
branches: [main]
branches: [v1.*]

jobs:
image:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/integration-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ name: Integration Test

on:
push:
branches: [main]
branches: [v1.*]
pull_request:
branches: [main]
branches: [v1.*]

env:
KUBECONFIG_PATH: /tmp/kubeconfig.yaml
Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:

- name: Set up ginkgo
run: |
go install github.com/onsi/ginkgo/ginkgo
go install github.com/onsi/ginkgo/v2/ginkgo@v2.1.4
- name: Set up KIND k8s cluster
run: |
Expand Down
96 changes: 96 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Release Operator

on:
# pull_request:
# branches: [v1.*]
push:
tags: [v1.0.6-*]

env:
GO_VER: 1.18
GO_TAGS: ""
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
SEMREV_LABEL: ${{ github.ref_name }}

permissions:
contents: read

jobs:
build-and-push-image:
runs-on: ubuntu-20.04

permissions:
contents: read
packages: write

steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
with:
buildkitd-flags: --debug
config-inline: |
[worker.oci]
max-parallelism = 1

- name: Checkout
uses: actions/checkout@v3

- name: setup
run: |
scripts/install-tools.sh
make setup

- name: Login to the GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}.{{minor}}.{{patch}}

- name: Build and push
id: push
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GO_VER=${{ env.GO_VER }}
GO_TAGS=${{ env.GO_TAGS }}
BUILD_ID=${{ env.SEMREV_LABEL }}
BUILD_DATE=${{ env.BUILD_DATE }}


create-release:
name: Create GitHub Release
needs: [ build-and-push-image ]
runs-on: ubuntu-20.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Release Operator Version
uses: ncipollo/release-action@v1
with:
allowUpdates: "true"
bodyFile: release_notes/${{ env.SEMREV_LABEL }}.md
tag: ${{ env.SEMREV_LABEL }}
token: ${{ secrets.GITHUB_TOKEN }}
12 changes: 5 additions & 7 deletions .github/workflows/unit-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
name: unit-tests

on:
# TODO: uncomment this when moved to hyperledger-labs repo
# push:
# branches: [main]
push:
branches: [v1.*]
pull_request:
branches: [main]
branches: [v1.*]

env:
GO_VER: 1.18
Expand All @@ -39,8 +38,7 @@ jobs:
go-version: ${{ env.GO_VER }}
- name: license header checks
run: scripts/check-license.sh
# TODO: run in hyperledger-labs
# - name: gosec
# run: scripts/go-sec.sh
- name: gosec
run: scripts/go-sec.sh
- name: run tests
run: make test
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ARG GO_VER
FROM registry.access.redhat.com/ubi8/go-toolset:$GO_VER as builder
COPY . /go/src/github.com/IBM-Blockchain/fabric-operator
WORKDIR /go/src/github.com/IBM-Blockchain/fabric-operator
RUN GOOS=linux GOARCH=$(go env GOARCH) CGO_ENABLED=1 go build -mod=vendor -tags "pkcs11" -gcflags all=-trimpath=${GOPATH} -asmflags all=-trimpath=${GOPATH} -o /tmp/build/_output/bin/ibp-operator
RUN GOOS=linux GOARCH=${ARCH} CGO_ENABLED=1 go build -mod=vendor -tags "pkcs11" -gcflags all=-trimpath=${GOPATH} -asmflags all=-trimpath=${GOPATH} -o /tmp/build/_output/bin/ibp-operator

########## Final Image ##########
FROM registry.access.redhat.com/ubi8/ubi-minimal
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
IMAGE ?= ghcr.io/hyperledger-labs/fabric-operator
TAG ?= $(shell git rev-parse --short HEAD)
ARCH ?= $(shell go env GOARCH)
OSS_GO_VER ?= 1.17.7
OSS_GO_VER ?= 1.18
BUILD_DATE = $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
OS = $(shell go env GOOS)

Expand Down
13 changes: 12 additions & 1 deletion api/v1beta1/ibporderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
config "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/orderer/config/v1"
v2config "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/orderer/config/v2"
v24config "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/orderer/config/v24"
v25config "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/orderer/config/v25"
"github.com/IBM-Blockchain/fabric-operator/pkg/util/image"
"github.com/IBM-Blockchain/fabric-operator/version"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -88,7 +89,17 @@ func (o *IBPOrderer) GetConfigOverride() (interface{}, error) {
switch version.GetMajorReleaseVersion(o.Spec.FabricVersion) {
case version.V2:
currentVer := version.String(o.Spec.FabricVersion)
if currentVer.EqualWithoutTag(version.V2_4_1) || currentVer.GreaterThan(version.V2_4_1) {
if currentVer.EqualWithoutTag(version.V2_5_1) || currentVer.GreaterThan(version.V2_5_1) {
if o.Spec.ConfigOverride == nil {
return &v25config.Orderer{}, nil
}

configOverride, err := v25config.ReadFrom(&o.Spec.ConfigOverride.Raw)
if err != nil {
return nil, err
}
return configOverride, nil
} else if currentVer.EqualWithoutTag(version.V2_4_1) || currentVer.GreaterThan(version.V2_4_1) {
if o.Spec.ConfigOverride == nil {
return &v24config.Orderer{}, nil
}
Expand Down
23 changes: 21 additions & 2 deletions api/v1beta1/ibppeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

config "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/peer/config/v1"
v2config "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/peer/config/v2"
v25config "github.com/IBM-Blockchain/fabric-operator/pkg/initializer/peer/config/v25"
"github.com/IBM-Blockchain/fabric-operator/pkg/util/image"
"github.com/IBM-Blockchain/fabric-operator/version"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -99,15 +100,33 @@ func (p *IBPPeer) UsingCCLauncherImage() bool {
func (p *IBPPeer) EnrollerImage() string {
return image.Format(p.Spec.Images.EnrollerImage, p.Spec.Images.EnrollerTag)
}
func IsV25Peer(fabricVersion string) bool {
currentVer := version.String(fabricVersion)
if currentVer.EqualWithoutTag(version.V2_5_1) || currentVer.GreaterThan(version.V2_5_1) {
return true
}
return false
}

func (s *IBPPeer) GetConfigOverride() (interface{}, error) {
switch version.GetMajorReleaseVersion(s.Spec.FabricVersion) {
case version.V2:
isv25Peer := IsV25Peer(s.Spec.FabricVersion)
if s.Spec.ConfigOverride == nil {
return &v2config.Core{}, nil
if isv25Peer {
return &v25config.Core{}, nil
} else {
return &v2config.Core{}, nil
}
}

configOverride, err := v2config.ReadFrom(&s.Spec.ConfigOverride.Raw)
var configOverride interface{}
var err error
if isv25Peer {
configOverride, err = v25config.ReadFrom(&s.Spec.ConfigOverride.Raw)
} else {
configOverride, err = v2config.ReadFrom(&s.Spec.ConfigOverride.Raw)
}
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion config/ingress/kind/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ resources:
- https://github.com/kubernetes/ingress-nginx.git/deploy/static/provider/kind?ref=controller-v1.1.2

patchesStrategicMerge:
- ingress-nginx-controller.yaml
- ingress-nginx-controller.yaml
6 changes: 3 additions & 3 deletions controllers/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ type Client interface {
List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
}

// 1. Only one existing instance (of the same type as 'instance') should have
// the name 'instance.GetName()'; if more than one is present, return error
// 2. If any instance of a different type share the same name, return error
// 1. Only one existing instance (of the same type as 'instance') should have
// the name 'instance.GetName()'; if more than one is present, return error
// 2. If any instance of a different type share the same name, return error
func ValidateCRName(k8sclient Client, name, namespace, kind string) error {
listOptions := &client.ListOptions{
Namespace: namespace,
Expand Down
34 changes: 26 additions & 8 deletions controllers/ibporderer/ibporderer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -746,25 +746,43 @@ func (r *ReconcileIBPOrderer) UpdateFunc(e event.UpdateEvent) bool {
oldVer := version.String(oldOrderer.Spec.FabricVersion)
newVer := version.String(newOrderer.Spec.FabricVersion)

// check if this V1 -> V2.2.x/V2.4.x orderer migration
// check if this V1 -> V2.2.x/V2.4.x/v2.5.x orderer migration
if (oldOrderer.Spec.FabricVersion == "" ||
version.GetMajorReleaseVersion(oldOrderer.Spec.FabricVersion) == version.V1) &&
version.GetMajorReleaseVersion(newOrderer.Spec.FabricVersion) == version.V2 {
update.migrateToV2 = true
if newVer.EqualWithoutTag(version.V2_4_1) || newVer.GreaterThan(version.V2_4_1) {
if newVer.EqualWithoutTag(version.V2_5_1) || newVer.GreaterThan(version.V2_5_1) {
update.migrateToV25 = true
// Re-enrolling tls cert to include admin hostname in SAN (for orderers >=2.5.1)
update.tlscertReenrollNeeded = true
} else if newVer.EqualWithoutTag(version.V2_4_1) || newVer.GreaterThan(version.V2_4_1) {
update.migrateToV24 = true
// Re-enrolling tls cert to include admin hostname in SAN (for orderers >=2.4.1)
update.tlscertReenrollNeeded = true
}
}

// check if this V2.2.x -> V2.4.x/2.5.x orderer migration
if (version.GetMajorReleaseVersion(oldOrderer.Spec.FabricVersion) == version.V2) &&
oldVer.LessThan(version.V2_4_1) {
if newVer.EqualWithoutTag(version.V2_5_1) || newVer.GreaterThan(version.V2_5_1) {
update.migrateToV25 = true
// Re-enrolling tls cert to include admin hostname in SAN (for orderers >=2.4.1)
update.tlscertReenrollNeeded = true
} else if newVer.EqualWithoutTag(version.V2_4_1) || newVer.GreaterThan(version.V2_4_1) {
update.migrateToV24 = true
// Re-enrolling tls cert to include admin hostname in SAN (for orderers >=2.4.1)
update.tlscertReenrollNeeded = true
}
}

// check if this V2.2.x -> V2.4.x orderer migration
// check if this V2.4.x -> V2.5.x orderer migration
if (version.GetMajorReleaseVersion(oldOrderer.Spec.FabricVersion) == version.V2) &&
oldVer.LessThan(version.V2_4_1) &&
(newVer.EqualWithoutTag(version.V2_4_1) || newVer.GreaterThan(version.V2_4_1)) {
update.migrateToV24 = true
// Re-enrolling tls cert to include admin hostname in SAN (for orderers >=2.4.1)
update.tlscertReenrollNeeded = true
oldVer.LessThan(version.V2_5_1) &&
(newVer.EqualWithoutTag(version.V2_5_1) || newVer.GreaterThan(version.V2_5_1)) {
update.migrateToV25 = true
//Orderers >=2.4.1 alredy has the tls-cert renewed, we do not do this in this upgrade
//update.tlscertReenrollNeeded = true
}

if oldOrderer.Spec.NodeOUDisabled() != newOrderer.Spec.NodeOUDisabled() {
Expand Down
9 changes: 9 additions & 0 deletions controllers/ibporderer/predicate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type Update struct {
ecertCreated bool
migrateToV2 bool
migrateToV24 bool
migrateToV25 bool
nodeOUUpdated bool
imagesUpdated bool
fabricVersionUpdated bool
Expand All @@ -69,6 +70,7 @@ func (u *Update) Detected() bool {
u.ecertEnroll ||
u.migrateToV2 ||
u.migrateToV24 ||
u.migrateToV25 ||
u.nodeOUUpdated ||
u.imagesUpdated ||
u.fabricVersionUpdated
Expand Down Expand Up @@ -186,6 +188,10 @@ func (u *Update) MigrateToV24() bool {
return u.migrateToV24
}

func (u *Update) MigrateToV25() bool {
return u.migrateToV25
}

func (u *Update) NodeOUUpdated() bool {
return u.nodeOUUpdated
}
Expand Down Expand Up @@ -251,6 +257,9 @@ func (u *Update) GetUpdateStackWithTrues() string {
if u.migrateToV24 {
stack += "migrateToV24 "
}
if u.migrateToV25 {
stack += "migrateToV25 "
}
if u.nodeOUUpdated {
stack += "nodeOUUpdated "
}
Expand Down
Loading
Loading