Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: red-hat-storage/ocs-operator
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: baa693ab7c3696aef9730dc9b7a4ea11d4cd99c4
Choose a base ref
..
head repository: red-hat-storage/ocs-operator
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cf7b6383ae331ea69c1849e5062da0f81ddf3837
Choose a head ref
Showing with 11 additions and 22 deletions.
  1. +2 −1 controllers/storagecluster/provider_server.go
  2. +1 −13 controllers/storagecluster/storagecluster_controller.go
  3. +0 −4 controllers/util/util.go
  4. +8 −4 onboarding/main.go
3 changes: 2 additions & 1 deletion controllers/storagecluster/provider_server.go
Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/utils/ptr"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
@@ -455,7 +456,7 @@ func getOnboardingJobObject(instance *ocsv1.StorageCluster) *batchv1.Job {
},
Spec: batchv1.JobSpec{
// Eligible to delete automatically when job finishes
TTLSecondsAfterFinished: util.ToPointer[int32](0),
TTLSecondsAfterFinished: ptr.To(int32(0)),
Template: corev1.PodTemplateSpec{
Spec: corev1.PodSpec{
RestartPolicy: corev1.RestartPolicyOnFailure,
14 changes: 1 addition & 13 deletions controllers/storagecluster/storagecluster_controller.go
Original file line number Diff line number Diff line change
@@ -164,26 +164,14 @@ func (r *StorageClusterReconciler) SetupWithManager(mgr ctrl.Manager) error {
},
}

secretPredicate := predicate.Funcs{
DeleteFunc: func(e event.DeleteEvent) bool {
return true
},
CreateFunc: func(e event.CreateEvent) bool {
return e.Object.GetName() != onboardingTicketPublicKeySecretName
},
UpdateFunc: func(e event.UpdateEvent) bool {
return e.ObjectNew.GetName() != onboardingTicketPublicKeySecretName
},
}

builder := ctrl.NewControllerManagedBy(mgr).
For(&ocsv1.StorageCluster{}, builder.WithPredicates(scPredicate)).
Owns(&cephv1.CephCluster{}).
Owns(&corev1.PersistentVolumeClaim{}, builder.WithPredicates(pvcPredicate)).
Owns(&appsv1.Deployment{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Owns(&corev1.Service{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Owns(&corev1.ConfigMap{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Owns(&corev1.Secret{}, builder.WithPredicates(secretPredicate)).
Owns(&corev1.Secret{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})).
Watches(&ocsv1.StorageProfile{}, enqueueStorageClusterRequest).
Watches(
&extv1.CustomResourceDefinition{
4 changes: 0 additions & 4 deletions controllers/util/util.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,3 @@ func DetectDuplicateInStringSlice(slice []string) bool {
}
return false
}

func ToPointer[T any](value T) *T {
return &value
}
12 changes: 8 additions & 4 deletions onboarding/main.go
Original file line number Diff line number Diff line change
@@ -141,7 +141,7 @@ func newClient() (*kubernetes.Clientset, error) {
config := runtime.GetConfigOrDie()
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
return nil, fmt.Errorf("failed to create clientset: %v", err)
return nil, err
}

return clientset, nil
@@ -165,13 +165,17 @@ func convertRsaPublicKeyAsPemStr(publicKey *rsa.PublicKey) (string, error) {

func getStorageClusterMetadata(ctx context.Context, operatorNamespace string, clientset *kubernetes.Clientset) (*metav1.PartialObjectMetadata, error) {
var storageClusterMetadata metav1.PartialObjectMetadata
storageClusterGVKPath := fmt.Sprintf("/apis/%s/%s/namespaces/%s/%s/%s", "ocs.openshift.io", "v1", operatorNamespace, "storageclusters", storageClusterName)
instance, err := clientset.RESTClient().Get().AbsPath(storageClusterGVKPath).Do(ctx).Raw()
storageClusterGVKPath := fmt.Sprintf(
"/apis/ocs.openshift.io/v1/namespaces/%s/storageclusters/%s",
operatorNamespace,
storageClusterName,
)
storageClusterMetadataJSON, err := clientset.RESTClient().Get().AbsPath(storageClusterGVKPath).Do(ctx).Raw()
if err != nil {
return nil, fmt.Errorf("failed to get storage cluster metadata: %v", err)
}

if err = json.Unmarshal(instance, &storageClusterMetadata); err != nil {
if err = json.Unmarshal(storageClusterMetadataJSON, &storageClusterMetadata); err != nil {
return nil, fmt.Errorf("failed to parse storage cluster metadata response: %v", err)
}