Skip to content

imageresitry support Alibabacloud oss#1009

Closed
menglingwei wants to merge 7 commits intoopenshift:masterfrom
menglingwei:master
Closed

imageresitry support Alibabacloud oss#1009
menglingwei wants to merge 7 commits intoopenshift:masterfrom
menglingwei:master

Conversation

@menglingwei
Copy link
Copy Markdown

No description provided.

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 10, 2021

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: menglingwei
To complete the pull request process, please assign jwforres after the PR has been reviewed.
You can assign the PR to them by writing /assign @jwforres in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot requested review from knobunc and sttts September 10, 2021 02:35
@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 10, 2021
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Sep 10, 2021

Hi @menglingwei. Thanks for your PR.

I'm waiting for a openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@kwoodson
Copy link
Copy Markdown

/ok-to-test

@openshift-ci openshift-ci Bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 10, 2021
Comment thread imageregistry/v1/types.go Outdated
Comment thread imageregistry/v1/types.go
Comment thread imageregistry/v1/types.go Outdated
Comment thread imageregistry/v1/types.go Outdated
Comment thread imageregistry/v1/types.go Outdated
// internal specifies whether the registry use the OSS VPC internal endpoint
// Optional, defaults to false. if RegionEndpoint is specified, this config will be ignored
// +optional
Internal bool `json:"internal,omitempty"`
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.

Nothing is a bool. Use an enum string please, with values like Internal and its counterpoint.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think it's better to keep it the same as registry storage-driver for oss. https://github.com/docker/docker.github.io/blob/master/registry/storage-drivers/oss.md

Copy link
Copy Markdown
Contributor

@deads2k deads2k Dec 6, 2021

Choose a reason for hiding this comment

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

The registry storage driver isn't an openshift API. openshift APIs look like kube APIs and we prefer to have enumerations where the value clearly indicates what it does and the list of values provides helpful description of what the alternatives are.

This field looks like "EndpointAccessibility" with values "Internal" or "Public". Looking at clear enums like that, the default ought to be internal.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

So we might want to change Internal to EndpointAccessibility, and EndpointAccessibility is an enums filed.

var (
   InternalEndpoint = EndpointAccessibility("Internal")
   PublicEndpoint = EndpointAccessibility("Public")
)

type ImageRegistryConfigStorageOSS struct{
...
    EndpointAccessibility EndpointAccessibility `json:"endpointAccessibility,omitempty"`

}

Is ok?

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.

Is ok?

Yes, that looks good. Please be careful about resolving threads without a push. These comments are disappearing from view.

Comment thread imageregistry/v1/types.go Outdated
// format or not.
// Optional, defaults to false.
// +optional
Encrypt bool `json:"encrypt,omitempty"`
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.

You have two encryption related fields? this and keyID? You need to describe the interaction and likely produce an API that makes it impossible to specify an invalid combination.

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.

Why would we allow a non-encrypted option?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Here the documation https://www.alibabacloud.com/help/doc-detail/117914.htm?spm=a2c63.p38356.b99.1075.5c3e56989tiYEz.
Encrypt means enable server-side encryption. The default server-side encryption method.
Valid values: KMS, AES256. So if you not set keyID ,AES256 is used for default server-side encryption method.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

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.

The registry storage driver isn't an openshift API. This API is an openshift API and should conform to our standards. Encryption with values of "ServerSideEncryption" and "ClearText" is very clear.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@kwoodson @deads2k From the above discussion. I think i need to change internal to an Enum filed like "EndpointAccessibility" , it may be Internal or Public, the default value is Internal. And the Encrty change to an Enum filed like Encryption,It is used to define the server-side encryption algorithm, KMS or AES256, and same time ,add KeyID , if the Encryption value is KMS, the KeyID must be set. So the final structure should be


type EndpointAccessibility string
var (
   InternalEndpoint = EndpointAccessibility("Internal")
   PublicEndpoint = EndpointAccessibility("Public")
)

type Encryption string
var(
 AES256 = Encryption("AES256")
 KMS = Encryption("KMS")
)

