Skip to content

Commit

Permalink
Merge pull request #371 from sthaha/fix-redfish-crash
Browse files Browse the repository at this point in the history
fix(redfish): skip internals without redfish secret
  • Loading branch information
vimalk78 authored Mar 11, 2024
2 parents ef88a4d + 7fd0828 commit 978ea73
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ metadata:
capabilities: Basic Install
categories: Monitoring
containerImage: quay.io/sustainable_computing_io/kepler-operator:0.10.0
createdAt: "2024-03-11T03:26:22Z"
createdAt: "2024-03-11T09:21:02Z"
description: 'Deploys and Manages Kepler on Kubernetes '
operators.operatorframework.io/builder: operator-sdk-v1.27.0
operators.operatorframework.io/internal-objects: |-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,15 @@ spec:
description: RedfishSpec for connecting to Redfish API
properties:
probeInterval:
default: 60s
description: ProbeInterval controls how frequently power info
is queried from Redfish
type: string
secretRef:
description: SecretRef refers to the name of secret which
contains credentials to initialize RedfishClient
maxLength: 63
minLength: 1
type: string
skipSSLVerify:
default: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,15 @@ spec:
description: RedfishSpec for connecting to Redfish API
properties:
probeInterval:
default: 60s
description: ProbeInterval controls how frequently power info
is queried from Redfish
type: string
secretRef:
description: SecretRef refers to the name of secret which
contains credentials to initialize RedfishClient
maxLength: 63
minLength: 1
type: string
skipSSLVerify:
default: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,15 @@ spec:
description: RedfishSpec for connecting to Redfish API
properties:
probeInterval:
default: 60s
description: ProbeInterval controls how frequently power info
is queried from Redfish
type: string
secretRef:
description: SecretRef refers to the name of secret which
contains credentials to initialize RedfishClient
maxLength: 63
minLength: 1
type: string
skipSSLVerify:
default: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,15 @@ spec:
description: RedfishSpec for connecting to Redfish API
properties:
probeInterval:
default: 60s
description: ProbeInterval controls how frequently power info
is queried from Redfish
type: string
secretRef:
description: SecretRef refers to the name of secret which
contains credentials to initialize RedfishClient
maxLength: 63
minLength: 1
type: string
skipSSLVerify:
default: false
Expand Down
4 changes: 4 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ RedfishSpec for connecting to Redfish API
<td>string</td>
<td>
ProbeInterval controls how frequently power info is queried from Redfish<br/>
<br/>
<i>Default</i>: 60s<br/>
</td>
<td>false</td>
</tr><tr>
Expand Down Expand Up @@ -1714,6 +1716,8 @@ RedfishSpec for connecting to Redfish API
<td>string</td>
<td>
ProbeInterval controls how frequently power info is queried from Redfish<br/>
<br/>
<i>Default</i>: 60s<br/>
</td>
<td>false</td>
</tr><tr>
Expand Down
5 changes: 5 additions & 0 deletions pkg/api/v1alpha1/kepler_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,15 @@ type ExporterDeploymentSpec struct {
// RedfishSpec for connecting to Redfish API
type RedfishSpec struct {
// SecretRef refers to the name of secret which contains credentials to initialize RedfishClient
// +required
// +kubebuilder:validation:Required
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=63
SecretRef string `json:"secretRef"`

// ProbeInterval controls how frequently power info is queried from Redfish
// +optional
// +kubebuilder:default:="60s"
ProbeInterval metav1.Duration `json:"probeInterval,omitempty"`

// SkipSSLVerify controls if RedfishClient will skip verifying server
Expand Down
10 changes: 9 additions & 1 deletion pkg/controllers/kepler_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ func (r *KeplerInternalReconciler) SetupWithManager(mgr ctrl.Manager) error {
// mapSecretToRequests returns the reconcile requests for kepler-internal objects for which an associated redfish secret has been changed.
func (r *KeplerInternalReconciler) mapSecretToRequests(ctx context.Context, object client.Object) []reconcile.Request {

secret, _ := object.(*corev1.Secret)
secret, ok := object.(*corev1.Secret)
if !ok {
return nil
}

ks := v1alpha1.KeplerInternalList{}
if err := r.List(ctx, &ks); err != nil {
Expand All @@ -101,6 +104,11 @@ func (r *KeplerInternalReconciler) mapSecretToRequests(ctx context.Context, obje
requests := []reconcile.Request{}
for _, ki := range ks.Items {
ex := ki.Spec.Exporter

if ex.Redfish == nil {
continue
}

if ex.Redfish.SecretRef == secret.GetName() &&
ex.Deployment.Namespace == secret.GetNamespace() {
requests = append(requests, reconcile.Request{
Expand Down

0 comments on commit 978ea73

Please sign in to comment.