-
Notifications
You must be signed in to change notification settings - Fork 6
feat(sync): Support Kerberos authentication for HDFS sync #101
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
17cc789
feat(sync): Support Kerberos authentication for HDFS sync
sw-cho 60db5ce
Fix error message
sw-cho eeba52e
Add comments to kerberos related fields
sw-cho 1c69e51
Add test case for HDFS-to-HDFS sync rejection
sw-cho 880adaa
Prevent setting both KRB5Keytab and KRB5KeytabBase64
sw-cho 4909db4
chore: sync generated deepcopy with struct field changes
sw-cho File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -81,4 +81,82 @@ var _ = Describe("Sync Controller", func() { | |
| // Example: If you expect a certain status condition after reconciliation, verify it here. | ||
| }) | ||
| }) | ||
|
|
||
| Context("When rejecting HDFS-to-HDFS sync", func() { | ||
| const hdfsToHdfsResourceName = "hdfs-to-hdfs-sync" | ||
|
|
||
| ctx := context.Background() | ||
|
|
||
| typeNamespacedName := types.NamespacedName{ | ||
| Name: hdfsToHdfsResourceName, | ||
| Namespace: "default", | ||
| } | ||
|
|
||
| BeforeEach(func() { | ||
| By("creating a Sync resource with both from and to as HDFS") | ||
| resource := &juicefsiov1.Sync{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: hdfsToHdfsResourceName, | ||
| Namespace: "default", | ||
| }, | ||
| Spec: juicefsiov1.SyncSpec{ | ||
| Image: "juicedata/mount:ce-v1.3.0", | ||
| From: juicefsiov1.SyncSink{ | ||
| External: &juicefsiov1.SyncSinkExternal{ | ||
| Uri: "hdfs://example.com/user/source/", | ||
| KRB5Principal: juicefsiov1.SyncSinkValue{ | ||
| Value: "hdfs/[email protected]", | ||
| }, | ||
| KRB5KeytabBase64: juicefsiov1.SyncSinkValue{ | ||
| Value: "dGVzdC1rZXl0YWItYmFzZTY0", | ||
| }, | ||
| }, | ||
| }, | ||
| To: juicefsiov1.SyncSink{ | ||
| External: &juicefsiov1.SyncSinkExternal{ | ||
| Uri: "hdfs://example.com/user/destination/", | ||
| KRB5Principal: juicefsiov1.SyncSinkValue{ | ||
| Value: "hdfs/[email protected]", | ||
| }, | ||
| KRB5KeytabBase64: juicefsiov1.SyncSinkValue{ | ||
| Value: "dGVzdC1rZXl0YWItYmFzZTY0", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| err := k8sClient.Get(ctx, typeNamespacedName, &juicefsiov1.Sync{}) | ||
| if err != nil && errors.IsNotFound(err) { | ||
| Expect(k8sClient.Create(ctx, resource)).To(Succeed()) | ||
| } | ||
| }) | ||
|
|
||
| AfterEach(func() { | ||
| By("cleaning up the HDFS-to-HDFS sync resource") | ||
| resource := &juicefsiov1.Sync{} | ||
| err := k8sClient.Get(ctx, typeNamespacedName, resource) | ||
| if err == nil { | ||
| Expect(k8sClient.Delete(ctx, resource)).To(Succeed()) | ||
| } | ||
| }) | ||
|
|
||
| It("should reject sync and set status to Failed with appropriate reason", func() { | ||
| By("reconciling the HDFS-to-HDFS sync resource") | ||
| controllerReconciler := &SyncReconciler{ | ||
| Client: k8sClient, | ||
| Scheme: k8sClient.Scheme(), | ||
| } | ||
|
|
||
| _, err := controllerReconciler.Reconcile(ctx, reconcile.Request{ | ||
| NamespacedName: typeNamespacedName, | ||
| }) | ||
| Expect(err).NotTo(HaveOccurred()) | ||
|
|
||
| By("verifying the sync status is set to Failed") | ||
| sync := &juicefsiov1.Sync{} | ||
| Expect(k8sClient.Get(ctx, typeNamespacedName, sync)).To(Succeed()) | ||
| Expect(sync.Status.Phase).To(Equal(juicefsiov1.SyncPhaseFailed)) | ||
| Expect(sync.Status.Reason).To(ContainSubstring("HDFS-to-HDFS sync is not supported")) | ||
| }) | ||
| }) | ||
| }) | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -318,6 +318,103 @@ func TestParseSyncSink(t *testing.T) { | |
| want: nil, | ||
| wantErr: true, | ||
| }, | ||
| { | ||
| name: "HDFS sink with KRB5Principal and KRB5Keytab", | ||
| sink: juicefsiov1.SyncSink{ | ||
| External: &juicefsiov1.SyncSinkExternal{ | ||
| Uri: "hdfs://example.com/user/test/", | ||
| KRB5Principal: juicefsiov1.SyncSinkValue{ | ||
| Value: "hdfs/[email protected]", | ||
| }, | ||
| KRB5Keytab: juicefsiov1.SyncSinkValue{ | ||
| Value: "/root/keytab/keytab", | ||
| }, | ||
| }, | ||
| }, | ||
| syncName: "sync4", | ||
| ref: "FROM", | ||
| want: &juicefsiov1.ParsedSyncSink{ | ||
| Uri: "hdfs://example.com/user/test/", | ||
| Envs: []corev1.EnvVar{ | ||
| { | ||
| Name: "EXTERNAL_FROM_KRB5KEYTAB", | ||
| ValueFrom: &corev1.EnvVarSource{ | ||
| SecretKeyRef: &corev1.SecretKeySelector{ | ||
| LocalObjectReference: corev1.LocalObjectReference{ | ||
| Name: common.GenSyncSecretName("sync4"), | ||
| }, | ||
| Key: "EXTERNAL_FROM_KRB5KEYTAB", | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| Name: "EXTERNAL_FROM_KRB5PRINCIPAL", | ||
| ValueFrom: &corev1.EnvVarSource{ | ||
| SecretKeyRef: &corev1.SecretKeySelector{ | ||
| LocalObjectReference: corev1.LocalObjectReference{ | ||
| Name: common.GenSyncSecretName("sync4"), | ||
| }, | ||
| Key: "EXTERNAL_FROM_KRB5PRINCIPAL", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| PrepareCommand: "export KRB5KEYTAB=$EXTERNAL_FROM_KRB5KEYTAB\nexport KRB5PRINCIPAL=$EXTERNAL_FROM_KRB5PRINCIPAL\n", | ||
| }, | ||
| wantErr: false, | ||
| }, | ||
| { | ||
| name: "HDFS sink with KRB5Principal and KRB5KeytabBase64", | ||
| sink: juicefsiov1.SyncSink{ | ||
| External: &juicefsiov1.SyncSinkExternal{ | ||
| Uri: "hdfs://example.com/user/test/", | ||
| KRB5Principal: juicefsiov1.SyncSinkValue{ | ||
| Value: "hdfs/[email protected]", | ||
| }, | ||
| KRB5KeytabBase64: juicefsiov1.SyncSinkValue{ | ||
| ValueFrom: &corev1.EnvVarSource{ | ||
| SecretKeyRef: &corev1.SecretKeySelector{ | ||
| LocalObjectReference: corev1.LocalObjectReference{ | ||
| Name: "keytabbase64-secret", | ||
| }, | ||
| Key: "KRB5KEYTAB_BASE64", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| syncName: "sync5", | ||
| ref: "FROM", | ||
| want: &juicefsiov1.ParsedSyncSink{ | ||
| Uri: "hdfs://example.com/user/test/", | ||
| Envs: []corev1.EnvVar{ | ||
| { | ||
| Name: "EXTERNAL_FROM_KRB5KEYTAB_BASE64", | ||
| ValueFrom: &corev1.EnvVarSource{ | ||
| SecretKeyRef: &corev1.SecretKeySelector{ | ||
| LocalObjectReference: corev1.LocalObjectReference{ | ||
| Name: "keytabbase64-secret", | ||
| }, | ||
| Key: "KRB5KEYTAB_BASE64", | ||
| }, | ||
| }, | ||
| }, | ||
| { | ||
| Name: "EXTERNAL_FROM_KRB5PRINCIPAL", | ||
| ValueFrom: &corev1.EnvVarSource{ | ||
| SecretKeyRef: &corev1.SecretKeySelector{ | ||
| LocalObjectReference: corev1.LocalObjectReference{ | ||
| Name: common.GenSyncSecretName("sync5"), | ||
| }, | ||
| Key: "EXTERNAL_FROM_KRB5PRINCIPAL", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| PrepareCommand: "export KRB5KEYTAB_BASE64=$EXTERNAL_FROM_KRB5KEYTAB_BASE64\nexport KRB5PRINCIPAL=$EXTERNAL_FROM_KRB5PRINCIPAL\n", | ||
| }, | ||
| wantErr: false, | ||
| }, | ||
| } | ||
|
|
||
| for _, tt := range tests { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.