type ImageRegistryConfigStorageOSS struct {
	// bucket is the bucket name in which you want to store the registry's data.
	// Optional, will be generated if not provided.
	// +optional
	// About Bucket naming, more details you can look at the [official documentation](https://www.alibabacloud.com/help/doc-detail/257087.htm)
	Bucket string `json:"bucket,omitempty"`
	// region is the Alibaba Cloud Region in which your bucket exists.
	// Optional, will be set based on the installed Alibaba Cloud Region.
	// +optional
	// For a list of regions, you can look at the [official documentation](https://www.alibabacloud.com/help/doc-detail/31837.html).
	Region string `json:"region,omitempty"`
	// EndpointAccessibility specifies whether the registry use the OSS VPC internal endpoint
	// Optional, defaults to Internal.
	// +optional
	EndpointAccessibility EndpointAccessibility `json:"endpointAccessibility,omitempty"`
	// encrypt specifies whether the registry stores the image in encrypted
	// format or not.
	// Optional, defaults to false.
	// +optional
	// More details, you can look cat the [official documentation](https://www.alibabacloud.com/help/doc-detail/117914.htm)
	Encrypt Encryption `json:"encrypt,omitempty"`
	// keyID is the KMS key ID to use for encryption.
	// +optional
	KeyID string `json:"keyID,omitempty"`
}

I wonder if my understanding is correct? If it's correct, I'll do it this way

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If user don't set Encrypt or out of range ,the default value is AES256. If user set Encrypt to KMS and KeyID is not empty, use KMS. Follow the api documents

type Encryption string
var(
AES256 = Encryption("AES256")
KMS = Encryption("KMS")
)

Encrypt Encryption `json:"encrypt,omitempty"`
KeyID string `json:"keyID,omitempty"`

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.

I didn't realize that keyID was related to Encryption before.

type ImageRegistryConfigStorageAlibaba struct{

}


type Encryption string
var(
    ClearText = Encryption("ClearText")
    AES256 = Encryption("AES256")
    KMS = Encryption("KMS") 
)


// this a union type in kube parlance.  Depending on the value for the encryptionType,
// different pointers may be used
type EncryptionAlibaba struct{
    EncryptionType Encryption `json:"encryptionType"`

    KMSEncryptionAlibaba *KMSEncryptionAlibaba  `json:"kms"`
}

type KMSEncryptionAlibaba struct{
    KeyID string
} 

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Got it.

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.

this thread got resolved before a push, unresolving so we can see it.

Comment thread imageregistry/v1/types.go Outdated
Comment thread imageregistry/v1/types.go Outdated
@dmage
Copy link
Copy Markdown
Contributor

dmage commented Sep 14, 2021

The registry team isn't allowed to merge PRs without approvals from QE/Docs/Px (i.e. QE should confirm that the feature works as expected, Docs can confirm that they have capacity to document it), so I'd expect to have at least a draft PR for cluster-image-registry-operator. You can use replace in your go.mod to create a draft PR with these changes.

@menglingwei
Copy link
Copy Markdown
Author

replace

ok.

@menglingwei
Copy link
Copy Markdown
Author

menglingwei commented Sep 22, 2021

The registry team isn't allowed to merge PRs without approvals from QE/Docs/Px (i.e. QE should confirm that the feature works as expected, Docs can confirm that they have capacity to document it), so I'd expect to have at least a draft PR for cluster-image-registry-operator. You can use replace in your go.mod to create a draft PR with these changes.

I post a new PR openshift/cluster-image-registry-operator#724.

@menglingwei
Copy link
Copy Markdown
Author

menglingwei commented Sep 23, 2021

@dmage I posted a draf PR openshift/cluster-image-registry-operator#724. In cluster-image-reigstry-operator, I need the structure defined in openshift/api. Same as other storage registry privders, such as AWS, GCP, etc

@menglingwei
Copy link
Copy Markdown
Author

hi,any questions about this PR?

@mtulio
Copy link
Copy Markdown
Contributor

mtulio commented Nov 25, 2021

@menglingwei we are making sure that the PR openshift/cluster-image-registry-operator#724 will work with the tests described here using new credentials from CCO. Then when image-registry is validated we can follow up on this one. All the builds is including this change.

@menglingwei
Copy link
Copy Markdown
Author

@menglingwei we are making sure that the PR openshift/cluster-image-registry-operator#724 will work with the tests described here using new credentials from CCO. Then when image-registry is validated we can follow up on this one. All the builds is including this change.

@mtulio got it.

