Skip to content

Option to configure proxy cache TTL - #3238

Closed
manishtomar wants to merge 1 commit into
distribution:mainfrom
manishtomar:proxy-cache-configurable
Closed

manishtomar wants to merge 1 commit into
distribution:mainfrom
manishtomar:proxy-cache-configurable

Conversation

@manishtomar

Copy link
Copy Markdown
Contributor

Currently when registry is run as proxy it tries to cleanup unused blobs from its cache after 7 days which is hard-coded. This PR makes that value configurable. One can disable caching using this option. This allows one to temporarily mitigate
#2367 bug.

@manishtomar
manishtomar requested a review from dmcgowan August 28, 2020 00:33
Currently when registry is run as proxy it tries to cleanup unused blobs
from its cache after 7 days which is hard-coded. This PR makes that
value configurable. One can disable caching using this option. This
allows one to temporarily mitigate
distribution#2367 bug.

Signed-off-by: Manish Tomar <[email protected]>
@manishtomar
manishtomar force-pushed the proxy-cache-configurable branch from d689ee6 to 7937651 Compare August 28, 2020 18:59
@manishtomar
manishtomar requested a review from thaJeztah August 28, 2020 19:07
@manishtomar

manishtomar commented Aug 28, 2020 •

Copy link
Copy Markdown
Contributor Author

With recent TOS change from Docker a lot more people may run this project as a mirror and bug #2367 is a blocker in using it as mirror.

Comment thread docs/configuration.md
| `remoteurl`| yes | The URL for the repository on Docker Hub. |
| `username` | no | The username registered with Docker Hub which has access to the repository. |
| `password` | no | The password used to authenticate to Docker Hub using the username specified in `username`. |
| `ttl` | no | Expire proxy cache configured in "storage" after this time. Cache expiration is disabled if not provided. |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Should we keep the default same as the current value? (7 days)? I that case, possibly use some special value for disabling

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this PR implementation, if no config is specified there is no expiration. I like this approach as it forces explicit intent by the operator, rather than hiding some opaque behaviour. As long as the behaviour is documented and we no longer pick arbitrary values I'm happy with this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One thing to note is that operators who might be used to seeing reduced space will see it growing unbounded after this PR is deployed. Considering most of the operators would've encountered this bug after 7 days I think its fine to have this backward incompatible change.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If no default value set here, does it impact the upgrade scenario? The default expiration setting will change to none? We probably should document this change. @milosgajdos

@milosgajdos milosgajdos Apr 19, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

So this entry is used for generating the docs, actually. How we notify/warn users about this change is a whole another question. But I can see this turning a bit tricky. I had a read through related issues here and here and it seems that people either:

  1. Don't set STORAGE_CACHE_BLOBDESCRIPTOR when local file store is used
  2. Build a custom image and set expiry TTL to a very large number which essentially means cache indefinitely

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Anyone that's not happy with that can override it, and we could use a value of -1 to disable it.

Curious if we could make the type for the TTL a pointer instead, we should be able to tell 0 from not configured with a nil check then and not have to have special values.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@manishtomar WDYT?

@manishtomar manishtomar Apr 23, 2021 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since the default behavior is effectively broken (in a way that is difficult to debug) I feel changing the default behavior is the right thing to do. By keeping it same, we will still be making operators life difficult by silently failing to pull images after 7 days. Currently everyone who encounters the bug has to rebuild the code with high TTL and deploy it. The only thing this PR will do is avoid rebuilding from source. They will still have to face the error, google it and disable TTL to use it. Considering that the end state is always disabling TTL to make the system work why not make it default? FWIW while it seems bad to make backward-incompatible operator changes we've historically done that in the past with minor version upgrades. That is not a justification to make another one but seems justifiable in this case.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, @manishtomar o/ I think we all agree here re: the default behavior being broken and our having to change it. The "issue" is not so much the change of the current behavior on main branch, which no one would object to going forward, but rather that we'd like to propagate this change into the next 2.7.x patch release and would like to avoid changing the existing behavior, rather than tracking another patch. Would you consider changing this PR to what @SteveLasker suggests in his comment ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"github.com/opencontainers/go-digest"
)

// todo(richardscothern): from cache control header or config

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see the original todo mentioned respecting cache-control headers; that still something we want to add at some point?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The TODO comment actually says: "...instead of hardcoding an arbitrary chosen constant here, we could either pick it from cache headers or we can make move it to config". Given this PR moves the TTL value to config, I think this comment no longer applies.

