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

Added initial support for P2P-based image distribution #2303

Merged
merged 1 commit into from
Oct 27, 2023

Conversation

dynos01
Copy link
Contributor

@dynos01 dynos01 commented Sep 20, 2023

Describe what this PR does / why we need it

This PR provides P2P-based image distribution on top of the current SFTP-based approach, as described in #2278.

P2P-based content distribution has gained great popularity in the recent years. By using P2P-based content distribution, the load on the source provider significantly decreases as the entire system scales up. For example, the source would like to distribute 1GiB of content to 10 receivers, then it has to send 10GiB in total. However, with P2P used, the theoretical lower bound of sent bytes is only 1GiB. Other 9GiB of data is transmitted between the receivers.

Does this pull request fix one issue?

Describe how you did it

The design relies on Kubo (formerly known as IPFS), a popular P2P network implementation in Go. Since P2P-based distribution is just introduced, it is not used by default. If the user chooses to use it, then Sealer will:

  1. Spawn an IPFS node
  2. Create a tarball of the given directory (to accelerate the creation of merkel tree used by IPFS)
  3. Add the tarball to the IPFS node, effectively adding it to the P2P network
  4. Use SSH to spawn IPFS nodes on the clients (a dedicated receiver is needed on the client systems)
  5. Pass necessary information to the clients (the identificator of the resource tarball, where other peers are, etc)
  6. The clients download the tarball and uncompress it to the destination folder
  7. When all clients finish, the distribution process is finished

Describe how to verify it

  1. Copy dist-receiver to the destination servers (usually to /usr/bin)
  2. Add flag --p2p-distribution when running sealer run
  3. Watch terminal output and network activities to discover the magic of P2P distribution

Special notes for reviews

I have completed preliminary tests on the result (as the following figure shows). P2P-based distribution gradually gains advantage when the number of servers increase. (The tests are done under 1Gbit/s network offered by a cloud provider)

figure.jpg

Due to the nature of how P2P works, Sealer will use slightly more memory when using P2P-based distributions. In my experienments, with 10 destinations (peers) added, Sealer uses about 70MiB more of memory compared with SFTP-based distribution. However, The increase shouldn't be linear, as the base algorithm P2P networks use, Kademlia, uses a data structure called "K-bucket" to manage peers. This data structure does not keep track of every peer it discovers. When the number of peers approaches infinite, the memory usage will remain almost constant.

Since the integration of an alternative distribution system involves fundamental changes, P2P-based distribution shouldn't be used as the default method right now, if this PR gets merged.

This PR also bumps some dependencies. For quicker review, please refer to pkg/imagedistributor/p2p_distributor.go and cmd/dist-receiver/main.go, where the main logics can be found.

@dynos01 dynos01 marked this pull request as draft September 20, 2023 13:11
@codecov-commenter
Copy link

codecov-commenter commented Sep 21, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Files Coverage Δ
pkg/cluster-runtime/scale.go 0.00% <0.00%> (ø)

... and 165 files with indirect coverage changes

📢 Thoughts on this report? Let us know!.

@VinceCui
Copy link
Collaborator

You have done a great job and deserve praise. Including technology selection, coding and comparative experiments, it is relatively complete.

However, the amount of code is a bit too large. For the convenience of the Reviewer, please take some time to describe the main methods of each file in this comments.

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 11, 2023

You have done a great job and deserve praise. Including technology selection, coding and comparative experiments, it is relatively complete.

However, the amount of code is a bit too large. For the convenience of the Reviewer, please take some time to describe the main methods of each file in this comments.

Thank you for your comment. I'll briefly describe what is going on behind the scenes.

Client

A piece of program that acts as a P2P client is required on each target server. The implementation of this client can be found at cmd/dist-receiver/main.go, which basically includes:

  • Starting an HTTP server to receive control messages (cmd/dist-receiver/main.go:63)
  • Starting an IPFS client (cmd/dist-receiver/main.go:71)
  • Download the resource file (cmd/dist-receiver/main.go:98)
  • Keeping seeding until every client finishes downloading (cmd/dist-receiver/main.go:126)
P2P Distributor

This part includes modification to sealer itself. Most logics are located in pkg/imagedistributor/p2p_distributor.go, while some minor modifications live in other files to make the new distributor work. I'll focus on the main logic of this distributor.

The distributor complies with the Distributor interface. Since method DistributeRegistry and Distribute share a lot of similarities, I created a common abstraction of the distributing process at pkg/imagedistributor/p2p_distributor.go:131. Here is the implementation:

  • Compress the source data (pkg/imagedistributor/p2p_distributor.go:132)
  • Add the file to IPFS network (pkg/imagedistributor/p2p_distributor.go:143)
  • Instruct every target to start downloading (and seeding, of course) (pkg/imagedistributor/p2p_distributor.go:160)
  • Instruct every target to connect to their peers, thus accelerating bootstrap (pkg/imagedistributor/p2p_distributor.go:182)
  • Instruct every target to finish seeding (pkg/imagedistributor/p2p_distributor.go:209)

I also created some methods to assist the implementation, namely:

  • func (p *p2pDistributor) getRealIP(host net.IP) (string, error) gets the outbound IP address of sealer (the source machine), so the solution will work on environments with NAT (if the NAT implementation does not filter reverse traffic)
  • func cidToString(cid path.Resolved) string converts IPFS CID to string to pass to the client
  • func spawnNode(ctx context.Context) (icore.CoreAPI, *core.IpfsNode, error) and func createNode(ctx context.Context, repoPath string) (*core.IpfsNode, error) create an IPFS node, as the names suggest
  • func createTempRepo() (string, error) creates an IPFS working repo
  • func constructPeerHost(id peer.ID, ps peerstore.Peerstore, options ...lp2p.Option) (host.Host, error) handles key-related stuff
  • func setupPlugins(externalPluginsPath string) error initializes IPFS plugins
  • func (p *p2pDistributor) dumpConfigToRootfs(mountDir string) error dumps configuration
  • func (p *p2pDistributor) renderRootfs(mountDir string) error is the same as its SFTP counterpart
  • func getUnixfsNode(path string) (files.Node, error) converts UNIX file paths to the IPFS format
  • func tarGzDirectory(sourceDir string) (string, error) compresses the source directory
  • func waitForState(hosts []net.IP, expectedStage string) error is used for synchronization between targets (wait until everyone is on the same state)
  • func goNext(hosts []net.IP) instructs the targets to continue with next state

