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

syz-ci: introduce git_archive parameter #5371

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkg/vcs/fuchsia.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,7 @@ func (ctx *fuchsia) MergeBases(firstCommit, secondCommit string) ([]*Commit, err
func (ctx *fuchsia) CommitExists(string) (bool, error) {
return false, fmt.Errorf("not implemented for fuchsia")
}

func (ctx *fuchsia) PushCommit(repo, commit string) error {
return ctx.repo.PushCommit(repo, commit)
}
9 changes: 9 additions & 0 deletions pkg/vcs/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,3 +635,12 @@ func (git *git) CommitExists(commit string) (bool, error) {
}
return true, nil
}

func (git *git) PushCommit(repo, commit string) error {
tagName := "tag-" + commit // assign tag to guarantee remote persistence
git.git("tag", tagName) // ignore errors on re-tagging
if _, err := git.git("push", repo, "tag", tagName); err != nil {
return fmt.Errorf("git push %s tag %s: %w", repo, tagName, err)
}
return nil
}
3 changes: 3 additions & 0 deletions pkg/vcs/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ type Repo interface {

// CommitExists check for the commit presence in local checkout.
CommitExists(commit string) (bool, error)

// PushCommit is used to store commit in remote repo.
PushCommit(repo, commit string) error
}

// Bisecter may be optionally implemented by Repo.
Expand Down
14 changes: 13 additions & 1 deletion syz-ci/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ loop:
log.Logf(0, "%v: stopped", mgr.name)
}

func (mgr *Manager) archiveCommit(commit string) {
if mgr.cfg.GitArchive == "" || mgr.mgrcfg.DisableGitArchive {
return
}
if err := mgr.repo.PushCommit(mgr.cfg.GitArchive, commit); err != nil {
mgr.Errorf("%v: failed to archive commit %s from repo %s: %s",
mgr.name, commit, mgr.mgrcfg.Repo, err.Error())
}
}

func (mgr *Manager) pollAndBuild(lastCommit string, latestInfo *BuildInfo) (
string, *BuildInfo, time.Duration) {
rebuildAfter := buildRetryPeriod
Expand All @@ -277,7 +287,9 @@ func (mgr *Manager) pollAndBuild(lastCommit string, latestInfo *BuildInfo) (
if err := mgr.build(commit); err != nil {
log.Logf(0, "%v: %v", mgr.name, err)
} else {
log.Logf(0, "%v: build successful, [re]starting manager", mgr.name)
log.Logf(0, "%v: build successful", mgr.name)
mgr.archiveCommit(lastCommit)
log.Logf(0, "%v: [re]starting manager", mgr.name)
mgr.buildFailed = false
rebuildAfter = kernelRebuildPeriod
latestInfo = mgr.checkLatest()
Expand Down
7 changes: 7 additions & 0 deletions syz-ci/syz-ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ type Config struct {
// Per-vm type JSON diffs that will be applied to every instace of the
// corresponding VM type.
PatchVMConfigs map[string]json.RawMessage `json:"patch_vm_configs"`
// Some commits don't live long.
// Push all commits used in kernel builds to this git repo URL.
// The archive is later used by coverage merger.
GitArchive string `json:"git_archive"`
tarasmadan marked this conversation as resolved.
Show resolved Hide resolved
}

type ManagerConfig struct {
Expand Down Expand Up @@ -210,6 +214,9 @@ type ManagerConfig struct {
BisectBackports []vcs.BackportCommit `json:"bisect_backports"`
// Base syz-manager config for the instance.
ManagerConfig json.RawMessage `json:"manager_config"`
// By default we want to archive git commits.
// This opt-out is needed for *BSD systems.
DisableGitArchive bool `json:"disable_git_archive"`
// If the kernel's commit is older than MaxKernelLagDays days,
// fuzzing won't be started on this instance.
// By default it's 30 days.
Expand Down
7 changes: 7 additions & 0 deletions tools/docker/syzbot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ RUN test "$(uname -m)" != x86_64 && exit 0 || \
qemu-utils qemu-system-misc qemu-system-x86 qemu-system-arm qemu-system-aarch64 \
qemu-system-s390x qemu-system-mips qemu-system-ppc

# Install gcloud https://cloud.google.com/sdk/docs/install#deb.
RUN apt-get install -y -q ca-certificates \
&& curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor -o /usr/share/keyrings/cloud.google.gpg \
&& echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
RUN apt-get update && apt-get install -y google-cloud-cli
RUN git config --global credential.'https://*.*.sourcemanager.dev'.helper gcloud.sh

# pkg/osutil uses syzkaller user for sandboxing.
RUN useradd --create-home syzkaller
RUN echo "export PS1='\n\W🤖 '" >> /root/.bashrc
Expand Down
Loading