@thaJeztah

Copy link
Copy Markdown
Member

@dmcgowan ptal

@billchenchina

Copy link
Copy Markdown

Any updates on this?
/cc @dmcgowan

@milosgajdos milosgajdos left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

"github.com/opencontainers/go-digest"
)

// todo(richardscothern): from cache control header or config

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The TODO comment actually says: "...instead of hardcoding an arbitrary chosen constant here, we could either pick it from cache headers or we can make move it to config". Given this PR moves the TTL value to config, I think this comment no longer applies.

Comment thread docs/configuration.md
| `remoteurl`| yes | The URL for the repository on Docker Hub. |
| `username` | no | The username registered with Docker Hub which has access to the repository. |
| `password` | no | The password used to authenticate to Docker Hub using the username specified in `username`. |
| `ttl` | no | Expire proxy cache configured in "storage" after this time. Cache expiration is disabled if not provided. |

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In this PR implementation, if no config is specified there is no expiration. I like this approach as it forces explicit intent by the operator, rather than hiding some opaque behaviour. As long as the behaviour is documented and we no longer pick arbitrary values I'm happy with this.

@wy65701436 wy65701436 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

Comment thread docs/configuration.md
| `remoteurl`| yes | The URL for the repository on Docker Hub. |
| `username` | no | The username registered with Docker Hub which has access to the repository. |
| `password` | no | The password used to authenticate to Docker Hub using the username specified in `username`. |
| `ttl` | no | Expire proxy cache configured in "storage" after this time. Cache expiration is disabled if not provided. |

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If no default value set here, does it impact the upgrade scenario? The default expiration setting will change to none? We probably should document this change. @milosgajdos

@waynr waynr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🙈

@SteveLasker

Copy link
Copy Markdown
Collaborator

Can we make the default consistent with previous behavior in 2.7 (7-days), and have an option to change the behavior in 2.7 through config?
This way, someone that updates distribution on top of their current release, nothing changes. But, they have the option to change the TTL through config.

Then, in 3.0, we can change the default.

@xavipanda

Copy link
Copy Markdown

we also experiencing this somehow... it is not very frequent, it takes place maybe a couple times a week in a large fleet.. but when it happens it requires a restart of the pod. Since it seems to have backwards compatibility, what are we needing to move this forward ?

@prune998

Copy link
Copy Markdown

There is something that I don't get.
I'm using this Docker Registry as a mirror/cache of DockerHub. Pretty basic setup.
After few months running, I see the disk space used always growing.

So, it seems there's a TTL set to 7 days by default that you want to make configurable.
But, anyways, the proxy functions to delete the manifests and blobs are still not doing anything:

func (pms proxyManifestStore) Delete(ctx context.Context, dgst digest.Digest) error {
	return distribution.ErrUnsupported
}

Am I missing something here ? What's the point of all this ?

Thanks

@liangyuanpeng

Copy link
Copy Markdown

Really want to know what is missing in the PR before it can be merged.

@liangyuanpeng

liangyuanpeng commented Dec 10, 2021 •

Copy link
Copy Markdown

The problem is Existed for too long and maintainers seems like is not care about it.

I'm working on this feature of ttl blobs and I will release it in liangyuanpeng/distribution. welcom everyone to work for it together.

The feature will be like this:

  1. will it effectively delete blobs of old images form the cache .
  2. Deleted blobs not referenced by manifests.

Absolutely, it's great if some maintainers is really work for it.

@milosgajdos

milosgajdos commented Dec 10, 2021 •

Copy link
Copy Markdown
Member

Heym @liangyuanpeng

The problem is Existed for too long and maintainers seems like is not care about it.

This is fundamentally wrong conclusion. Maintainers DO care about this problem (see the discussion we had with the author of this PR), we just don't want to be breaking the existing behaviour for users. We've asked the author of the original PR to make some adjustments.

If you create a PR that addresses the points we've raised in the discussion we'll be more than happy to review it and merge it into upstream.

@liangyuanpeng

Copy link
Copy Markdown

@milosgajdos Thanks for your reply and happy for my stupid conclusion. I would like to push this PR.

@wzshiming

Copy link
Copy Markdown
Contributor

I want to move forward with this PR, based on which I have made sure of compatibility, please take a look #3880.

@milosgajdos

Copy link
Copy Markdown
Member

Closing, addressed in #3880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.