@VinceCui
Copy link
Collaborator

Does this PR affect the original distribution logic? In other words, if I do not enable P2P mode, is the program path the same as before your modification?

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 23, 2023

Does this PR affect the original distribution logic? In other words, if I do not enable P2P mode, is the program path the same as before your modification?

No, the PR does not affect the original logic. Every occurrence of the P2P distributor is guarded by an if statement, and if the condition is not met (i.e. the user does not enable the P2P distributor), the program does exactly what it does without the P2P distributor.

The aforementioned logic can be found at cmd/sealer/cmd/cluster/installer.go.

@VinceCui
Copy link
Collaborator

Pls check: "
Run gosec / golang-security-action (pull_request) Failing"

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 23, 2023

Pls check: " Run gosec / golang-security-action (pull_request) Failing"

All fixed. Please restart CI to check if the warnings persist.

@VinceCui
Copy link
Collaborator

Still some error.

@VinceCui
Copy link
Collaborator

pls rebase upstream/main into your branch

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 24, 2023

pls rebase upstream/main into your branch

Done. Now the latest commit in upstream/main is on my branch.

@@ -148,8 +149,14 @@ func (i *Installer) Install() error {
}

// distribute rootfs
if err := i.Distributor.Distribute(all, rootfs); err != nil {
return err
if i.P2PDistributor != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we use distibutor as the interface and initialize different instances, there's no need to make an if else decision here

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 temporary solution. In the future, I plan to introduce multicast distribution as well, so multiple distributors will be running in one cluster. SFTP-based distributor will be the fallback method (when other methods won't work due to environmental limitations or failure).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Even so, we should solve this problem at the implementation level, not at the use level.

maybe we could have an intelligent distributor implementation that invokes several other distributors and have the ability to fallback.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even so, we should solve this problem at the implementation level, not at the use level.

maybe we could have an intelligent distributor implementation that invokes several other distributors and have the ability to fallback.

Okay, I'll unify the two distributors here for now.

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. Is there anything else that I need to pay attention to? If no I'll be squashing my commits shortly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

just do it 😄

@starnop
Copy link
Collaborator

starnop commented Oct 24, 2023

@dynos01 In general, a PR should contain only one commit, and if multiple commits are included, they should contain different features.

cmd/dist-receiver/main.go Outdated Show resolved Hide resolved
cmd/dist-receiver/main.go Outdated Show resolved Hide resolved
cmd/dist-receiver/main.go Outdated Show resolved Hide resolved
cmd/dist-receiver/main.go Outdated Show resolved Hide resolved
@dynos01
Copy link
Contributor Author

dynos01 commented Oct 24, 2023

@dynos01 In general, a PR should contain only one commit, and if multiple commits are included, they should contain different features.

I'll squash all the commits once I complete everything. Thanks for reviewing!

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 24, 2023

@starnop Thank you for reviewing my code. Before I squash and push the final commit, let me know if there's anything else that should be fixed.

@dynos01 dynos01 force-pushed the main branch 3 times, most recently from 36c0c73 to 11fa836 Compare October 25, 2023 04:30
}

if err := plugins.Inject(); err != nil {
return fmt.Errorf("error initializing plugins: %s", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

initializing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Typo here, all occurrences fixed

func main() {
bootstrap := flag.String("bootstrap", "", "Specify the bootstrap node")
cidArg := flag.String("cid", "", "Specify the CID")
fileName := flag.String("file", "", "Specify the file name")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if file is a good parameter name so that the user can quickly understand what value should be passed for this parameter

Copy link
Collaborator

Choose a reason for hiding this comment

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

so do with the comments for the file flag.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In fact, this part is only intended to be invoked by sealer, not a user. Nevertheless, I've updated them for better clarity.

bootstrap := flag.String("bootstrap", "", "Specify the bootstrap node")
cidArg := flag.String("cid", "", "Specify the CID")
fileName := flag.String("file", "", "Specify the file name")
targetDir := flag.String("dir", "", "Specify the target directory")
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

}

err = files.WriteTo(rootNode, *fileName)
if err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

if err := files.WriteTo(rootNode, *fileName); err!=nil {
xxxxx
}

Please also take a look at similar code globally

Copy link
Contributor Author

@dynos01 dynos01 Oct 25, 2023

Choose a reason for hiding this comment

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

Done, replaced every similar place in my code. However I do note that there are still quite some similar snippets in sealer's codebase, which I'll be not fixing now since they are not a part of my commit.

panic(fmt.Errorf("could not get file with CID: %s", err))
}

if err := os.RemoveAll(*fileName); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

could you please have a comment here?

and, in my opinion is it necessary to clean this file? What about overwriting the original file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah this should be OK, since the following line will truncate the file if it is already present. Removed this part.

Comment on lines +202 to +203
var p2p bool
switch runFlags.Distributor {
Copy link
Collaborator

Choose a reason for hiding this comment

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

When we start writing the same code a second time, we can consider whether we should extract it as a public method

Copy link
Contributor Author

@dynos01 dynos01 Oct 25, 2023

Choose a reason for hiding this comment

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

Yeah that's perfectly reasonable. However this part will be rewritten soon with the introduction of the other distribution methods I mentioned yesterday, I'd keep it simple here for now. The p2p variable itself will be gone then. There will be a set of logics which will be abstracted as a public method.

for _, host := range cluster.Spec.Hosts {
if err = mergo.Merge(&host.SSH, &cluster.Spec.SSH); err != nil {
for i, host := range cluster.Spec.Hosts {
if err = mergo.Merge(&cluster.Spec.Hosts[i].SSH, &cluster.Spec.SSH); err != nil {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the need for this code change?

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 part is not related to my commit, but it does cause lint errors, so I fixed it to pass CI.

https://github.com/sealerio/sealer/actions/runs/6611224807/job/17954685797

Copy link
Collaborator

Choose a reason for hiding this comment

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

In theory, this PR should only contain your own code, you can get the latest code through git rebase

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll drop these changes then.

@@ -52,7 +52,8 @@ func NewConfigurator(deployHosts []net.IP,
containerRuntimeInfo containerruntime.Info,
regConfig v2.Registry,
infraDriver infradriver.InfraDriver,
distributor imagedistributor.Distributor) (Configurator, error) {
distributor imagedistributor.Distributor,
Copy link
Collaborator

Choose a reason for hiding this comment

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

go fmt code

Generally, in code style, we don't use ) as the first character of a line

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops sorry, I was mainly using Rust which encourages this style. Fixed.

@@ -50,7 +50,8 @@ type Installer interface {
func NewInstaller(currentDeployHost []net.IP,
regConfig *v2.LocalRegistry,
infraDriver infradriver.InfraDriver,
distributor imagedistributor.Distributor) Installer {
distributor imagedistributor.Distributor,
) Installer {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

BTW, in general, before the code is reviewed by the reviewers, we should develop a good habit, that is, review our own code firstly, and try to ensure that there are no unnecessary changes. Of course, good modifications are welcome

utils/ssh/ssh.go Outdated
@@ -88,13 +88,13 @@ func NewSSHClient(ssh *v1.SSH, alsoToStdout bool) Interface {

// GetHostSSHClient is used to executed bash command and no std out to be printed.
func GetHostSSHClient(hostIP net.IP, cluster *v2.Cluster) (Interface, error) {
for _, host := range cluster.Spec.Hosts {
for i, host := range cluster.Spec.Hosts {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ditto

@starnop
Copy link
Collaborator

starnop commented Oct 25, 2023

@dynos01 please try to run make lint locally and make sure it passes

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 25, 2023

@dynos01 please try to run make lint locally and make sure it passes

Well... I tried, but make lint gives quite some errors which are not part of my changes.

INFO [config_reader] Config search paths: [./ /home/dyn/sealer /home/dyn /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 21 linters: [deadcode errcheck goconst gofmt goimports golint gosimple govet ifshort ineffassign misspell nilerr staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace] 
INFO [loader] Using build tags: [containers_image_openpgp] 
INFO [loader] Go packages loading at mode 575 (compiled_files|name|types_sizes|deps|exports_file|files|imports) took 2.883337681s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 10.343597ms 
INFO [linters context/goanalysis] analyzers took 1.791020247s with top 10 stages: printf: 120.4689ms, unconvert: 39.338284ms, buildir: 37.294376ms, golint: 31.937849ms, tests: 28.497513ms, goimports: 27.812721ms, config: 27.030168ms, deadcode: 26.489588ms, gofmt: 25.26567ms, ST1012: 25.12162ms 
INFO [runner/max_same_issues] 61/64 issues with text "undeclared name: `distribution`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 25/28 issues with text "undeclared name: `digest`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 15/18 issues with text "undeclared name: `It`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 9/12 issues with text "undeclared name: `Context`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 8/11 issues with text "undeclared name: `By`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "\"github.com/opencontainers/go-digest\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "undeclared name: `BeforeEach`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "undeclared name: `AfterEach`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 5/8 issues with text "undeclared name: `progressbar`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "undeclared name: `yaml`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "undeclared name: `Expect`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "\"github.com/distribution/distribution/v3\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 2/5 issues with text "\"github.com/onsi/ginkgo\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `multierror`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `homedir`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "\"github.com/mitchellh/go-homedir\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `Describe`" were hidden, use --max-same-issues 
INFO [runner/max_from_linter] 37/87 issues from linter typecheck were hidden, use --max-issues-per-linter 
INFO [runner] Issues before processing: 7340, after processing: 50 
INFO [runner] Processors filtering stat (out/in): skip_dirs: 7340/7340, exclude: 7340/7340, path_shortener: 50/50, sort_results: 50/50, skip_files: 7340/7340, autogenerated_exclude: 7340/7340, identifier_marker: 7340/7340, diff: 243/243, max_per_file_from_linter: 243/243, max_same_issues: 87/243, source_code: 50/50, filename_unadjuster: 7340/7340, path_prettifier: 7340/7340, exclude-rules: 7290/7340, uniq_by_line: 243/7290, cgo: 7340/7340, nolint: 7290/7290, max_from_linter: 50/87, severity-rules: 50/50, path_prefixer: 50/50 
INFO [runner] processing took 111.64502ms with stages: exclude-rules: 51.535861ms, identifier_marker: 46.762964ms, nolint: 6.749128ms, path_prettifier: 1.979261ms, autogenerated_exclude: 1.758985ms, skip_files: 875.344µs, skip_dirs: 784.876µs, uniq_by_line: 298.139µs, cgo: 297.725µs, source_code: 253.782µs, filename_unadjuster: 205.633µs, max_same_issues: 118.166µs, max_per_file_from_linter: 8.63µs, max_from_linter: 7.995µs, path_shortener: 7.179µs, sort_results: 395ns, exclude: 358ns, diff: 270ns, severity-rules: 200ns, path_prefixer: 129ns 
INFO [runner] linters took 3.772371434s with stages: goanalysis_metalinter: 3.660658342s 
common/common.go:167:15: undeclared name: `homedir` (typecheck)
        home, err := homedir.Dir()
                     ^
common/common.go:20:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
types/api/v1/image_types.go:28:8: undeclared name: `digest` (typecheck)
        ID    digest.Digest `json:"id,omitempty"` // shaxxx:d6a6c9bfd4ad2901695be1dceca62e1c35a8482982ad6be172fe6958bc4f79d7
              ^
types/api/v1/image_types.go:20:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:32:17: undeclared name: `distribution` (typecheck)
        localStore     distribution.BlobStore
                       ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:33:17: undeclared name: `distribution` (typecheck)
        remoteStore    distribution.BlobService
                       ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:39:7: undeclared name: `distribution` (typecheck)
var _ distribution.BlobStore = &proxyBlobStore{}
      ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:42:25: undeclared name: `digest` (typecheck)
var inflight = make(map[digest.Digest]struct{})
                        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:47:87: undeclared name: `digest` (typecheck)
func setResponseHeaders(w http.ResponseWriter, length int64, mediaType string, digest digest.Digest) {
                                                                                      ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:28:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:24:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
pkg/image/save/distributionpkg/proxy/proxymanifeststore.go:24:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxymanifeststore.go:21:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
pkg/image/save/distributionpkg/proxy/proxyregistry.go:30:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
build/buildimage/middleware.go:55:3: domainToImages declared but not used (typecheck)
                domainToImages, err := normalizedImageListWithAuth(section)
                ^
pkg/auth/auth.go:24:14: undeclared name: `homedir` (typecheck)
        dir, err := homedir.Dir()
                    ^
pkg/auth/auth.go:20:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
utils/progressbar/progressbar.go:23:2: undeclared name: `progressbar` (typecheck)
        progressbar.ProgressBar
        ^
utils/progressbar/progressbar.go:28:27: undeclared name: `progressbar` (typecheck)
        optionEnableColorCodes = progressbar.OptionEnableColorCodes(true)
                                 ^
utils/progressbar/progressbar.go:29:27: undeclared name: `progressbar` (typecheck)
        optionSetWidth         = progressbar.OptionSetWidth(width)
                                 ^
utils/progressbar/progressbar.go:18:2: "github.com/schollz/progressbar/v3" imported but not used (typecheck)
        "github.com/schollz/progressbar/v3"
        ^
pkg/clustercert/cert/readwriter.go:19:2: "crypto/ecdsa" imported but not used (typecheck)
        "crypto/ecdsa"
        ^
pkg/clustercert/cert/readwriter.go:20:2: "crypto/rsa" imported but not used (typecheck)
        "crypto/rsa"
        ^
pkg/registry/local.go:406:13: undeclared name: `toml` (typecheck)
        bs, err := toml.Marshal(cfg)
                   ^
pkg/registry/local.go:41:2: "github.com/pelletier/go-toml" imported but not used (typecheck)
        "github.com/pelletier/go-toml"
        ^
pkg/debug/pod.go:58:2: debugContainer declared but not used (typecheck)
        debugContainer := debugger.generateDebugContainer(pod)
        ^
cmd/seautil/cmd/root.go:75:16: undeclared name: `homedir` (typecheck)
                home, err := homedir.Dir()
                             ^
cmd/seautil/cmd/root.go:21:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
pkg/infra/container/client/docker/container.go:62:2: networkID declared but not used (typecheck)
        networkID, err := p.PrepareNetworkResource(opts.NetworkName)
        ^
pkg/infra/container/container.go:160:4: joinIPList declared but not used (typecheck)
                        joinIPList, err := a.applyToJoin(result.ToJoinNumber, result.Role)
                        ^
pkg/infra/container/container.go:176:4: joinIPList declared but not used (typecheck)
                        joinIPList, err := a.applyToJoin(result.ToJoinNumber, result.Role)
                        ^
cmd/sealer/cmd/utils/cluster.go:88:2: flagHosts declared but not used (typecheck)
        flagHosts := TransferIPToHosts(flagMasters, flagNodes, v1.SSH{
        ^
cmd/sealer/cmd/utils/cluster.go:147:3: host declared but not used (typecheck)
                host := constructHost(common.MASTER, mj, scaleFlags, cluster.Spec.SSH)
                ^
cmd/sealer/cmd/utils/cluster.go:159:3: host declared but not used (typecheck)
                host := constructHost(common.NODE, nj, scaleFlags, cluster.Spec.SSH)
                ^
pkg/application/files.go:71:9: undeclared name: `yaml` (typecheck)
        err := yaml.Unmarshal([]byte(m.Data), &srcDataMap)
               ^
pkg/application/files.go:88:9: undeclared name: `yaml` (typecheck)
                err = yaml.Unmarshal(section, &destDataMap)
                      ^
pkg/application/files.go:98:15: undeclared name: `yaml` (typecheck)
                out, err := yaml.Marshal(destDataMap)
                            ^
pkg/application/files.go:28:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
        "gopkg.in/yaml.v3"
        ^
pkg/clusterfile/decoder.go:276:2: portStr declared but not used (typecheck)
        portStr := fmt.Sprintf("%d", regConfig.Port)
        ^
pkg/clusterfile/decoder.go:281:2: registryURL declared but not used (typecheck)
        registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
        ^
pkg/clusterfile/decoder.go:239:3: kubeIP declared but not used (typecheck)
                kubeIP, err := utilsnet.GetIndexIP(cidr, 1)
                ^
pkg/clusterfile/decoder.go:243:3: dnsIP declared but not used (typecheck)
                dnsIP, err := utilsnet.GetIndexIP(cidr, 10)
                ^
pkg/clusterfile/decoder.go:257:3: registryURL declared but not used (typecheck)
                registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
                ^
pkg/clusterfile/decoder.go:268:3: registryURL declared but not used (typecheck)
                registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
                ^
pkg/config/config.go:26:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
        "gopkg.in/yaml.v3"
        ^
pkg/define/image/v1/sealer_image_test.go:49:18: undeclared name: `specs` (typecheck)
                                                Versioned: specs.Versioned{
                                                           ^
pkg/define/image/v1/sealer_image_test.go:28:2: "github.com/opencontainers/image-spec/specs-go" imported but not used (typecheck)
        "github.com/opencontainers/image-spec/specs-go"
        ^
pkg/imageengine/buildah/images.go:150:19: undeclared name: `units` (typecheck)
                                CreatedAt:    units.HumanDuration(time.Since(created)) + " ago",
                                              ^
pkg/imageengine/buildah/images.go:193:27: undeclared name: `units` (typecheck)
                outputParam.CreatedAt = units.HumanDuration(time.Since(created)) + " ago"
                                        ^
pkg/imageengine/buildah/manifest.go:76:14: undeclared name: `multierror` (typecheck)
        var multiE *multierror.Error
                    ^
INFO File cache stats: 30 entries of total size 139.2KiB 
INFO Memory: 68 samples, avg is 646.9MB, max is 1673.5MB 
INFO Execution took 6.669821618s                  
make: *** [Makefile:27: lint] Error 1

Currently, none of these errors belong to my commit. However they are strange: I reviewed some errors and realized the errors appeared to be false alarms. How is this possible? Investigating on...

I've pushed a new commit with all the changes you requested before.

@starnop
Copy link
Collaborator

starnop commented Oct 25, 2023

@dynos01 please try to run make lint locally and make sure it passes

Well... I tried, but make lint gives quite some errors which are not part of my changes.

INFO [config_reader] Config search paths: [./ /home/dyn/sealer /home/dyn /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 21 linters: [deadcode errcheck goconst gofmt goimports golint gosimple govet ifshort ineffassign misspell nilerr staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace] 
INFO [loader] Using build tags: [containers_image_openpgp] 
INFO [loader] Go packages loading at mode 575 (compiled_files|name|types_sizes|deps|exports_file|files|imports) took 2.883337681s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 10.343597ms 
INFO [linters context/goanalysis] analyzers took 1.791020247s with top 10 stages: printf: 120.4689ms, unconvert: 39.338284ms, buildir: 37.294376ms, golint: 31.937849ms, tests: 28.497513ms, goimports: 27.812721ms, config: 27.030168ms, deadcode: 26.489588ms, gofmt: 25.26567ms, ST1012: 25.12162ms 
INFO [runner/max_same_issues] 61/64 issues with text "undeclared name: `distribution`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 25/28 issues with text "undeclared name: `digest`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 15/18 issues with text "undeclared name: `It`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 9/12 issues with text "undeclared name: `Context`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 8/11 issues with text "undeclared name: `By`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "\"github.com/opencontainers/go-digest\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "undeclared name: `BeforeEach`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "undeclared name: `AfterEach`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 5/8 issues with text "undeclared name: `progressbar`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "undeclared name: `yaml`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "undeclared name: `Expect`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "\"github.com/distribution/distribution/v3\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 2/5 issues with text "\"github.com/onsi/ginkgo\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `multierror`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `homedir`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "\"github.com/mitchellh/go-homedir\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `Describe`" were hidden, use --max-same-issues 
INFO [runner/max_from_linter] 37/87 issues from linter typecheck were hidden, use --max-issues-per-linter 
INFO [runner] Issues before processing: 7340, after processing: 50 
INFO [runner] Processors filtering stat (out/in): skip_dirs: 7340/7340, exclude: 7340/7340, path_shortener: 50/50, sort_results: 50/50, skip_files: 7340/7340, autogenerated_exclude: 7340/7340, identifier_marker: 7340/7340, diff: 243/243, max_per_file_from_linter: 243/243, max_same_issues: 87/243, source_code: 50/50, filename_unadjuster: 7340/7340, path_prettifier: 7340/7340, exclude-rules: 7290/7340, uniq_by_line: 243/7290, cgo: 7340/7340, nolint: 7290/7290, max_from_linter: 50/87, severity-rules: 50/50, path_prefixer: 50/50 
INFO [runner] processing took 111.64502ms with stages: exclude-rules: 51.535861ms, identifier_marker: 46.762964ms, nolint: 6.749128ms, path_prettifier: 1.979261ms, autogenerated_exclude: 1.758985ms, skip_files: 875.344µs, skip_dirs: 784.876µs, uniq_by_line: 298.139µs, cgo: 297.725µs, source_code: 253.782µs, filename_unadjuster: 205.633µs, max_same_issues: 118.166µs, max_per_file_from_linter: 8.63µs, max_from_linter: 7.995µs, path_shortener: 7.179µs, sort_results: 395ns, exclude: 358ns, diff: 270ns, severity-rules: 200ns, path_prefixer: 129ns 
INFO [runner] linters took 3.772371434s with stages: goanalysis_metalinter: 3.660658342s 
common/common.go:167:15: undeclared name: `homedir` (typecheck)
        home, err := homedir.Dir()
                     ^
common/common.go:20:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
types/api/v1/image_types.go:28:8: undeclared name: `digest` (typecheck)
        ID    digest.Digest `json:"id,omitempty"` // shaxxx:d6a6c9bfd4ad2901695be1dceca62e1c35a8482982ad6be172fe6958bc4f79d7
              ^
types/api/v1/image_types.go:20:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:32:17: undeclared name: `distribution` (typecheck)
        localStore     distribution.BlobStore
                       ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:33:17: undeclared name: `distribution` (typecheck)
        remoteStore    distribution.BlobService
                       ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:39:7: undeclared name: `distribution` (typecheck)
var _ distribution.BlobStore = &proxyBlobStore{}
      ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:42:25: undeclared name: `digest` (typecheck)
var inflight = make(map[digest.Digest]struct{})
                        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:47:87: undeclared name: `digest` (typecheck)
func setResponseHeaders(w http.ResponseWriter, length int64, mediaType string, digest digest.Digest) {
                                                                                      ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:28:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:24:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
pkg/image/save/distributionpkg/proxy/proxymanifeststore.go:24:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxymanifeststore.go:21:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
pkg/image/save/distributionpkg/proxy/proxyregistry.go:30:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
build/buildimage/middleware.go:55:3: domainToImages declared but not used (typecheck)
                domainToImages, err := normalizedImageListWithAuth(section)
                ^
pkg/auth/auth.go:24:14: undeclared name: `homedir` (typecheck)
        dir, err := homedir.Dir()
                    ^
pkg/auth/auth.go:20:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
utils/progressbar/progressbar.go:23:2: undeclared name: `progressbar` (typecheck)
        progressbar.ProgressBar
        ^
utils/progressbar/progressbar.go:28:27: undeclared name: `progressbar` (typecheck)
        optionEnableColorCodes = progressbar.OptionEnableColorCodes(true)
                                 ^
utils/progressbar/progressbar.go:29:27: undeclared name: `progressbar` (typecheck)
        optionSetWidth         = progressbar.OptionSetWidth(width)
                                 ^
utils/progressbar/progressbar.go:18:2: "github.com/schollz/progressbar/v3" imported but not used (typecheck)
        "github.com/schollz/progressbar/v3"
        ^
pkg/clustercert/cert/readwriter.go:19:2: "crypto/ecdsa" imported but not used (typecheck)
        "crypto/ecdsa"
        ^
pkg/clustercert/cert/readwriter.go:20:2: "crypto/rsa" imported but not used (typecheck)
        "crypto/rsa"
        ^
pkg/registry/local.go:406:13: undeclared name: `toml` (typecheck)
        bs, err := toml.Marshal(cfg)
                   ^
pkg/registry/local.go:41:2: "github.com/pelletier/go-toml" imported but not used (typecheck)
        "github.com/pelletier/go-toml"
        ^
pkg/debug/pod.go:58:2: debugContainer declared but not used (typecheck)
        debugContainer := debugger.generateDebugContainer(pod)
        ^
cmd/seautil/cmd/root.go:75:16: undeclared name: `homedir` (typecheck)
                home, err := homedir.Dir()
                             ^
cmd/seautil/cmd/root.go:21:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
pkg/infra/container/client/docker/container.go:62:2: networkID declared but not used (typecheck)
        networkID, err := p.PrepareNetworkResource(opts.NetworkName)
        ^
pkg/infra/container/container.go:160:4: joinIPList declared but not used (typecheck)
                        joinIPList, err := a.applyToJoin(result.ToJoinNumber, result.Role)
                        ^
pkg/infra/container/container.go:176:4: joinIPList declared but not used (typecheck)
                        joinIPList, err := a.applyToJoin(result.ToJoinNumber, result.Role)
                        ^
cmd/sealer/cmd/utils/cluster.go:88:2: flagHosts declared but not used (typecheck)
        flagHosts := TransferIPToHosts(flagMasters, flagNodes, v1.SSH{
        ^
cmd/sealer/cmd/utils/cluster.go:147:3: host declared but not used (typecheck)
                host := constructHost(common.MASTER, mj, scaleFlags, cluster.Spec.SSH)
                ^
cmd/sealer/cmd/utils/cluster.go:159:3: host declared but not used (typecheck)
                host := constructHost(common.NODE, nj, scaleFlags, cluster.Spec.SSH)
                ^
pkg/application/files.go:71:9: undeclared name: `yaml` (typecheck)
        err := yaml.Unmarshal([]byte(m.Data), &srcDataMap)
               ^
pkg/application/files.go:88:9: undeclared name: `yaml` (typecheck)
                err = yaml.Unmarshal(section, &destDataMap)
                      ^
pkg/application/files.go:98:15: undeclared name: `yaml` (typecheck)
                out, err := yaml.Marshal(destDataMap)
                            ^
pkg/application/files.go:28:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
        "gopkg.in/yaml.v3"
        ^
pkg/clusterfile/decoder.go:276:2: portStr declared but not used (typecheck)
        portStr := fmt.Sprintf("%d", regConfig.Port)
        ^
pkg/clusterfile/decoder.go:281:2: registryURL declared but not used (typecheck)
        registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
        ^
pkg/clusterfile/decoder.go:239:3: kubeIP declared but not used (typecheck)
                kubeIP, err := utilsnet.GetIndexIP(cidr, 1)
                ^
pkg/clusterfile/decoder.go:243:3: dnsIP declared but not used (typecheck)
                dnsIP, err := utilsnet.GetIndexIP(cidr, 10)
                ^
pkg/clusterfile/decoder.go:257:3: registryURL declared but not used (typecheck)
                registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
                ^
pkg/clusterfile/decoder.go:268:3: registryURL declared but not used (typecheck)
                registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
                ^
pkg/config/config.go:26:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
        "gopkg.in/yaml.v3"
        ^
pkg/define/image/v1/sealer_image_test.go:49:18: undeclared name: `specs` (typecheck)
                                                Versioned: specs.Versioned{
                                                           ^
pkg/define/image/v1/sealer_image_test.go:28:2: "github.com/opencontainers/image-spec/specs-go" imported but not used (typecheck)
        "github.com/opencontainers/image-spec/specs-go"
        ^
pkg/imageengine/buildah/images.go:150:19: undeclared name: `units` (typecheck)
                                CreatedAt:    units.HumanDuration(time.Since(created)) + " ago",
                                              ^
pkg/imageengine/buildah/images.go:193:27: undeclared name: `units` (typecheck)
                outputParam.CreatedAt = units.HumanDuration(time.Since(created)) + " ago"
                                        ^
pkg/imageengine/buildah/manifest.go:76:14: undeclared name: `multierror` (typecheck)
        var multiE *multierror.Error
                    ^
INFO File cache stats: 30 entries of total size 139.2KiB 
INFO Memory: 68 samples, avg is 646.9MB, max is 1673.5MB 
INFO Execution took 6.669821618s                  
make: *** [Makefile:27: lint] Error 1

Currently, none of these errors belong to my commit. However they are strange: I reviewed some errors and realized the errors appeared to be false alarms. How is this possible? Investigating on...

I've pushed a new commit with all the changes you requested before.

@dynos01 I have submit a new PR to fix the lint error for main branch. Please rebase the code after it was merged.

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 25, 2023

@dynos01 please try to run make lint locally and make sure it passes

Well... I tried, but make lint gives quite some errors which are not part of my changes.

INFO [config_reader] Config search paths: [./ /home/dyn/sealer /home/dyn /home /] 
INFO [config_reader] Used config file .golangci.yml 
INFO [lintersdb] Active 21 linters: [deadcode errcheck goconst gofmt goimports golint gosimple govet ifshort ineffassign misspell nilerr staticcheck structcheck stylecheck typecheck unconvert unparam unused varcheck whitespace] 
INFO [loader] Using build tags: [containers_image_openpgp] 
INFO [loader] Go packages loading at mode 575 (compiled_files|name|types_sizes|deps|exports_file|files|imports) took 2.883337681s 
INFO [runner/filename_unadjuster] Pre-built 0 adjustments in 10.343597ms 
INFO [linters context/goanalysis] analyzers took 1.791020247s with top 10 stages: printf: 120.4689ms, unconvert: 39.338284ms, buildir: 37.294376ms, golint: 31.937849ms, tests: 28.497513ms, goimports: 27.812721ms, config: 27.030168ms, deadcode: 26.489588ms, gofmt: 25.26567ms, ST1012: 25.12162ms 
INFO [runner/max_same_issues] 61/64 issues with text "undeclared name: `distribution`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 25/28 issues with text "undeclared name: `digest`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 15/18 issues with text "undeclared name: `It`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 9/12 issues with text "undeclared name: `Context`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 8/11 issues with text "undeclared name: `By`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "\"github.com/opencontainers/go-digest\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "undeclared name: `BeforeEach`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 6/9 issues with text "undeclared name: `AfterEach`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 5/8 issues with text "undeclared name: `progressbar`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "undeclared name: `yaml`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "undeclared name: `Expect`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 3/6 issues with text "\"github.com/distribution/distribution/v3\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 2/5 issues with text "\"github.com/onsi/ginkgo\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `multierror`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `homedir`" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "\"github.com/mitchellh/go-homedir\" imported but not used" were hidden, use --max-same-issues 
INFO [runner/max_same_issues] 1/4 issues with text "undeclared name: `Describe`" were hidden, use --max-same-issues 
INFO [runner/max_from_linter] 37/87 issues from linter typecheck were hidden, use --max-issues-per-linter 
INFO [runner] Issues before processing: 7340, after processing: 50 
INFO [runner] Processors filtering stat (out/in): skip_dirs: 7340/7340, exclude: 7340/7340, path_shortener: 50/50, sort_results: 50/50, skip_files: 7340/7340, autogenerated_exclude: 7340/7340, identifier_marker: 7340/7340, diff: 243/243, max_per_file_from_linter: 243/243, max_same_issues: 87/243, source_code: 50/50, filename_unadjuster: 7340/7340, path_prettifier: 7340/7340, exclude-rules: 7290/7340, uniq_by_line: 243/7290, cgo: 7340/7340, nolint: 7290/7290, max_from_linter: 50/87, severity-rules: 50/50, path_prefixer: 50/50 
INFO [runner] processing took 111.64502ms with stages: exclude-rules: 51.535861ms, identifier_marker: 46.762964ms, nolint: 6.749128ms, path_prettifier: 1.979261ms, autogenerated_exclude: 1.758985ms, skip_files: 875.344µs, skip_dirs: 784.876µs, uniq_by_line: 298.139µs, cgo: 297.725µs, source_code: 253.782µs, filename_unadjuster: 205.633µs, max_same_issues: 118.166µs, max_per_file_from_linter: 8.63µs, max_from_linter: 7.995µs, path_shortener: 7.179µs, sort_results: 395ns, exclude: 358ns, diff: 270ns, severity-rules: 200ns, path_prefixer: 129ns 
INFO [runner] linters took 3.772371434s with stages: goanalysis_metalinter: 3.660658342s 
common/common.go:167:15: undeclared name: `homedir` (typecheck)
        home, err := homedir.Dir()
                     ^
common/common.go:20:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
types/api/v1/image_types.go:28:8: undeclared name: `digest` (typecheck)
        ID    digest.Digest `json:"id,omitempty"` // shaxxx:d6a6c9bfd4ad2901695be1dceca62e1c35a8482982ad6be172fe6958bc4f79d7
              ^
types/api/v1/image_types.go:20:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:32:17: undeclared name: `distribution` (typecheck)
        localStore     distribution.BlobStore
                       ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:33:17: undeclared name: `distribution` (typecheck)
        remoteStore    distribution.BlobService
                       ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:39:7: undeclared name: `distribution` (typecheck)
var _ distribution.BlobStore = &proxyBlobStore{}
      ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:42:25: undeclared name: `digest` (typecheck)
var inflight = make(map[digest.Digest]struct{})
                        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:47:87: undeclared name: `digest` (typecheck)
func setResponseHeaders(w http.ResponseWriter, length int64, mediaType string, digest digest.Digest) {
                                                                                      ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:28:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxyblobstore.go:24:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
pkg/image/save/distributionpkg/proxy/proxymanifeststore.go:24:2: "github.com/opencontainers/go-digest" imported but not used (typecheck)
        "github.com/opencontainers/go-digest"
        ^
pkg/image/save/distributionpkg/proxy/proxymanifeststore.go:21:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
pkg/image/save/distributionpkg/proxy/proxyregistry.go:30:2: "github.com/distribution/distribution/v3" imported but not used (typecheck)
        "github.com/distribution/distribution/v3"
        ^
build/buildimage/middleware.go:55:3: domainToImages declared but not used (typecheck)
                domainToImages, err := normalizedImageListWithAuth(section)
                ^
pkg/auth/auth.go:24:14: undeclared name: `homedir` (typecheck)
        dir, err := homedir.Dir()
                    ^
pkg/auth/auth.go:20:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
utils/progressbar/progressbar.go:23:2: undeclared name: `progressbar` (typecheck)
        progressbar.ProgressBar
        ^
utils/progressbar/progressbar.go:28:27: undeclared name: `progressbar` (typecheck)
        optionEnableColorCodes = progressbar.OptionEnableColorCodes(true)
                                 ^
utils/progressbar/progressbar.go:29:27: undeclared name: `progressbar` (typecheck)
        optionSetWidth         = progressbar.OptionSetWidth(width)
                                 ^
utils/progressbar/progressbar.go:18:2: "github.com/schollz/progressbar/v3" imported but not used (typecheck)
        "github.com/schollz/progressbar/v3"
        ^
pkg/clustercert/cert/readwriter.go:19:2: "crypto/ecdsa" imported but not used (typecheck)
        "crypto/ecdsa"
        ^
pkg/clustercert/cert/readwriter.go:20:2: "crypto/rsa" imported but not used (typecheck)
        "crypto/rsa"
        ^
pkg/registry/local.go:406:13: undeclared name: `toml` (typecheck)
        bs, err := toml.Marshal(cfg)
                   ^
pkg/registry/local.go:41:2: "github.com/pelletier/go-toml" imported but not used (typecheck)
        "github.com/pelletier/go-toml"
        ^
pkg/debug/pod.go:58:2: debugContainer declared but not used (typecheck)
        debugContainer := debugger.generateDebugContainer(pod)
        ^
cmd/seautil/cmd/root.go:75:16: undeclared name: `homedir` (typecheck)
                home, err := homedir.Dir()
                             ^
cmd/seautil/cmd/root.go:21:2: "github.com/mitchellh/go-homedir" imported but not used (typecheck)
        "github.com/mitchellh/go-homedir"
        ^
pkg/infra/container/client/docker/container.go:62:2: networkID declared but not used (typecheck)
        networkID, err := p.PrepareNetworkResource(opts.NetworkName)
        ^
pkg/infra/container/container.go:160:4: joinIPList declared but not used (typecheck)
                        joinIPList, err := a.applyToJoin(result.ToJoinNumber, result.Role)
                        ^
pkg/infra/container/container.go:176:4: joinIPList declared but not used (typecheck)
                        joinIPList, err := a.applyToJoin(result.ToJoinNumber, result.Role)
                        ^
cmd/sealer/cmd/utils/cluster.go:88:2: flagHosts declared but not used (typecheck)
        flagHosts := TransferIPToHosts(flagMasters, flagNodes, v1.SSH{
        ^
cmd/sealer/cmd/utils/cluster.go:147:3: host declared but not used (typecheck)
                host := constructHost(common.MASTER, mj, scaleFlags, cluster.Spec.SSH)
                ^
cmd/sealer/cmd/utils/cluster.go:159:3: host declared but not used (typecheck)
                host := constructHost(common.NODE, nj, scaleFlags, cluster.Spec.SSH)
                ^
pkg/application/files.go:71:9: undeclared name: `yaml` (typecheck)
        err := yaml.Unmarshal([]byte(m.Data), &srcDataMap)
               ^
pkg/application/files.go:88:9: undeclared name: `yaml` (typecheck)
                err = yaml.Unmarshal(section, &destDataMap)
                      ^
pkg/application/files.go:98:15: undeclared name: `yaml` (typecheck)
                out, err := yaml.Marshal(destDataMap)
                            ^
pkg/application/files.go:28:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
        "gopkg.in/yaml.v3"
        ^
pkg/clusterfile/decoder.go:276:2: portStr declared but not used (typecheck)
        portStr := fmt.Sprintf("%d", regConfig.Port)
        ^
pkg/clusterfile/decoder.go:281:2: registryURL declared but not used (typecheck)
        registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
        ^
pkg/clusterfile/decoder.go:239:3: kubeIP declared but not used (typecheck)
                kubeIP, err := utilsnet.GetIndexIP(cidr, 1)
                ^
pkg/clusterfile/decoder.go:243:3: dnsIP declared but not used (typecheck)
                dnsIP, err := utilsnet.GetIndexIP(cidr, 10)
                ^
pkg/clusterfile/decoder.go:257:3: registryURL declared but not used (typecheck)
                registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
                ^
pkg/clusterfile/decoder.go:268:3: registryURL declared but not used (typecheck)
                registryURL := net.JoinHostPort(regConfig.Domain, strconv.Itoa(regConfig.Port))
                ^
pkg/config/config.go:26:2: "gopkg.in/yaml.v3" imported but not used (typecheck)
        "gopkg.in/yaml.v3"
        ^
pkg/define/image/v1/sealer_image_test.go:49:18: undeclared name: `specs` (typecheck)
                                                Versioned: specs.Versioned{
                                                           ^
pkg/define/image/v1/sealer_image_test.go:28:2: "github.com/opencontainers/image-spec/specs-go" imported but not used (typecheck)
        "github.com/opencontainers/image-spec/specs-go"
        ^
pkg/imageengine/buildah/images.go:150:19: undeclared name: `units` (typecheck)
                                CreatedAt:    units.HumanDuration(time.Since(created)) + " ago",
                                              ^
pkg/imageengine/buildah/images.go:193:27: undeclared name: `units` (typecheck)
                outputParam.CreatedAt = units.HumanDuration(time.Since(created)) + " ago"
                                        ^
pkg/imageengine/buildah/manifest.go:76:14: undeclared name: `multierror` (typecheck)
        var multiE *multierror.Error
                    ^
INFO File cache stats: 30 entries of total size 139.2KiB 
INFO Memory: 68 samples, avg is 646.9MB, max is 1673.5MB 
INFO Execution took 6.669821618s                  
make: *** [Makefile:27: lint] Error 1

Currently, none of these errors belong to my commit. However they are strange: I reviewed some errors and realized the errors appeared to be false alarms. How is this possible? Investigating on...
I've pushed a new commit with all the changes you requested before.

@dynos01 I have submit a new PR to fix the lint error for main branch. Please rebase the code after it was merged.

Got it. I'll wait for your PR to be merged.

@VinceCui
Copy link
Collaborator

Pls Rebase

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 25, 2023

@starnop I'm trying to solve the issue of Build binaries / ubuntu - Go v1.17 (pull_request) failing. In this job, golangci-lint was killed due to lack of memory. I went ahead and had some tests on my local machine, and realized there were serious bugs with older versions of golangci-lint, which makes it consume an unbelievably high amount of memory.

Based on my tests, golangci-lint version 1.44 successfully solved the issue. The peak memory requirement is dramatically lower (consider ~24GB vs ~3GB). Therefore, I'd like to bump the version of golangci-lint to 1.44.

With the upgrade of golangci-lint, a single line of the original codebase needs to be updated (pkg/imageengine/buildah/inspect.go:34). There is a dot at the end of the error string, which shouldn't exist and causes golangci-lint to fail.

And of course, there are a few places golangci-lint requested me to update. After bumping the version of golangci-lint, removing the extra dot, and fixing my own codes, the job successfully completes (see dynos01@23b0695).

Since I should be focusing on my own code, would you mind helping me:

  • bump the version of golangci-lint to 1.44.0 at .github/workflows/go.yml:53
  • remove the extra dot at pkg/imageengine/buildah/inspect.go:34

And I'll push my fixed code. If everything goes well, this time all Github Actions should pass.

Thank you!

@starnop
Copy link
Collaborator

starnop commented Oct 26, 2023

Details

A separate PR might be better 😄

@starnop
Copy link
Collaborator

starnop commented Oct 26, 2023

@dynos01 BTW, please rebase the code before you push it.

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 26, 2023

@dynos01 BTW, please rebase the code before you push it.

Yeah of course, I'll handle the conflicts and make the history clean. I have already made another PR (#2312), which is awaiting to be merged. Once the new PR is merged, I can finalize this PR. Thanks!

@dynos01
Copy link
Contributor Author

dynos01 commented Oct 26, 2023

@VinceCui @starnop Done. I have rebased commits from sealerio:main into my branch, and checks are passed. Is there anything else that can be improved?

Copy link
Collaborator

@VinceCui VinceCui left a comment

Choose a reason for hiding this comment

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

LGTM

@starnop
Copy link
Collaborator

starnop commented Oct 27, 2023

LGTM

@starnop starnop merged commit 005f904 into sealerio:main Oct 27, 2023
11 checks passed
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.

4 participants