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
Ensure to watch image from image providers #1117
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code coverage for golang is
|
15c2474
to
c4ef830
Compare
c4ef830
to
8995bb2
Compare
The golinter build is completed with FAILURE. The build will be triggered again when you push any other commits. Or you can trigger it manually by You can check the build log from here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code coverage for golang is
|
8995bb2
to
177f903
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code coverage for golang is
|
177f903
to
bff5808
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code coverage for golang is
|
bff5808
to
fc2edcd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code coverage for golang is
|
fc2edcd
to
49576fe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code coverage for golang is
|
49576fe
to
23f7fb3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"github.com/pipe-cd/pipe/pkg/model" | ||
) | ||
|
||
// Provider acs as a container registry client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: acts
Repo string | ||
} | ||
|
||
func (i ImageName) String() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return path.Join(i.Domain, i.Repo)
pkg/model/image_name.go
Outdated
if i.Tag != "" { | ||
tag = ":" + i.Tag | ||
} | ||
return fmt.Sprintf("%s%s", i.ImageName.String(), tag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
if i.Tag == "" {
return i.ImageName.String()
}
return fmt.Sprintf("%s:%s", i.ImageTag.String(), i.Tag)
Name string `json:"name"` | ||
Type model.ImageProviderType `json:"type"` | ||
// Default is five minute. | ||
PullInterval Duration `json:"pullInterval"` | ||
|
||
DockerhubConfig *ImageProviderDockerhubConfig | ||
GCRConfig *ImageProviderGCRConfig | ||
ECRConfig *ImageProviderECRConfig | ||
} | ||
|
||
type genericPipedImageProvider struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
line 384: Dockerhub
-> DockerHub
switch cfg.Type { | ||
case model.ImageProviderTypeGCR: | ||
return gcr.NewProvider(cfg.Name, cfg.GCRConfig, doChallenge, logger) | ||
case model.ImageProviderTypeDockerhub: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dockerhub
-> DockerHub
pkg/config/piped.go
Outdated
Type model.ImageProviderType | ||
Name string `json:"name"` | ||
Type model.ImageProviderType `json:"type"` | ||
// Default is five minute. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: 5m
(to be same with the specifying in the config file)
if err != nil { | ||
return nil, err | ||
} | ||
_, err = repository.Tags(ctx).All(ctx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As they described:
For repositories with a large number of tags, this response may be quite large. If such a response is expected, one should use the pagination.
https://docs.docker.com/registry/spec/api/#listing-image-tags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the lack of description, the implementation of GCR is still WIP, and we decided to prioritize ECR over GCR. So will just leave TODO comments.
|
||
go w.run(ctx, p, cfg.PullInterval.Duration()) | ||
} | ||
return nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is exited immediately after starting goroutine
s for all image providers.
Please ensure that all of its child tasks must be stopped before exiting.
} | ||
includes = append(includes, target.Includes...) | ||
excludes = append(excludes, target.Excludes...) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Instead of finding and saving these include/exclude
list, just finding and marking the target.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, let me address it when I work on this 🙏 :
https://github.com/pipe-cd/pipe/blob/1c4d30e9b310b4e180af234efcffe9e142ba4d7d/pkg/config/image_watcher.go#L31-L32
return true | ||
} | ||
branch := repo.GetClonedBranch() | ||
if err := repo.Pull(ctx, branch); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git.Repo
is a pointer and pointing to the same disk location of git data.
This Pull
can be called from multiple goroutines and may cause a data race.
@nakabonne Reviewing is not finished yet, but please check the comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nghialv Fixed. Could you take a look? |
Code coverage for golang is
|
pkg/model/imageprovider.go
Outdated
@@ -17,7 +17,7 @@ package model | |||
type ImageProviderType string | |||
|
|||
const ( | |||
ImageProviderTypeDockerhub ImageProviderType = "DOCKERHUB" | |||
ImageProviderTypeDockerHub ImageProviderType = "DOCKERHUB" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOCKER_HUB
mu sync.Mutex | ||
|
||
// Indexed by repo id. | ||
gitRepos sync.Map |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why do we need to use a sync map instead of a normal map?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, you're right. A map can be read when it's being read. Gonna fix them.
The following ISSUES will be created once got merged. If you want me to skip creating the issue, you can use Details1. Stop listing all tagsThis was created by todo plugin since "TODO:" was found in dc28c17 when #1117 was merged. cc: @nakabonne.2. Give back latest image from GCRThis was created by todo plugin since "TODO:" was found in dc28c17 when #1117 was merged. cc: @nakabonne.3. Use credentials for GCR configured by userThis was created by todo plugin since "TODO:" was found in dc28c17 when #1117 was merged. cc: @nakabonne.4. Handle the no challenge caseThis was created by todo plugin since "TODO:" was found in dc28c17 when #1117 was merged. cc: @nakabonne.5. Control not to reach the rate limitThis was created by todo plugin since "TODO:" was found in dc28c17 when #1117 was merged. cc: @nakabonne.6. Compares between image repos in the image registry and image repos in gitThis was created by todo plugin since "TODO:" was found in dc28c17 when #1117 was merged. cc: @nakabonne.7. Make it possible to push outdated images to GitThis was created by todo plugin since "TODO:" was found in dc28c17 when #1117 was merged. cc: @nakabonne.8. Load image watcher configThis was created by todo plugin since "TODO:" was found in dc28c17 when #1117 was merged. cc: @nakabonne. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nghialv I really appreciate your polite review. Please take a look again 😄 |
Code coverage for golang is
|
Nice. |
Thanks 😃 |
What this PR does / why we need it:
Base implementation of #1114.
Sorry for the huge patch. I'd be happy to work on tiny issues respectively after this.
Which issue(s) this PR fixes:
Fixes #
Does this PR introduce a user-facing change?: