Skip to content
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

Bug 1976894: Idling a StatefulSet seems to work however accessing the Services Route does not wake up the application ("Application is not available" error page is returned). #1026

Merged

Conversation

miheer
Copy link
Contributor

@miheer miheer commented Jan 17, 2022

Idling a StatefulSet seems to work however accessing the Services Route does not wake up the application ("Application is not available" error page is returned).
So, with this fix we will return an error saying that we don't support idling of stateful sets as the accessing the routes for the service which is idled does not work. For that a feature work will be required. But, for now we need to add a error whenever a customer tries to idle a stateful service. This commit fixes Bug 1976894.

@openshift-ci openshift-ci bot added bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jan 17, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 17, 2022

@miheer: This pull request references Bugzilla bug 1976894, which is invalid:

  • expected the bug to target the "4.10.0" release, but it targets "---" instead

Comment /bugzilla refresh to re-evaluate validity if changes to the Bugzilla bug are made, or edit the title of this pull request to link to a different bug.

In response to this:

Bug 1976894: Idling a StatefulSet seems to work however accessing the Services Route does not wake up the application ("Application is not available" error page is returned).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@miheer
Copy link
Contributor Author

miheer commented Jan 17, 2022

/bugzilla refresh

@openshift-ci openshift-ci bot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. and removed bugzilla/invalid-bug Indicates that a referenced Bugzilla bug is invalid for the branch this PR is targeting. labels Jan 17, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 17, 2022

@miheer: This pull request references Bugzilla bug 1976894, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.10.0) matches configured target release for branch (4.10.0)
  • bug is in the state NEW, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

Requesting review from QA contact:
/cc @lihongan

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Comment on lines 272 to 273
fmt.Println("Idling StatefulSet is not supported yet.")
return nil, nil
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you need to print here instead of returning an error?

Suggested change
fmt.Println("Idling StatefulSet is not supported yet.")
return nil, nil
return nil, fmt.Errorf("idling StatefulSets is not supported")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, don't you need three return values here?