Comment thread imageregistry/v1/types.go Outdated
// ImageRegistryConfigStorageOSS holds Alibaba Cloud OSS configuration.
// the registry to use Alibaba Cloud Object Storage Service for backend storage.
// More about oss, you can look at the [official documentation](https://www.alibabacloud.com/help/product/31815.htm)
type ImageRegistryConfigStorageOSS struct {
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.

Since there's another push coming anyway, let's clean this up to ImageRegistryConfigStorageAlibaba. I think most of us won't recognize OSS

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Got it.

@menglingwei
Copy link
Copy Markdown
Author

/retest

@menglingwei
Copy link
Copy Markdown
Author

/retest

2 similar comments
@menglingwei
Copy link
Copy Markdown
Author

/retest

@menglingwei
Copy link
Copy Markdown
Author

/retest

@menglingwei
Copy link
Copy Markdown
Author

I find this job(ci/prow/verify ) fails all the time, I don't know why? @deads2k @kwoodson Who can help me to solve this task?

@menglingwei
Copy link
Copy Markdown
Author

In my dev environment,. when i run make verify. The following error occurs

  • hack/../hack/update-deepcopy.sh
    Generating deepcopy funcs
    F1209 16:50:52.181929 38267 main.go:82] Error: Failed executing generator: some packages had errors:
    errors in package "github.com/openshift/api/user/v1":
    output for "v1/zz_generated.deepcopy.go" differs; first existing/expected diff:
    "go:build !ignore_autogenerated\n// +build !ignore_autogenerated\n\n// Code generated by deepcopy-gen. D"
    " +build !ignore_autogenerated\n\n// Code generated by deepcopy-gen. DO NOT EDIT.\n\npackage v1\n\nimport ("

@menglingwei
Copy link
Copy Markdown
Author

/retest

1 similar comment
@menglingwei
Copy link
Copy Markdown
Author

/retest

@kwoodson
Copy link
Copy Markdown

kwoodson commented Dec 9, 2021

@menglingwei This is caused by the generated code and golang 1.17. When I run make update-gofmt I receive a single update:

 make update-gofmt
Running `gofmt -s -l -w` on 352 file(s).
./imageregistry/v1/zz_generated.deepcopy.go
 git diff
diff --git a/imageregistry/v1/zz_generated.deepcopy.go b/imageregistry/v1/zz_generated.deepcopy.go
index 00748800..0cb96ed9 100644
--- a/imageregistry/v1/zz_generated.deepcopy.go
+++ b/imageregistry/v1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 // Code generated by deepcopy-gen. DO NOT EDIT.

Please rerun with golang1.17, add the change, and push.

@menglingwei
Copy link
Copy Markdown
Author

@menglingwei This is caused by the generated code and golang 1.17. When I run make update-gofmt I receive a single update:

 make update-gofmt
Running `gofmt -s -l -w` on 352 file(s).
./imageregistry/v1/zz_generated.deepcopy.go
 git diff
diff --git a/imageregistry/v1/zz_generated.deepcopy.go b/imageregistry/v1/zz_generated.deepcopy.go
index 00748800..0cb96ed9 100644
--- a/imageregistry/v1/zz_generated.deepcopy.go
+++ b/imageregistry/v1/zz_generated.deepcopy.go
@@ -1,3 +1,4 @@
+//go:build !ignore_autogenerated
 // +build !ignore_autogenerated
 
 // Code generated by deepcopy-gen. DO NOT EDIT.

Please rerun with golang1.17, add the change, and push.
@kwoodson Thank you.

@menglingwei
Copy link
Copy Markdown
Author

@deads2k @kwoodson I updated the api defination,please help to reiveiw it. If the changes are acceptable, I wiil update the cluster-image-registry-operator dependency. Thank you.

@kwoodson
Copy link
Copy Markdown

@menglingwei Thanks for the fix! I have pinged the API team and we should receive a review.

@menglingwei
Copy link
Copy Markdown
Author

@menglingwei Thanks for the fix! I have pinged the API team and we should receive a review.

@kwoodson Do I need to update cluster-image-registry-operator now or later?

@kwoodson
Copy link
Copy Markdown

@menglingwei After this merges, please update the cluster-image-registry-operator PR by removing your repository and update the openshift/api library in the go.mod file.

Comment thread imageregistry/v1/types.go
type Encryption string

var (
ClearText = Encryption("ClearText")
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.

usual style is ClearText Encryption = "ClearText"

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.

and they should be defined as const, not var.

Comment thread imageregistry/v1/types.go
// EncryptionAlibaba this a union type in kube parlance. Depending on the value for the encryptionType,
// different pointers may be used
type EncryptionAlibaba struct {
EncryptionType Encryption `json:"encryptionType"`
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.

needs OpenAPI markers

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.

is it required?

Copy link
Copy Markdown
Contributor

@sttts sttts Dec 10, 2021

Choose a reason for hiding this comment

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

nvmd. These are native types, right? Not CRDs.

Comment thread imageregistry/v1/types.go
type EncryptionAlibaba struct {
EncryptionType Encryption `json:"encryptionType"`

KMSEncryptionAlibaba *KMSEncryptionAlibaba `json:"kms"`
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.

omitempty?

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.

It's convenient when field names match their json names. So I'd recommend

KMS *KMSEncryptionAlibaba `json:"kms,omitempty"`

Comment thread imageregistry/v1/types.go
// EncryptionAlibaba this a union type in kube parlance. Depending on the value for the encryptionType,
// different pointers may be used
type EncryptionAlibaba struct {
EncryptionType Encryption `json:"encryptionType"`
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.

doc this field and the valid values

Comment thread imageregistry/v1/types.go
}

type KMSEncryptionAlibaba struct {
KeyID string `json:"keyID"`
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.

doc this field (key id of what/from where?)

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.

is this security sensitive?

Comment thread imageregistry/v1/types.go
// +optional
EndpointAccessibility EndpointAccessibility `json:"endpointAccessibility,omitempty"`
// encrypt specifies whether you would like your data encrypted on the server side. Defaults to false if not specified.
// Optional, defaults to AES256.
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.

this says "defaults to false" and then "defaults to aes256". Since it's not a boolean, I assume "defaults to false" is not accurate.

Comment thread imageregistry/v1/types.go
// encrypt specifies whether you would like your data encrypted on the server side. Defaults to false if not specified.
// Optional, defaults to AES256.
// +optional
// More details, you can look cat the [official documentation](https://www.alibabacloud.com/help/doc-detail/117914.htm)
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.

Suggested change
// More details, you can look cat the [official documentation](https://www.alibabacloud.com/help/doc-detail/117914.htm)
// More details, you can look at the [official documentation](https://www.alibabacloud.com/help/doc-detail/117914.htm)

Comment thread imageregistry/v1/types.go
}

// ImageRegistryConfigStorageAlibabaOSS holds Alibaba Cloud OSS configuration.
// the registry to use Alibaba Cloud Object Storage Service for backend storage.
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.

Suggested change
// the registry to use Alibaba Cloud Object Storage Service for backend storage.
// Configures the registry to use Alibaba Cloud Object Storage Service for backend storage.

?

Comment thread imageregistry/v1/types.go
// bucket is the bucket name in which you want to store the registry's
// data.
// Optional, will be generated if not provided.
// +optional
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.

shouldn't this come after the comment?

Comment thread imageregistry/v1/types.go
Bucket string `json:"bucket,omitempty"`
// region is the Alibaba Cloud Region in which your bucket exists.
// Optional, will be set based on the installed Alibaba Cloud Region.
// +optional
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.

shouldn't this come after the comment?

Comment thread imageregistry/v1/types.go
EndpointAccessibility EndpointAccessibility `json:"endpointAccessibility,omitempty"`
// encrypt specifies whether you would like your data encrypted on the server side. Defaults to false if not specified.
// Optional, defaults to AES256.
// +optional
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.

shouldn't this come after the comment?

Comment thread imageregistry/v1/types.go
// EncryptionAlibaba this a union type in kube parlance. Depending on the value for the encryptionType,
// different pointers may be used
type EncryptionAlibaba struct {
EncryptionType Encryption `json:"encryptionType"`
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.

So it'll look like

encrypt:
  encryptionType: KMS
  kms:
    keyID: ...

Maybe it's better to name it as

encryption:
  type: KMS
  kms:
    keyID: ...

?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I will update to type. This reduces verbiage and reads more clearly.

Comment thread imageregistry/v1/types.go
// ibmcos represents configuration that uses IBM Cloud Object Storage.
// +optional
IBMCOS *ImageRegistryConfigStorageIBMCOS `json:"ibmcos,omitempty"`
// OSS represents configuration that uses Alibaba Cloud Object Storage Service.
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.

These comments will be visible by customers and should contain YAML names, so

Suggested change
// OSS represents configuration that uses Alibaba Cloud Object Storage Service.
// oss represents configuration that uses Alibaba Cloud Object Storage Service.

Comment thread imageregistry/v1/types.go
// Optional, defaults to AES256.
// +optional
// More details, you can look cat the [official documentation](https://www.alibabacloud.com/help/doc-detail/117914.htm)
Encrypt EncryptionAlibaba `json:"encrypt,omitempty"`
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.

omitempty + non-point struct does not work.

You probably want a pointer to the struct.

Comment thread imageregistry/v1/types.go
// EndpointAccessibility specifies whether the registry use the OSS VPC internal endpoint
// Optional, defaults to Internal.
// +optional
EndpointAccessibility EndpointAccessibility `json:"endpointAccessibility,omitempty"`
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.

needs enum marker

Comment thread imageregistry/v1/types.go
// Optional, will be generated if not provided.
// +optional
// About Bucket naming, more details you can look at the [official documentation](https://www.alibabacloud.com/help/doc-detail/257087.htm)
Bucket string `json:"bucket,omitempty"`
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.

which strings are allowed?

@kwoodson
Copy link
Copy Markdown

Closing this one in favor of #1082

cc @menglingwei

@kwoodson kwoodson closed this Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Indicates a non-member PR verified by an org member that is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants