Skip to content

Commit cfd153a

Browse files
authored
Fix azure (#210)
* Add header with "conectix" value To fix this error: Message: The specified cookie value in VHD footer indicates that disk 'kairos-ubuntu-24.04-core-amd64-generic-3.3.1-88-g70ebc315.raw.vhd' with blob https://kairoscloudimages.blob.core.windows.net:8443/kairos-cloud-images/kairos-ubuntu-24.04-core-amd64-generic-3.3.1-88-g70ebc315.raw.vhd is not a supported VHD. Disk is expected to have cookie value 'conectix'. Signed-off-by: Dimitris Karakasilis <[email protected]> * Azure expect the file size without the header to be rounded to MB Thus we don't have to remove 512 bytes (the "footer"/header size). We just round the file up and we add the footer in the end. Signed-off-by: Dimitris Karakasilis <[email protected]> * Fix test Signed-off-by: Dimitris Karakasilis <[email protected]> --------- Signed-off-by: Dimitris Karakasilis <[email protected]>
1 parent 6b647d7 commit cfd153a

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

e2e/disks_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import (
77
"encoding/binary"
88
"encoding/hex"
99
"fmt"
10-
"github.com/kairos-io/AuroraBoot/pkg/constants"
11-
"github.com/kairos-io/AuroraBoot/pkg/ops"
1210
"os"
1311
"os/exec"
1412
"path/filepath"
1513

14+
"github.com/kairos-io/AuroraBoot/pkg/constants"
15+
"github.com/kairos-io/AuroraBoot/pkg/ops"
16+
1617
. "github.com/onsi/ginkgo/v2"
1718
. "github.com/onsi/gomega"
1819
)
@@ -141,8 +142,8 @@ var _ = Describe("Disk image generation", Label("raw-disks", "e2e"), Serial, Ord
141142
f, _ := os.Open(filepath.Join(tempDir, "kairos-rockylinux-9-core-amd64-generic-v3.2.1.raw.vhd"))
142143
defer f.Close()
143144
info, _ := f.Stat()
144-
// Should be divisible by 1024*1024
145-
Expect(info.Size() % constants.MB).To(BeNumerically("==", 0))
145+
// Should be divisible by 1024*1024 + 512 bytes header
146+
Expect(info.Size() % constants.MB).To(BeNumerically("==", 512))
146147
// Dump the header from the file into our VHDHeader
147148
buff := make([]byte, 512)
148149
_, _ = f.ReadAt(buff, info.Size()-512)

pkg/ops/rawDiskOutput.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ import (
77
"encoding/binary"
88
"encoding/hex"
99
"fmt"
10-
"github.com/kairos-io/AuroraBoot/pkg/utils"
1110
"io"
1211
"io/fs"
1312
"math"
1413
"os"
1514
"time"
1615

16+
"github.com/kairos-io/AuroraBoot/pkg/utils"
17+
1718
uuidPkg "github.com/gofrs/uuid"
1819
"github.com/kairos-io/AuroraBoot/internal"
1920
"github.com/kairos-io/AuroraBoot/pkg/constants"
@@ -44,8 +45,6 @@ func Raw2Azure(source string) (string, error) {
4445
var finalSize int64
4546
// Calculate the final size in bytes
4647
finalSize = ((actualSize + constants.MB - 1) / constants.MB) * constants.MB
47-
finalSize -= 512
48-
// Remove the 512 bytes for the header that we are going to add afterwards
4948

5049
// If the actual size is different from the final size, we have to resize the image
5150
if actualSize != finalSize {
@@ -88,7 +87,7 @@ func Raw2Azure(source string) (string, error) {
8887
}
8988
sizeFile := fileInfo.Size()
9089

91-
if sizeFile%constants.MB != 0 {
90+
if int64(size)%constants.MB != 0 {
9291
err = fmt.Errorf("The file %s size %d bytes is not divisible by 1 MB.\n", fileInfo.Name(), sizeFile)
9392
internal.Log.Logger.Error().Err(err).Msg("Error validating file size")
9493
return name, err
@@ -233,6 +232,7 @@ type VHDHeader struct {
233232
// Lots of magic numbers here, but they are all defined in the VHD format spec
234233
func newVHDFixed(size uint64) VHDHeader {
235234
header := VHDHeader{}
235+
hexToField("636f6e6563746978", header.Cookie[:])
236236
hexToField("00000002", header.Features[:])
237237
hexToField("00010000", header.FileFormatVersion[:])
238238
hexToField("ffffffffffffffff", header.DataOffset[:])

0 commit comments

Comments
 (0)