Skip to content

Commit aa8f6bd

Browse files
[5.18 backport] Support key rotation to Azure vault (noobaa#1596) (noobaa#1795)
* Support key rotation to Azure vault (noobaa#1596) Signed-off-by: jackyalbo <jacky.albo@gmail.com> (cherry picked from commit 18b2405) * CI | adding Set up kind step to the yamls Signed-off-by: liranmauda <liran.mauda@gmail.com> (cherry picked from commit 8deec77) * Remove KMS condition status Init checks from tests - Removing False positive verification of KMS condition status Init The Init condition status is, in most cases, a state that is short in time, and the tests are missing the timing, hence failing. We do not need this case as corev1.ConditionStatus = "Sync" will never happen if Init did not, and we will fail there. Signed-off-by: liranmauda <liran.mauda@gmail.com> (cherry picked from commit de03454) --------- Signed-off-by: jackyalbo <jacky.albo@gmail.com> Signed-off-by: liranmauda <liran.mauda@gmail.com> Co-authored-by: liranmauda <liran.mauda@gmail.com>
1 parent 0209ef0 commit aa8f6bd

16 files changed

Lines changed: 108 additions & 47 deletions

.github/workflows/run_hac_test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ jobs:
1313
uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: "1.23"
16+
go-version-file: go.mod
17+
check-latest: true
18+
cache: true
19+
cache-dependency-path: |
20+
**/go.sum
21+
- name: Set up kind
22+
uses: helm/kind-action@v1
1723

1824
- name: Set environment variables
1925
run: |

.github/workflows/run_kms_azure_vault_test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ jobs:
1313
uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: "1.23"
16+
go-version-file: go.mod
17+
check-latest: true
18+
cache: true
19+
cache-dependency-path: |
20+
**/go.sum
21+
- name: Set up kind
22+
uses: helm/kind-action@v1
1723

1824
- name: Set environment variables
1925
run: |

.github/workflows/run_kms_dev_test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ jobs:
1313
uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: "1.23"
16+
go-version-file: go.mod
17+
check-latest: true
18+
cache: true
19+
cache-dependency-path: |
20+
**/go.sum
21+
- name: Set up kind
22+
uses: helm/kind-action@v1
1723

1824
- name: Set environment variables
1925
run: |

.github/workflows/run_kms_ibm_kp_test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ jobs:
1616
uses: actions/checkout@v4
1717
- uses: actions/setup-go@v5
1818
with:
19-
go-version: "1.23"
19+
go-version-file: go.mod
20+
check-latest: true
21+
cache: true
22+
cache-dependency-path: |
23+
**/go.sum
24+
- name: Set up kind
25+
uses: helm/kind-action@v1
2026

2127
- name: Set environment variables
2228
run: |

.github/workflows/run_kms_kmip_test.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,28 @@ jobs:
1313
uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: "1.23"
16+
go-version-file: go.mod
17+
check-latest: true
18+
cache: true
19+
cache-dependency-path: |
20+
**/go.sum
21+
- name: Set up kind
22+
uses: helm/kind-action@v1
1723

1824
- name: Set environment variables
1925
run: |
2026
echo PATH=$PATH:$HOME/go/bin >> $GITHUB_ENV
2127
echo OPERATOR_IMAGE=localhost:5000/noobaa/noobaa-operator:integration >> $GITHUB_ENV
2228
echo PYKMIP_IMAGE=localhost:5000/noobaa/pykmip:integration >> $GITHUB_ENV
23-
29+
2430
- name: Deploy Dependencies
2531
run: |
2632
set -x
2733
bash .travis/install-5nodes-kind-cluster.sh
2834
go get -v github.com/onsi/ginkgo/v2
2935
go install -v github.com/onsi/ginkgo/v2/ginkgo
3036
ginkgo version
31-
37+
3238
- name: Build NooBaa
3339
run: |
3440
make cli

.github/workflows/run_kms_rotate_test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ jobs:
1313
uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: "1.23"
16+
go-version-file: go.mod
17+
check-latest: true
18+
cache: true
19+
cache-dependency-path: |
20+
**/go.sum
21+
- name: Set up kind
22+
uses: helm/kind-action@v1
1723

1824
- name: Set environment variables
1925
run: |

.github/workflows/run_kms_tls_sa_test.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,13 @@ jobs:
1313
uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: "1.23"
17-
16+
go-version-file: go.mod
17+
check-latest: true
18+
cache: true
19+
cache-dependency-path: |
20+
**/go.sum
21+
- name: Set up kind
22+
uses: helm/kind-action@v1
1823
- name: Set environment variables
1924
run: |
2025
echo PATH=$PATH:$HOME/go/bin >> $GITHUB_ENV

.github/workflows/run_kms_tls_token_test.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,13 @@ jobs:
1313
uses: actions/checkout@v4
1414
- uses: actions/setup-go@v5
1515
with:
16-
go-version: "1.23"
16+
go-version-file: go.mod
17+
check-latest: true
18+
cache: true
19+
cache-dependency-path: |
20+
**/go.sum
21+
- name: Set up kind
22+
uses: helm/kind-action@v1
1723

1824
- name: Set environment variables
1925
run: |

pkg/util/kms/kms_azure.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ const (
2121
// AzureVault is a azure kms driver
2222
type AzureVault struct {
2323
UID string // NooBaa system UID
24+
name string // NooBaa system name
25+
ns string // NooBaa system namespace
2426
}
2527

2628
// NewAzureVault is azure driver constructor
@@ -29,7 +31,7 @@ func NewAzureVault(
2931
namespace string,
3032
uid string,
3133
) Driver {
32-
return &AzureVault{uid}
34+
return &AzureVault{uid, name, namespace}
3335
}
3436

3537
//
@@ -107,8 +109,8 @@ func createCertTempFile(config map[string]interface{}, namespace string) error {
107109

108110
// Version returns the current driver KMS version
109111
// either single string or map, i.e. rotating key
110-
func (*AzureVault) Version(kms *KMS) Version {
111-
return &VersionSingleSecret{kms, nil}
112+
func (k *AzureVault) Version(kms *KMS) Version {
113+
return &VersionRotatingSecret{VersionBase{kms, nil}, k.name, k.ns}
112114
}
113115

114116
// Register Azure driver with KMS layer

pkg/util/kms/test/azure-vault/kms_azure_vault_test.go

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package kmsazurevaulttest
33
import (
44
"os"
55

6+
"github.com/libopenstorage/secrets"
67
"github.com/libopenstorage/secrets/azure"
78
nbv1 "github.com/noobaa/noobaa-operator/v5/pkg/apis/noobaa/v1alpha1"
89
"github.com/noobaa/noobaa-operator/v5/pkg/options"
@@ -105,4 +106,48 @@ var _ = Describe("KMS - Azure Vault", func() {
105106
})
106107
})
107108

109+
Context("Verify Rotate", func() {
110+
noobaa := getMiniNooBaa()
111+
azureVaultURL, azureVaultURLFound := os.LookupEnv("AZURE_VAULT_URL")
112+
k := azureKMSSpec(azureVaultURL)
113+
noobaa.Spec.Security.KeyManagementService = k
114+
noobaa.Spec.Security.KeyManagementService.EnableKeyRotation = true
115+
noobaa.Spec.Security.KeyManagementService.Schedule = "* * * * *" // every min
116+
117+
Specify("Verify API Address", func() {
118+
Expect(azureVaultURLFound).To(BeTrue())
119+
})
120+
Specify("Create key rotate schedule system", func() {
121+
Expect(util.KubeCreateFailExisting(noobaa)).To(BeTrue())
122+
})
123+
// Change here to .To(BeTrue()) once fixed issue in line 53
124+
Specify("Verify KMS condition Type", func() {
125+
Expect(util.NooBaaCondition(noobaa, nbv1.ConditionTypeKMSType, secrets.TypeAzure)).To(BeFalse())
126+
})
127+
// Change here to .To(BeTrue()) once fixed issue in line 53
128+
Specify("Verify KMS condition status Init", func() {
129+
Expect(util.NooBaaCondStatus(noobaa, nbv1.ConditionKMSInit)).To(BeFalse())
130+
})
131+
Specify("Restart NooBaa operator", func() {
132+
podList := &corev1.PodList{}
133+
podSelector, _ := labels.Parse("noobaa-operator=deployment")
134+
listOptions := client.ListOptions{Namespace: options.Namespace, LabelSelector: podSelector}
135+
136+
Expect(util.KubeList(podList, &listOptions)).To(BeTrue())
137+
Expect(len(podList.Items)).To(BeEquivalentTo(1))
138+
Expect(util.KubeDelete(&podList.Items[0])).To(BeTrue())
139+
})
140+
// Change here to .To(BeTrue()) once fixed issue in line 53
141+
Specify("Verify KMS condition status Sync", func() {
142+
Expect(util.NooBaaCondStatus(noobaa, nbv1.ConditionKMSSync)).To(BeFalse())
143+
})
144+
// Change here to .To(BeTrue()) once fixed issue in line 53
145+
Specify("Verify KMS condition status Key Rotate", func() {
146+
Expect(util.NooBaaCondStatus(noobaa, nbv1.ConditionKMSKeyRotate)).To(BeFalse())
147+
})
148+
Specify("Delete NooBaa", func() {
149+
Expect(util.KubeDelete(noobaa)).To(BeTrue())
150+
})
151+
})
152+
108153
})

0 commit comments

Comments
 (0)