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

Close 129/add optional version cleanup #196

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mddemin
Copy link
Collaborator

@mddemin mddemin commented Aug 31, 2024

No description provided.

@@ -137,6 +137,9 @@ container rename <old-name> <new-name>
container delete <name>
delete the given container

container ttl <name> <ttl>
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe container set <container> <option> <value> and then there will be no need to create additional command/etc each similar case?

Or even it could be covered with container set <container> --ttl-hours 1234 --another-option 213123 - so to be typed and just add optional fields to protobuf?

This is just a different approach but looks promising for further similar changes since will allow to preserve proto and CLI interfaces. And another question is how to unset TTL i.e. remove it from container?

In addition probably --ttl could be added to container create?

message SetContainerVersionsTTLRequest {
string namespace = 1;
string name = 2;
uint64 ttl_hours = 3;
Copy link
Owner

Choose a reason for hiding this comment

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

Do you really expect 2^64 hours to be passed?

For instance 100 years = 876 000 ....

And comments above about the interface if we do really need to add a handler particularly for ttl

@@ -60,6 +61,11 @@ func (m *protoClientMock) DeleteContainer(ctx context.Context, in *v1proto.Delet
return &v1proto.DeleteContainerResponse{}, args.Error(0)
}

func (m *protoClientMock) SetContainerVersionsTTL(ctx context.Context, in *v1proto.SetContainerVersionsTTLRequest, opts ...grpc.CallOption) (*v1proto.SetContainerVersionsTTLResponse, error) {
args := m.Called(in.GetNamespace(), in.GetName(), time.Duration(in.GetTtlHours())*time.Hour)
Copy link
Owner

Choose a reason for hiding this comment

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

There's no actual need to cast into time.Duration explicitly since any multiplication to time.Duration will be the same type.

Higher level question if we do really need to set conversion fringe here in CLI util or it could be right at service part on manager?

comment @ manager/presenter/grpc/proto/v1/manager.proto#59 is about that.

return errors.Wrap(err, "error setting container versions TTL")
}

fmt.Printf("container `%s` versions TTL set to %s\n", containerName, ttl)
Copy link
Owner

Choose a reason for hiding this comment

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

just about the form: "TTL for versions" but "version TTL"

:-)

@@ -219,15 +224,16 @@ func main() {
r := router.New(ctx)

r.Register(namespaceCreate.FullCommand(), cliSvc.CreateNamespace(*namespaceCreateName))
r.Register(namespaceRename.FullCommand(), cliSvc.RenameNamespace(*containerRenameOldName, *containerRenameNewName))
r.Register(namespaceRename.FullCommand(), cliSvc.RenameNamespace(*namespaceRenameOldName, *namespaceRenameNewName))
Copy link
Owner

Choose a reason for hiding this comment

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

Looks like a fix, would you mind to move it to another PR such as deleteObject...?

"namespace": namespace,
"container": container,
"version": version.Name,
}).Debugf("listing expired versions ...")
Copy link
Owner

Choose a reason for hiding this comment

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

this is ok to be debug, but why we still listing? We probably checking them? btw formatting is not needed here, so Debug() could be used instead of Debugf()

"version": version.Name,
}).Debugf("listing expired versions ...")

if version.CreatedAt.After(now.Add(-1 * container.VersionsTTL)) {
Copy link
Owner

Choose a reason for hiding this comment

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

I would prefer to use positive filters i.e. if true ; do delete ... ; done so to log things to be deleted instead ones not going to be deleted.

This logic looks more straight forward

log.WithFields(log.Fields{
"namespace": namespace,
"container": container,
}).Debugf("listing unpublished versions ...")
"version": version.Name,
}).Debug("version is newer ttl. Skipping ...")
Copy link
Owner

Choose a reason for hiding this comment

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

  1. If it's gonna be message about version to be deleted it probably should be info
  2. "version is newer than ttl"

log.WithFields(log.Fields{
"namespace": namespace,
"container": container,
}).Debugf("listing unpublished versions ...")
Copy link
Owner

Choose a reason for hiding this comment

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

The same: info + it's not listing it's routine :-)

"version": version.Name,
}).Debugf("listing unpublished expired versions ...")

if version.CreatedAt.After(now.Add(-1 * s.cfg.UnpublishedVersionMaxAge)) {
Copy link
Owner

Choose a reason for hiding this comment

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

the same, positive match looks better

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.

2 participants