Skip to content

Commit

Permalink
fixed re trigger job issue when public key deleted
Browse files Browse the repository at this point in the history
Signed-off-by: rchikatw <[email protected]>
  • Loading branch information
rchikatw committed Jan 19, 2024
1 parent bd55cf0 commit 270454e
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions controllers/storagecluster/provider_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,8 @@ func getOnboardingJobObject(instance *ocsv1.StorageCluster) *batchv1.Job {
Namespace: instance.Namespace,
},
Spec: batchv1.JobSpec{
// Eligible to delete automatically when job finishes
TTLSecondsAfterFinished: util.ToPointer[int32](0),
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyOnFailure,
Expand Down
4 changes: 4 additions & 0 deletions controllers/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ func DetectDuplicateInStringSlice(slice []string) bool {
}
return false
}

func ToPointer[T any](value T) *T {
return &value
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ rules:
- get
- list
- create
- update
5 changes: 5 additions & 0 deletions onboarding/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,15 @@ func main() {

_, err = clientset.CoreV1().Secrets(operatorNamespace).Create(context.Background(), privateSecret, metav1.CreateOptions{})

if err != nil && kerrors.IsAlreadyExists(err) {
_, err = clientset.CoreV1().Secrets(operatorNamespace).Update(context.Background(), privateSecret, metav1.UpdateOptions{})
}

if err != nil {
klog.Error(err, "Failed to create private secret.")
os.Exit(1)
}

publicSecret := &corev1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: onboardingTicketPublicKeySecretName,
Expand Down
1 change: 1 addition & 0 deletions rbac/onboarding-secret-generator-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ rules:
- get
- list
- create
- update
6 changes: 2 additions & 4 deletions tools/csv-merger/csv-merger.go
Original file line number Diff line number Diff line change
Expand Up @@ -925,10 +925,8 @@ func copyManifests() {
}

func getUXBackendServerDeployment() appsv1.DeploymentSpec {
replica := int32(1)
ptrToTrue := true
deployment := appsv1.DeploymentSpec{
Replicas: &replica,
Replicas: util.ToPointer[int32](1),
Selector: &metav1.LabelSelector{
MatchLabels: map[string]string{
"app.kubernetes.io/component": "ux-backend-server",
Expand Down Expand Up @@ -1019,7 +1017,7 @@ func getUXBackendServerDeployment() appsv1.DeploymentSpec {
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: "onboarding-private-key",
Optional: &ptrToTrue,
Optional: util.ToPointer[bool](true),
},
},
},
Expand Down

0 comments on commit 270454e

Please sign in to comment.