Suggested change
fmt.Println("Idling StatefulSet is not supported yet.")
return nil, nil
return nil, nil, fmt.Errorf("idling StatefulSets is not supported")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Miciah ! return is inside getController := func(ref namespacedOwnerReference) (metav1.Object, error) {

so I will add return nil, fmt.Errorf("idling StatefulSets is not supported") as can't return 3 values.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason you need to print here instead of returning an error?

It works fine however the right approach will be to add an error in the return as you mentioned as the return type of the function is error.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return is inside getController := func(ref namespacedOwnerReference) (metav1.Object, error) {

Ah, I see. GitHub doesn't show the indentation correctly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Miciah ! return is inside getController := func(ref namespacedOwnerReference) (metav1.Object, error) {

so I will add return nil, fmt.Errorf("idling StatefulSets is not supported") as can't return 3 values.

@Miciah after adding this I don't see the error message like I do see with this commit as follows -

[miheer@localhost oc]$ ./oc idle nginx
WARNING: idling when network policies are in place may cause connections to bypass network policy entirely
Idling StatefulSet is not supported yet.
error: unable to mark the service "nginx/nginx" as idled.
Make sure that the service is not already marked as idled and that it is associated with resources that can be scaled.
See 'oc idle -h' for help and examples.
[miheer@localhost oc]$

After adding the return nil, fmt.Errorf("idling StatefulSets is not supported") it does not show the error

[miheer@localhost oc]$ ./oc idle nginx
WARNING: idling when network policies are in place may cause connections to bypass network policy entirely
error: unable to mark the service "nginx/nginx" as idled.
Make sure that the service is not already marked as idled and that it is associated with resources that can be scaled.
See 'oc idle -h' for help and examples.

Copy link
Contributor Author

@miheer miheer Jan 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW I had to make the code changes where get controller is called and where it's error is captured if you want to return error. PTAL.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[miheer@localhost oc]$ ./oc idle nginx
WARNING: idling when network policies are in place may cause connections to bypass network policy entirely
error: no valid scalable resources found to idle: unable to calculate scalable resources for service nginx/nginx: Idling StatefulSet is not supported yet.
[miheer@localhost oc]$

Comment on lines 433 to 436
if err != nil {
return nil, err
} else if errors.IsNotFound(err) {
return nil, fmt.Errorf("unable to load %s %q: %v", controllerRef.Kind, controllerRef.Name, err)
}
Copy link
Contributor

@Miciah Miciah Jan 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@miheer, after your change, the else branch is unreachable, isn't it?

Anyway, it seems the logic was broken by an earlier change: https://github.com/openshift/origin/pull/22919/files#diff-037051bf889204d52030b00c7a2754f939bb8653b22842a3dc53db1259f433d6L420-R420. The original intention was any errors except not-found errors should be reported.

Suggested change
if err != nil {
return nil, err
} else if errors.IsNotFound(err) {
return nil, fmt.Errorf("unable to load %s %q: %v", controllerRef.Kind, controllerRef.Name, err)
}
if err != nil && !errors.IsNotFound(err) {
return nil, fmt.Errorf("unable to load %s %q: %v", controllerRef.Kind, controllerRef.Name, err)
}

@mfojtik, can you double-check that my analysis of your change and suggestion here are correct?

@Miciah
Copy link
Contributor

Miciah commented Jan 24, 2022

@soltysh, can you approve this PR?

@@ -268,6 +268,9 @@ func (o *IdleOptions) calculateIdlableAnnotationsByService(infoVisitor func(reso
}
// just get the unversioned version of this
gk := schema.GroupKind{Group: gv.Group, Kind: ref.Kind}
if gk.Kind == "StatefulSet" {
return nil, fmt.Errorf("Idling StatefulSet is not supported yet.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All errors should be lowercased, ie. idling StatefulSet...

@@ -268,6 +268,9 @@ func (o *IdleOptions) calculateIdlableAnnotationsByService(infoVisitor func(reso
}
// just get the unversioned version of this
gk := schema.GroupKind{Group: gv.Group, Kind: ref.Kind}
if gk.Kind == "StatefulSet" {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest being more accurate ie.:

if kappsv1.SchemeGroupVersion.WithKind("StatefulSet").GroupKind() == gk {
...

this will ensure that only k8s apps StatefulSet will be ignored.

Idling a StatefulSet seems to work however accessing the Services Route does not wake up the application ("Application is not available" error page is returned).
So, with this fix we will return an error saying that we don't support idling of stateful sets as the accessing the routes for the service which is idled does not work. For that a feature work will be required. But, for now we need to add a error whenever a customer tries to idle a stateful service.
@miheer
Copy link
Contributor Author

miheer commented Jan 28, 2022

/retest

1 similar comment
@miheer
Copy link
Contributor Author

miheer commented Jan 28, 2022

/retest

Copy link
Member

@soltysh soltysh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 28, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 28, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: miheer, soltysh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 28, 2022
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

1 similar comment
@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest-required

Please review the full test history for this PR and help us cut down flakes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 28, 2022

@miheer: all tests passed!

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@openshift-merge-robot openshift-merge-robot merged commit 7c299f1 into openshift:master Jan 28, 2022
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 28, 2022

@miheer: All pull requests linked via external trackers have merged:

Bugzilla bug 1976894 has been moved to the MODIFIED state.

In response to this:

Bug 1976894: Idling a StatefulSet seems to work however accessing the Services Route does not wake up the application ("Application is not available" error page is returned).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Miciah
Copy link
Contributor

Miciah commented Jan 29, 2022

/bugzilla refresh

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 29, 2022

@Miciah: Bugzilla bug 1976894 is in an unrecognized state (MODIFIED) and will not be moved to the MODIFIED state.

In response to this:

/bugzilla refresh

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. bugzilla/severity-medium Referenced Bugzilla bug's severity is medium for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants