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

fix: ssl use cache #203

Merged
merged 19 commits into from
Feb 4, 2021
Merged

fix: ssl use cache #203

merged 19 commits into from
Feb 4, 2021

Conversation

gxthrj
Copy link
Contributor

@gxthrj gxthrj commented Jan 25, 2021

Please answer these questions before submitting a pull request

  • Why submit this pull request?

  • Bugfix

  • New feature provided

  • Improve performance

  • Backport patches

  • Related issues


Bugfix

@tokers
Copy link
Contributor

tokers commented Jan 25, 2021

@gxthrj The unit test cases failed.

@@ -190,6 +190,7 @@ func (c *cluster) syncCacheOnce() (bool, error) {
}
}
for _, s := range ssl {
s.FullName = s.ID
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not assigning FullName outside?

Copy link
Contributor

Choose a reason for hiding this comment

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

Such as when you convert the v1.SSL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -168,6 +169,8 @@ func (s *sslClient) Create(ctx context.Context, obj *v1.Ssl) (*v1.Ssl, error) {
if err != nil {
return nil, err
}
ssl.ID = obj.ID
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should we re-assign here? APISIX doesn't change id.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -188,6 +191,7 @@ func (s *sslClient) Delete(ctx context.Context, obj *v1.Ssl) error {
if err := s.cluster.deleteResource(ctx, url); err != nil {
return err
}
obj.FullName = obj.ID
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we don't need to assign FullName here, since the obj already has a correct FullName when it was fetched from cache or APISIX.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -228,10 +232,11 @@ func (s *sslClient) Update(ctx context.Context, obj *v1.Ssl) (*v1.Ssl, error) {
if err != nil {
return nil, err
}
ssl.ID = obj.ID
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

var _ = ginkgo.Describe("SSL Testing", func() {
s := scaffold.NewDefaultScaffold()
ginkgo.It("create a SSL from ApisixTls ", func() {
secretName := "test-atls"
Copy link
Contributor

Choose a reason for hiding this comment

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

What is atls?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

change to apisix-tls

}
err = cli.AddCluster(&apisix.ClusterOptions{
BaseURL: u.String(),
})
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems we can prepare an APISIX client in the beforeEach function?

test/e2e/scaffold/ssl.go Show resolved Hide resolved
host := "api6.com"
err = s.NewApisixTls(tlsName, host, secretName)
assert.Nil(ginkgo.GinkgoT(), err, "create tls error")
// update ApisixTls resource
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the update SSL logic can be deleted, since it was check in the last case.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@codecov-io
Copy link

codecov-io commented Jan 25, 2021

Codecov Report

Merging #203 (6164e17) into master (c786e08) will increase coverage by 0.12%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #203      +/-   ##
==========================================
+ Coverage   44.48%   44.61%   +0.12%     
==========================================
  Files          34       34              
  Lines        2050     2053       +3     
==========================================
+ Hits          912      916       +4     
+ Misses        995      994       -1     
  Partials      143      143              
Impacted Files Coverage Δ
pkg/ingress/apisix/tls.go 92.00% <ø> (ø)
pkg/apisix/cluster.go 29.24% <100.00%> (+0.33%) ⬆️
pkg/apisix/resource.go 80.89% <100.00%> (+0.21%) ⬆️
pkg/apisix/ssl.go 39.45% <100.00%> (+0.41%) ⬆️
pkg/apisix/cache/memdb.go 67.27% <0.00%> (+0.90%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c786e08...6164e17. Read the comment docs.

@tokers
Copy link
Contributor

tokers commented Jan 25, 2021

@gxthrj Conflict again.

@gxthrj gxthrj requested a review from tokers February 3, 2021 16:54
err = s.EnsureNumApisixUpstreamsCreated(1)
assert.Nil(ginkgo.GinkgoT(), err, "Checking number of upstreams")
assert.Nil(ginkgo.GinkgoT(), s.ScaleHTTPBIN(2), "scaling number of httpbin instancess")
assert.Nil(ginkgo.GinkgoT(), s.WaitAllHTTPBINPoddsAvailable(), "waiting for all httpbin pods ready")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it doesn't need to scale the pods here?

tls, err := s.ListApisixTls()
assert.Nil(ginkgo.GinkgoT(), err, "list tls error")
assert.Len(ginkgo.GinkgoT(), tls, 1, "tls number not expect")
// FIXME
Copy link
Contributor

@tokers tokers Feb 3, 2021

Choose a reason for hiding this comment

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

What's wrong should be fixed in the FIXME.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a DP test error,will be added in other PR

`, backendSvc, backendSvcPort[0])
fmt.Println(apisixRoute)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should remove this debugging code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -174,6 +200,8 @@ func (s *Scaffold) newAPISIX() (*corev1.Service, error) {
return nil, err
}
if err := k8s.KubectlApplyFromStringE(s.t, s.kubectlOptions, _apisixDeployment); err != nil {
fmt.Println(_apisixDeployment)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the debugging lines.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

return net.JoinHostPort(addr, strconv.Itoa(int(port.NodePort))), nil
}
}
return "", errors.New("no http port in apisix service")
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: should be "no https port defined in apisix service".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -310,7 +310,11 @@ func (s *cluster) listResource(ctx context.Context, url string) (*listResponse,
}

func (s *cluster) createResource(ctx context.Context, url string, body io.Reader) (*createResponse, error) {
req, err := http.NewRequestWithContext(ctx, http.MethodPut, url, body)
return s.createResourceWithMethod(ctx, url, body, http.MethodPut)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why encapsulating it further by s.createResourceWithMethod, I didn't find any other places to call the s.createResourceWithMethod.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

createResourceWithMethod removed

return net.JoinHostPort(addr, strconv.Itoa(int(port.NodePort))), nil
}
}
return "", errors.New("no http port defined in apisix service")
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be "https" port.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

test/e2e/scaffold/ssl.go Show resolved Hide resolved
@gxthrj gxthrj merged commit e2f3541 into apache:master Feb 4, 2021
@gxthrj gxthrj deleted the kv/ssl-fix branch February 4, 2021 08:18
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.

bug: ssl synchronization is pathlogical
3 participants