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

add server version to ark version output #1116

Merged
merged 1 commit into from
Jan 23, 2019
Merged

Conversation

skriss
Copy link
Contributor

@skriss skriss commented Dec 5, 2018

Signed-off-by: Steve Kriss [email protected]

Fixes #770

Would appreciate a quick review on the CRD definition before I proceed with the rest of the PR.

cc @heptio/ark-team

@carlisia
Copy link
Contributor

carlisia commented Dec 5, 2018

This lgtm.

// by the StatusRequestController.
ProcessedTimestamp metav1.Time `json:"processedTimestamp"`

// ServerVersion is the version of the Ark binary that the
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// ServerVersion is the version of the Ark binary that the
// ServerVersion is the Ark server version.

@skriss
Copy link
Contributor Author

skriss commented Dec 6, 2018

Would appreciate another look at this when folks have a chance now that I've implemented the server-side logic. I did a couple of things differently than our existing patterns and would like input on whether they're good changes:

  • rather than putting all logic directly into the controller, I kept the controller pretty minimal (just enqueueing and dequeuing items) and put the actual domain logic into a new package, pkg/statusrequest.
  • I added pkg/builder with a helper type for building StatusRequest objects for test purposes. it looks pretty similar to some of the builders that are currently in pkg/util/test (though I dropped the With prefix on every method, e.g. .Name(...) instead of .WithName(...) to keep things shorter. Ideally would like to move all builders out of pkg/util and into here.

Still need to do the client-side updates to ark version.

Copy link
Contributor

@ncdc ncdc left a comment

Choose a reason for hiding this comment

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

Took a quick look. 👍

@skriss skriss force-pushed the status-crd branch 3 times, most recently from fa40cc1 to 8dacd0e Compare December 6, 2018 22:21
@skriss
Copy link
Contributor Author

skriss commented Dec 6, 2018

Added client code. The output currently looks something like:

Client:
        Version: master
        Git commit: v0.10.0-38-gfa40cc19
        Git tree state: dirty
Server:
        Version: v0.10.1

@ncdc
Copy link
Contributor

ncdc commented Dec 6, 2018

Should we add a --client-only flag to prevent trying to talk to the server? kubectl has one.

@skriss
Copy link
Contributor Author

skriss commented Dec 6, 2018

I included one :)

@ncdc
Copy link
Contributor

ncdc commented Dec 7, 2018 via email

@skriss skriss changed the title [WIP] add server version to ark version output add server version to ark version output Dec 20, 2018
@skriss
Copy link
Contributor Author

skriss commented Dec 20, 2018

rebased

@skriss skriss requested review from carlisia, nrb and wwitzel3 January 3, 2019 16:09
@skriss
Copy link
Contributor Author

skriss commented Jan 3, 2019

@carlisia @nrb @wwitzel3 @ncdc ready for a full review

Copy link
Contributor

@carlisia carlisia left a comment

Choose a reason for hiding this comment

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

Looks good 👍


// StatusRequest is a request to access current status information about
// the Ark server.
type StatusRequest struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth calling this ServerStatusRequest?

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 think I'm fine either way - strong feelings? Anyone else?

Copy link
Contributor

Choose a reason for hiding this comment

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

I like being more specific as opposed to less

Phase StatusRequestPhase `json:"phase"`

// ProcessedTimestamp is when the StatusRequest was processed
// by the StatusRequestController.
Copy link
Contributor

Choose a reason for hiding this comment

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

I would omit the controller detail - that's not something an end user would want or need to know about.

limitations under the License.
*/

package builder
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you anticipate we'll add more builders over time? If so, maybe this organization would make more sense?

pkg/builders/
  statusrequest
  someothertype

and then in each package, we'd have a plain Builder type along with NewBuilder, e.g.

package statusrequest

type Builder struct {}

func NewBuilder() *Builder {}

We could even align on a common function name to spit out the underlying object - perhaps Build()?

Copy link
Contributor

Choose a reason for hiding this comment

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

Or if we're afraid that pkg/builders/backup would conflict with var backup *v1.Backup, we could suffix all builder packages with builder - pkg/builders/backupbuilder and then instead of saying backupbuilder.NewBuilder() it would just be backupbuilder.New().

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 do expect we'd add more, yes; over time, I'd like this to replace the existing test obj helpers and be a little more succinct and standardized.

What's the motivation for having a subpackage per type? I'm not sure on that aspect yet.

+1 for renaming to Build() to get the obj

Copy link
Contributor

Choose a reason for hiding this comment

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

I was hoping to eliminate the duplication of "builder(s)" in builders.NewStatusRequestBuilder.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe it should just go into pkg/statusrequest, as a type Builder struct and NewBuilder() constructor? And over time as we relocate controller logic into separate packages, each of those can define their own?

Copy link
Contributor

Choose a reason for hiding this comment

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

That seems reasonable. Although we'll have problems with single-word types, such as backup and restore (trying to use as both a variable name and package name).

)

func NewCommand() *cobra.Command {
func NewCommand(f client.Factory) *cobra.Command {
timeout := time.Minute
Copy link
Contributor

Choose a reason for hiding this comment

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

I would default this to 3 to 5 seconds

fmt.Printf("Version: %s\n", buildinfo.Version)
fmt.Printf("Git commit: %s\n", buildinfo.FormattedGitSHA())
Run: func(c *cobra.Command, args []string) {
fmt.Println("Client:")
Copy link
Contributor

Choose a reason for hiding this comment

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

I know we haven't done this much (if any) to date, but is this worth splitting out into its own function so we can unit test it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, refactored & added a unit test for what I think is the important part. PTAL.

}
defer client.StatusRequests(namespace).Delete(created.Name, nil)

listOptions := metav1.ListOptions{
Copy link
Contributor

Choose a reason for hiding this comment

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

We have this same logic in downloadrequest.Stream(). It might be nice in the future to extract this to a helper, with a custom handler function to call in the watch.Modified case.

arkv1client "github.com/heptio/ark/pkg/generated/clientset/versioned/typed/ark/v1"
)

const ttl = time.Hour
Copy link
Contributor

Choose a reason for hiding this comment

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

1 minute is probably sufficient, especially if we change the default client-side timeout to 3 or 5 seconds.

}

for _, req := range items {
if req.Status.Phase == arkv1api.StatusRequestPhaseProcessed {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it worth readding everything, not just processed ones?

@skriss
Copy link
Contributor Author

skriss commented Jan 4, 2019

addressed most of the comments in new commits - still thinking about unit testing of the CLI run func

@nrb
Copy link
Contributor

nrb commented Jan 9, 2019

Could you include a changelog entry?

Copy link
Contributor

@carlisia carlisia left a comment

Choose a reason for hiding this comment

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

Lgtm 👍

@skriss
Copy link
Contributor Author

skriss commented Jan 23, 2019

@ncdc could you take another look here? your comments should all be addressed. will squash before merge.

@ncdc
Copy link
Contributor

ncdc commented Jan 23, 2019

@skriss did another pass.

@skriss
Copy link
Contributor Author

skriss commented Jan 23, 2019

Changes made. Anything else? Will do some retesting this aft as well.

@ncdc
Copy link
Contributor

ncdc commented Jan 23, 2019 via email

@skriss
Copy link
Contributor Author

skriss commented Jan 23, 2019

tests LGTM.

@skriss
Copy link
Contributor Author

skriss commented Jan 23, 2019

squished.

@ncdc ncdc merged commit f90b8f9 into vmware-tanzu:master Jan 23, 2019
@skriss skriss deleted the status-crd branch January 23, 2019 20:44
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.

4 participants