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

Remove use of global sonobuoy pod name #811

Merged
merged 1 commit into from
Jul 24, 2019

Conversation

zubron
Copy link
Contributor

@zubron zubron commented Jul 24, 2019

What this PR does / why we need it:
Previously the sonobuoy pod name was stored in a global variable and was
updated before it was used. Now, instead of updating the global variable
the function that determines the pod name returns it instead.

Signed-off-by: Bridget McErlean [email protected]

Special notes for your reviewer:

Release note:

NONE

@zubron zubron requested a review from johnSchnake July 24, 2019 16:09
@codecov-io
Copy link

codecov-io commented Jul 24, 2019

Codecov Report

❗ No coverage uploaded for pull request base (master@020a7e4). Click here to learn what that means.
The diff coverage is 28%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #811   +/-   ##
=========================================
  Coverage          ?   43.42%           
=========================================
  Files             ?       71           
  Lines             ?     4260           
  Branches          ?        0           
=========================================
  Hits              ?     1850           
  Misses            ?     2301           
  Partials          ?      109
Impacted Files Coverage Δ
pkg/plugin/aggregation/status.go 45.45% <0%> (ø)
pkg/discovery/discovery.go 5% <0%> (ø)
pkg/client/retrieve.go 4.95% <0%> (ø)
pkg/plugin/aggregation/update.go 45.97% <63.63%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 020a7e4...9971fbb. Read the comment docs.

Copy link
Contributor

@johnSchnake johnSchnake left a comment

Choose a reason for hiding this comment

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

Tiny nits but I do think they should be updated for clarity/consistency before merging.

// Determine sonobuoy pod name
podName, err := pluginaggregation.GetStatusPodName(client, namespace)
if err != nil {
return errors.Wrap(err, "failed to get name of status pod")
Copy link
Contributor

Choose a reason for hiding this comment

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

status pod I think is a little confusing.

Suggestion failed to get the name of the aggregator pod to set the status on

Copy link
Contributor

Choose a reason for hiding this comment

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

There are a few other lines like this that I stopped commenting it on; fyi (so you dont just look at the lines I pointed out)

SetStatusPodName(client, namespace)
podName, err := GetStatusPodName(client, namespace)
if err != nil {
return nil, errors.Wrap(err, "failed to get name of status pod")
Copy link
Contributor

Choose a reason for hiding this comment

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

same naming comment

listOptions := metav1.ListOptions{
LabelSelector: StatusPodLabel,
}

podList, err := client.CoreV1().Pods(namespace).List(listOptions)
if err != nil {
logrus.Errorf("Error listing pods with label '%s': %s", StatusPodLabel, err)
return
return "", errors.Wrap(err, "Error listing pods with label %q")
Copy link
Contributor

Choose a reason for hiding this comment

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

Should wrap with lower case phrases; only start with a capital when logging since you know it wont be further wrapped/prefixed.

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 for pointing that out. I had taken this from the previous log line and forgot to update that.

@@ -47,3 +54,75 @@ func TestCreateUpdater(t *testing.T) {
t.Errorf("expected status to be failed, got %v", updater.status.Status)
}
}

func TestGetStatusPodName(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

👍 having the test. I just talked to someone who was suggesting we tweak the logic this method would use to take into account pod status (filter to only consider running pods). Something to consider, but regardless of the decision there, having the test will help us ensure that functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm happy to make that change but would prefer to do it in a follow up branch just to avoid adding another change in functionality here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh for sure; I didnt mean to do that here. Was just adding context for why I like having this test now (that it will immediately be useful for testing/adding requested functionality)

@zubron zubron force-pushed the remove-use-of-status-pod-name branch from 1ecd350 to fd1215e Compare July 24, 2019 17:25
Previously the sonobuoy pod name was stored in a global variable and was
updated before it was used. Now, instead of updating the global variable
the function that determines the pod name returns it instead.

Signed-off-by: Bridget McErlean <[email protected]>
@zubron zubron force-pushed the remove-use-of-status-pod-name branch from fd1215e to 9971fbb Compare July 24, 2019 17:27
@zubron zubron merged commit f0ffecc into vmware-tanzu:master Jul 24, 2019
@zubron zubron deleted the remove-use-of-status-pod-name branch July 24, 2019 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants