Skip to content

Commit

Permalink
[CN-812] Rename secret to secretName for ManagementCenter and HotBack…
Browse files Browse the repository at this point in the history
…up (#740)

* change MC licenseKeySecret to licenseKeySecretName

* change HotBackup secret to secretName

* Update test/e2e/helpers_test.go

Co-authored-by: Semih Buyukgungor <semih.buyukgungor@hazelcast.com>

* Update test/e2e/config/managementcenter/config.go

Co-authored-by: Semih Buyukgungor <semih.buyukgungor@hazelcast.com>

* formating clean up

* fix validation error message

---------

Co-authored-by: Semih Buyukgungor <semih.buyukgungor@hazelcast.com>
  • Loading branch information
SeriyBg and semihbkgr committed May 17, 2023
1 parent b1033a4 commit 28f77b0
Show file tree
Hide file tree
Showing 38 changed files with 103 additions and 63 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/hazelcast_validation.go
Expand Up @@ -104,7 +104,7 @@ func validateExposeExternally(h *Hazelcast) *field.Error {

func validateLicense(h *Hazelcast) *field.Error {
if checkEnterprise(h.Spec.Repository) && len(h.Spec.GetLicenseKeySecretName()) == 0 {
return field.Required(field.NewPath("spec").Child("licenseKeySecret"),
return field.Required(field.NewPath("spec").Child("licenseKeySecretName"),
"must be set when Hazelcast Enterprise is deployed")
}

Expand All @@ -119,7 +119,7 @@ func validateLicense(h *Hazelcast) *field.Error {
err := kubeclient.Get(context.Background(), secretName, &secret)
if kerrors.IsNotFound(err) {
// we care only about not found error
return field.NotFound(field.NewPath("spec").Child("licenseKeySecret"),
return field.NotFound(field.NewPath("spec").Child("licenseKeySecretName"),
"Hazelcast Enterprise licenseKeySecret is not found")
}
}
Expand Down
15 changes: 13 additions & 2 deletions api/v1alpha1/hotbackup_types.go
Expand Up @@ -88,13 +88,24 @@ type HotBackupSpec struct {
// +optional
BucketURI string `json:"bucketURI,omitempty"`

// secret is a deprecated alias for secretName.
// +optional
DeprecatedSecret string `json:"secret,omitempty"`

// Name of the secret with credentials for cloud providers.
// +optional
Secret string `json:"secret,omitempty"`
SecretName string `json:"secretName,omitempty"`
}

func (hbs *HotBackupSpec) GetSecretName() string {
if hbs.SecretName == "" {
return hbs.DeprecatedSecret
}
return hbs.SecretName
}

func (hbs *HotBackupSpec) IsExternal() bool {
return hbs.BucketURI != "" && hbs.Secret != ""
return hbs.BucketURI != "" && hbs.GetSecretName() != ""
}

//+kubebuilder:object:root=true
Expand Down
13 changes: 12 additions & 1 deletion api/v1alpha1/managementcenter_types.go
Expand Up @@ -29,9 +29,13 @@ type ManagementCenterSpec struct {
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`

// licenseKeySecret is a deprecated alias for licenseKeySecretName.
// +optional
DeprecatedLicenseKeySecret string `json:"licenseKeySecret,omitempty"`

// Name of the secret with Hazelcast Enterprise License Key.
// +optional
LicenseKeySecret string `json:"licenseKeySecret,omitempty"`
LicenseKeySecretName string `json:"licenseKeySecretName,omitempty"`

// Connection configuration for the Hazelcast clusters that Management Center will monitor.
// +optional
Expand All @@ -58,6 +62,13 @@ type ManagementCenterSpec struct {
Resources corev1.ResourceRequirements `json:"resources,omitempty"`
}

func (s *ManagementCenterSpec) GetLicenseKeySecretName() string {
if s.LicenseKeySecretName == "" {
return s.DeprecatedLicenseKeySecret
}
return s.LicenseKeySecretName
}

type HazelcastClusterConfig struct {
// Name of the Hazelcast cluster that Management Center will connect to, default is dev.
// +kubebuilder:default:="dev"
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/hazelcast.com_cronhotbackups.yaml
Expand Up @@ -73,6 +73,9 @@ spec:
Hazelcast resource
type: string
secret:
description: secret is a deprecated alias for secretName.
type: string
secretName:
description: Name of the secret with credentials for cloud
providers.
type: string
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/hazelcast.com_hotbackups.yaml
Expand Up @@ -58,6 +58,9 @@ spec:
resource
type: string
secret:
description: secret is a deprecated alias for secretName.
type: string
secretName:
description: Name of the secret with credentials for cloud providers.
type: string
required:
Expand Down
3 changes: 3 additions & 0 deletions config/crd/bases/hazelcast.com_managementcenters.yaml
Expand Up @@ -153,6 +153,9 @@ spec:
x-kubernetes-map-type: atomic
type: array
licenseKeySecret:
description: licenseKeySecret is a deprecated alias for licenseKeySecretName.
type: string
licenseKeySecretName:
description: Name of the secret with Hazelcast Enterprise License
Key.
type: string
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast.yaml
Expand Up @@ -5,4 +5,4 @@ metadata:
spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_executor_service.yaml
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
userCodeDeployment:
bucketConfig:
secret: br-secret-gcp
secretName: br-secret-gcp
bucketURI: "gs://operator-custom-class/executorService"
executorServices:
- name: service1
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_expose_externally.yaml
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
exposeExternally:
type: Smart
discoveryServiceType: LoadBalancer
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_high_availability.yaml
Expand Up @@ -6,4 +6,4 @@ spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
highAvailabilityMode: ZONE
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_jet.yaml
Expand Up @@ -6,7 +6,7 @@ spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
version: '5.3.0-BETA-2'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
jet:
enabled: true
resourceUploadEnabled: true
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_jet_job_upload.yaml
Expand Up @@ -12,4 +12,4 @@ spec:
resourceUploadEnabled: true
bucketConfig:
bucketURI: "gs://operator-user-code/jetJobs"
secret: br-secret-gcp
secretName: br-secret-gcp
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_jvm_gc.yaml
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
jvm:
args:
- "-XX:MaxGCPauseMillis=200"
Expand Down
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
managementCenter:
scriptingEnabled: true
consoleEnabled: true
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_persistence.yaml
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
persistence:
baseDir: "/data/hot-restart/"
clusterDataRecoveryPolicy: "FullRecoveryOnly"
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_persistence_agent.yaml
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
agent:
repository: hazelcast/platform-operator-agent
persistence:
Expand Down
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterSize: 3
repository: 'docker.io/hazelcast/hazelcast-enterprise'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
persistence:
baseDir: "/data/hot-restart/"
clusterDataRecoveryPolicy: "FullRecoveryOnly"
Expand Down
4 changes: 2 additions & 2 deletions config/samples/_v1alpha1_hazelcast_persistence_restore.yaml
Expand Up @@ -5,7 +5,7 @@ metadata:
spec:
clusterSize: 3
repository: "docker.io/hazelcast/hazelcast-enterprise"
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
agent:
repository: hazelcast/platform-operator-agent
persistence:
Expand All @@ -16,5 +16,5 @@ spec:
requestStorage: 8Gi
restore:
bucketConfig:
secret: br-secret-az
secretName: br-secret-az
bucketURI: "azblob://backup?prefix=hazelcast/2022-06-02-21-57-49/"
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_tls.yaml
Expand Up @@ -4,6 +4,6 @@ metadata:
name: hazelcast
spec:
clusterSize: 3
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
tls:
secretName: example
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_hazelcast_user_code_bucket.yaml
Expand Up @@ -5,5 +5,5 @@ metadata:
spec:
userCodeDeployment:
bucketConfig:
secret: br-secret-gcp
secretName: br-secret-gcp
bucketURI: "gs://operator-user-code/entryListener"
6 changes: 3 additions & 3 deletions config/samples/_v1alpha1_hotbackup_agent.yaml
Expand Up @@ -5,10 +5,10 @@ metadata:
spec:
hazelcastResourceName: hazelcast
bucketURI: "s3://operator-e2e-external-backup"
secret: "br-secret-s3"
secretName: "br-secret-s3"

# bucketURI: "gs://operator-agent-backup"
# secret: "br-secret-gcp"
# secretName: "br-secret-gcp"

# bucketURI: "azblob://backup"
# secret: "br-secret-az"
# secretName: "br-secret-az"
4 changes: 2 additions & 2 deletions config/samples/_v1alpha1_jetjob.yaml
Expand Up @@ -10,9 +10,9 @@ spec:
resourceUploadEnabled: true
bucketConfig:
bucketURI: "gs://operator-user-code/jetJobs"
secret: br-secret-gcp
secretName: br-secret-gcp
version: '5.3.0-BETA-2'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
---
apiVersion: hazelcast.com/v1alpha1
kind: JetJob
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_jetjob_dynamic.yaml
Expand Up @@ -15,5 +15,5 @@ spec:
jarName: jet-pipeline-1.0.2.jar
bucketConfig:
bucketURI: "gs://operator-user-code/jetJobs"
secret: br-secret-gcp
secretName: br-secret-gcp

2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_managementcenter.yaml
Expand Up @@ -4,7 +4,7 @@ metadata:
name: managementcenter
spec:
repository: 'hazelcast/management-center'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
externalConnectivity:
type: LoadBalancer
hazelcastClusters:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_managementcenter_ingress.yaml
Expand Up @@ -4,7 +4,7 @@ metadata:
name: managementcenter
spec:
repository: 'hazelcast/management-center'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
externalConnectivity:
type: ClusterIP
ingress:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_managementcenter_no_pvc.yaml
Expand Up @@ -4,7 +4,7 @@ metadata:
name: managementcenter
spec:
repository: 'hazelcast/management-center'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
externalConnectivity:
type: LoadBalancer
hazelcastClusters:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_managementcenter_route.yaml
Expand Up @@ -4,7 +4,7 @@ metadata:
name: managementcenter
spec:
repository: 'hazelcast/management-center'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
externalConnectivity:
type: ClusterIP
route:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/_v1alpha1_managementcenter_tls.yaml
Expand Up @@ -4,7 +4,7 @@ metadata:
name: managementcenter
spec:
repository: 'hazelcast/management-center'
licenseKeySecret: hazelcast-license-key
licenseKeySecretName: hazelcast-license-key
externalConnectivity:
type: LoadBalancer
hazelcastClusters:
Expand Down
2 changes: 1 addition & 1 deletion controllers/hazelcast/hazelcast_resources.go
Expand Up @@ -1718,7 +1718,7 @@ func getRestoreContainerFromHotBackupResource(ctx context.Context, cl client.Cli
var cont corev1.Container
if hb.Spec.IsExternal() {
bucketURI := hb.Status.GetBucketURI()
cont = restoreAgentContainer(h, hb.Spec.Secret, bucketURI)
cont = restoreAgentContainer(h, hb.Spec.GetSecretName(), bucketURI)
} else {
backupFolder := hb.Status.GetBackupFolder()
cont = restoreLocalAgentContainer(h, backupFolder)
Expand Down
2 changes: 1 addition & 1 deletion controllers/hazelcast/hot_backup_controller.go
Expand Up @@ -322,7 +322,7 @@ func (r *HotBackupReconciler) startBackup(ctx context.Context, backupName types.
BucketURI: hb.Spec.BucketURI,
BackupBaseDir: hz.Spec.Persistence.BaseDir,
HazelcastName: hb.Spec.HazelcastResourceName,
SecretName: hb.Spec.Secret,
SecretName: hb.Spec.GetSecretName(),
MemberID: i,
})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions controllers/managementcenter/managementcenter_resources.go
Expand Up @@ -462,14 +462,14 @@ func configMount() corev1.VolumeMount {
func env(mc *hazelcastv1alpha1.ManagementCenter) []v1.EnvVar {
envs := []v1.EnvVar{{Name: mcInitCmd, Value: clusterAddCommand(mc)}}

if mc.Spec.LicenseKeySecret != "" {
if mc.Spec.GetLicenseKeySecretName() != "" {
envs = append(envs,
v1.EnvVar{
Name: mcLicenseKey,
ValueFrom: &v1.EnvVarSource{
SecretKeyRef: &v1.SecretKeySelector{
LocalObjectReference: v1.LocalObjectReference{
Name: mc.Spec.LicenseKeySecret,
Name: mc.Spec.GetLicenseKeySecretName(),
},
Key: n.LicenseDataKey,
},
Expand Down
Expand Up @@ -201,6 +201,9 @@ spec:
Hazelcast resource
type: string
secret:
description: secret is a deprecated alias for secretName.
type: string
secretName:
description: Name of the secret with credentials for cloud
providers.
type: string
Expand Down Expand Up @@ -2170,6 +2173,9 @@ spec:
resource
type: string
secret:
description: secret is a deprecated alias for secretName.
type: string
secretName:
description: Name of the secret with credentials for cloud providers.
type: string
required:
Expand Down Expand Up @@ -2503,6 +2509,9 @@ spec:
x-kubernetes-map-type: atomic
type: array
licenseKeySecret:
description: licenseKeySecret is a deprecated alias for licenseKeySecretName.
type: string
licenseKeySecretName:
description: Name of the secret with Hazelcast Enterprise License
Key.
type: string
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/config/hazelcast/config.go
Expand Up @@ -385,7 +385,7 @@ var (
Spec: hazelcastv1alpha1.HotBackupSpec{
HazelcastResourceName: hzName,
BucketURI: bucketURI,
Secret: secretName,
SecretName: secretName,
},
}
}
Expand Down

0 comments on commit 28f77b0

Please sign in to comment.