Skip to content

Don't enforce quota in registry by default #9400

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/generated/oadm_by_example_content.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ Install the integrated Docker registry

# Use a different registry image
oadm registry --images=myrepo/docker-registry:mytag

# Enforce quota and limits on images
oadm registry --enforce-quota
----
====

Expand Down
3 changes: 3 additions & 0 deletions docs/generated/oc_by_example_content.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,9 @@ Install the integrated Docker registry

# Use a different registry image
oc adm registry --images=myrepo/docker-registry:mytag

# Enforce quota and limits on images
oc adm registry --enforce-quota
----
====

Expand Down
4 changes: 2 additions & 2 deletions hack/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ function install_registry() {
echo "[INFO] Installing the registry"
# For testing purposes, ensure the quota objects are always up to date in the registry by
# disabling project cache.
openshift admin registry --config="${ADMIN_KUBECONFIG}" --images="${USE_IMAGES}" -o json | \
openshift admin registry --config="${ADMIN_KUBECONFIG}" --images="${USE_IMAGES}" --enforce-quota -o json | \
oc env -f - --output json "REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_PROJECTCACHETTL=0" | \
oc create -f -
}
Expand Down Expand Up @@ -878,4 +878,4 @@ function os::util::get_object_assert() {
return 1
fi
}
readonly -f os::util::get_object_assert
readonly -f os::util::get_object_assert
13 changes: 6 additions & 7 deletions pkg/cmd/admin/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ NOTE: This command is intended to simplify the tasks of setting up a Docker regi
%[1]s %[2]s --replicas=2

# Use a different registry image
%[1]s %[2]s --images=myrepo/docker-registry:mytag`
%[1]s %[2]s --images=myrepo/docker-registry:mytag

# Enforce quota and limits on images
%[1]s %[2]s --enforce-quota`
)

// RegistryOptions contains the configuration for the registry as well as any other
Expand Down Expand Up @@ -140,7 +143,7 @@ func NewCmdRegistry(f *clientcmd.Factory, parentName, name string, out io.Writer
Volume: "/registry",
ServiceAccount: "registry",
Replicas: 1,
EnforceQuota: true,
EnforceQuota: false,
}

cmd := &cobra.Command{
Expand Down Expand Up @@ -330,11 +333,7 @@ func (opts *RegistryOptions) RunCmdRegistry() error {
env := app.Environment{}
env.Add(secretEnv)

enforceQuota := "false"
if opts.Config.EnforceQuota {
enforceQuota = "true"
}
env["REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_ENFORCEQUOTA"] = enforceQuota
env["REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_ENFORCEQUOTA"] = fmt.Sprintf("%t", opts.Config.EnforceQuota)
healthzPort := defaultPort
if len(opts.ports) > 0 {
healthzPort = int(opts.ports[0].ContainerPort)
Expand Down
2 changes: 1 addition & 1 deletion pkg/dockerregistry/server/repositorymiddleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func (r *repository) Blobs(ctx context.Context) distribution.BlobStore {

bs := r.Repository.Blobs(ctx)

if quotaEnforcing != nil {
if !quotaEnforcing.enforcementDisabled {
Copy link
Author

Choose a reason for hiding this comment

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

@smarterclayton this was the culprit - well, my accomplice.

Copy link
Contributor

Choose a reason for hiding this comment

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

:). After Alexey lands his changes to distribution I have a refactor to the middleware initialization path that prevents us from reloading the clients multiple times (which was not intentional) that will affect some of this code. But the quick fix here is good.

bs = &quotaRestrictedBlobStore{
BlobStore: bs,

Expand Down
1 change: 1 addition & 0 deletions test/cmd/admin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ os::cmd::expect_success "oadm registry --credentials=${KUBECONFIG} --images='${U
os::cmd::expect_success_and_text 'oadm registry' 'service exists'
os::cmd::expect_success_and_text 'oc describe svc/docker-registry' 'Session Affinity:\s*ClientIP'
os::cmd::expect_success_and_text 'oc get dc/docker-registry -o yaml' 'readinessProbe'
os::cmd::expect_success_and_text 'oc env --list dc/docker-registry' 'REGISTRY_MIDDLEWARE_REPOSITORY_OPENSHIFT_ENFORCEQUOTA=false'
echo "registry: ok"
os::test::junit::declare_suite_end

Expand Down