Add image alias if not there
On LXD, if the list of image aliases does not include the image name we just fetched from the simplestreams remote, add it to the list.
This commit is contained in:
parent
a8274dcc02
commit
808bc42d33
2 changed files with 16 additions and 3 deletions
|
|
@ -405,7 +405,6 @@ func (r *basePool) updateArgsFromProviderInstance(providerInstance params.Instan
|
|||
|
||||
func (r *basePool) ensureIdleRunnersForOnePool(pool params.Pool) {
|
||||
if !pool.Enabled {
|
||||
log.Printf("pool %s is disabled, skipping", pool.ID)
|
||||
return
|
||||
}
|
||||
existingInstances, err := r.store.ListPoolInstances(r.ctx, pool.ID)
|
||||
|
|
@ -449,7 +448,6 @@ func (r *basePool) ensureIdleRunnersForOnePool(pool params.Pool) {
|
|||
|
||||
func (r *basePool) retryFailedInstancesForOnePool(pool params.Pool) {
|
||||
if !pool.Enabled {
|
||||
log.Printf("pool %s is disabled, skipping", pool.ID)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -464,7 +462,6 @@ func (r *basePool) retryFailedInstancesForOnePool(pool params.Pool) {
|
|||
continue
|
||||
}
|
||||
if instance.CreateAttempt >= maxCreateAttempts {
|
||||
log.Printf("instance %s max create attempts (%d) reached", instance.Name, instance.CreateAttempt)
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ package lxd
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"garm/config"
|
||||
|
|
@ -108,9 +109,22 @@ func (i *image) copyImageFromRemote(remote config.LXDRemote, imageName string, i
|
|||
}
|
||||
|
||||
// Ask LXD to copy the image from the remote server
|
||||
imgAliases := []api.ImageAlias{}
|
||||
found := false
|
||||
for _, alias := range image.Aliases {
|
||||
if alias.Name == imageName {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !found {
|
||||
imgAliases = append(imgAliases, api.ImageAlias{Name: imageName})
|
||||
}
|
||||
|
||||
imgCopyArgs := &lxd.ImageCopyArgs{
|
||||
AutoUpdate: true,
|
||||
CopyAliases: true,
|
||||
Aliases: imgAliases,
|
||||
}
|
||||
op, err := i.cli.CopyImage(imgCli, *image, imgCopyArgs)
|
||||
if err != nil {
|
||||
|
|
@ -146,6 +160,8 @@ func (i *image) EnsureImage(imageName string, imageType config.LXDImageType, arc
|
|||
|
||||
if img, err := i.getLocalImageByAlias(parsedName, imageType, arch); err == nil {
|
||||
return img, nil
|
||||
} else {
|
||||
log.Printf("failed to fetch local image of type %v with name %s and arch %s: %s", imageType, parsedName, arch, err)
|
||||
}
|
||||
|
||||
img, err := i.copyImageFromRemote(remote, parsedName, imageType, arch)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue