-
Notifications
You must be signed in to change notification settings - Fork 135
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
Add release version to status #1023
Changes from 2 commits
dc8de4c
6a23e1d
4e9adf1
1472566
2bc8d05
0884ae5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -257,10 +257,17 @@ func (r *DataScienceClusterReconciler) Reconcile(ctx context.Context, req ctrl.R | |
} | ||
|
||
// finalize reconciliation | ||
operatorReleaseVersion, err := cluster.SetRelease(r.Client) | ||
if err != nil { | ||
r.Log.Error(err, "failed to get operator release version") | ||
return ctrl.Result{}, err | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we consider it as a critical error? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably need this to be critical error. It points to either error getting platform or CSV |
||
} | ||
instance, err = status.UpdateWithRetry(ctx, r.Client, instance, func(saved *dsc.DataScienceCluster) { | ||
status.SetCompleteCondition(&saved.Status.Conditions, status.ReconcileCompleted, "DataScienceCluster resource reconciled successfully") | ||
saved.Status.Phase = status.PhaseReady | ||
saved.Status.Release = *operatorReleaseVersion | ||
zdtsw marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
|
||
if err != nil { | ||
r.Log.Error(err, "failed to update DataScienceCluster conditions after successfully completed reconciliation") | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"os" | ||
"strings" | ||
|
||
"github.com/operator-framework/api/pkg/lib/version" | ||
ofapi "github.com/operator-framework/api/pkg/operators/v1alpha1" | ||
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||
|
@@ -120,3 +121,31 @@ func GetPlatform(cli client.Client) (Platform, error) { | |
// check and return whether ODH or self-managed platform | ||
return isSelfManaged(cli) | ||
} | ||
|
||
type Release struct { | ||
Name Platform `json:"name,omitempty"` | ||
Version version.OperatorVersion `json:"version,omitempty"` | ||
} | ||
|
||
func SetRelease(cli client.Client) (*Release, error) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May be it is GetRelease() since creates the structure and does not set it anywhere (and in sync with the error message). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I personally do not see reason for pointer (*Release) here since you anyway dereference it right after the call and optimiser should avoid extra structure copying, but it's a matter of taste, probably. |
||
initRelease := &Release{} | ||
// Set platform | ||
platform, err := GetPlatform(cli) | ||
if err != nil { | ||
return nil, err | ||
} | ||
initRelease.Name = platform | ||
|
||
// Set Version | ||
// Get watchNamespace | ||
operatorNamespace, err := GetOperatorNamespace() | ||
if err != nil { | ||
return nil, err | ||
} | ||
csv, err := GetClusterServiceVersion(context.TODO(), cli, operatorNamespace) | ||
if err != nil { | ||
return nil, err | ||
} | ||
initRelease.Version = csv.Spec.Version | ||
return initRelease, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it would be useful to retrieve the version information before reconciling components? in case there are problems with certain components...