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

issue-698, Save default user ref for zookeeper #710

Merged
merged 1 commit into from
Feb 15, 2024
Merged
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
6 changes: 3 additions & 3 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,14 @@
"filename": "apis/clusters/v1beta1/zookeeper_types.go",
"hashed_secret": "5ffe533b830f08a0326348a9160afafc8ada44db",
"is_verified": false,
"line_number": 234
"line_number": 235
},
{
"type": "Secret Keyword",
"filename": "apis/clusters/v1beta1/zookeeper_types.go",
"hashed_secret": "5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8",
"is_verified": false,
"line_number": 239
"line_number": 240
}
],
"apis/clusters/v1beta1/zz_generated.deepcopy.go": [
Expand Down Expand Up @@ -1130,5 +1130,5 @@
}
]
},
"generated_at": "2024-02-12T11:41:39Z"
"generated_at": "2024-02-15T12:14:33Z"
}
3 changes: 2 additions & 1 deletion apis/clusters/v1beta1/zookeeper_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ type ZookeeperStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

ClusterStatus `json:",inline"`
ClusterStatus `json:",inline"`
DefaultUserSecretRef *Reference `json:"defaultUserSecretRef,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down
5 changes: 5 additions & 0 deletions apis/clusters/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions config/crd/bases/clusters.instaclustr.com_zookeepers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,17 @@ spec:
type: string
type: object
type: array
defaultUserSecretRef:
description: ObjectReference is namespaced reference to an object
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
id:
type: string
maintenanceEvents:
Expand Down
19 changes: 19 additions & 0 deletions controllers/clusters/zookeeper_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ func (r *ZookeeperReconciler) createDefaultSecret(ctx context.Context, zk *v1bet
return err
}

patch := zk.NewPatch()
secret := zk.NewDefaultUserSecret(username, password)
err = r.Create(ctx, secret)
if err != nil {
Expand All @@ -224,6 +225,24 @@ func (r *ZookeeperReconciler) createDefaultSecret(ctx context.Context, zk *v1bet
return err
}

zk.Status.DefaultUserSecretRef = &v1beta1.Reference{
Name: secret.Name,
Namespace: secret.Namespace,
}

err = r.Status().Patch(ctx, zk, patch)
if err != nil {
l.Error(err, "Cannot patch Zookeeper resource",
"cluster name", zk.Spec.Name,
"status", zk.Status)

r.EventRecorder.Eventf(
zk, models.Warning, models.PatchFailed,
"Cluster resource patch is failed. Reason: %v", err)

return err
}

return nil
}

Expand Down
Loading