Skip to content

Commit

Permalink
Move version checks from public container to static website (#1550)
Browse files Browse the repository at this point in the history
* Adding support for static website for version check
  • Loading branch information
vibhansa-msft authored Nov 22, 2024
1 parent 1ce5915 commit 0ab1a64
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 53 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
**Other Changes**
- Stream config will be converted to block-cache config implicitly and 'stream' component is no longer used from this release onwards.
- MSI login with object-id will not rely on azcli anymore, rather it will be supported by 'azidentity' SDK.
- Version check is now moved to a static website hosted on a public container.

## 2.3.2 (2024-09-03)
**Bug Fixes**
Expand Down
65 changes: 55 additions & 10 deletions blobfuse2-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1744,8 +1744,22 @@ stages:
condition: succeeded('ReleaseArtifacts')
jobs:
- job: UpdateVersion
timeoutInMinutes: 120
strategy:
matrix:
UBN20:
vmImage: 'ubuntu-20.04'
fuselib: 'libfuse3-dev'
tags: 'fuse3'
depends: 'fuse3'
container: 'test-cnt-ubn-20'
AgentName: "blobfuse-ubuntu20"

pool:
vmImage: 'ubuntu-20.04'
name: "blobfuse-ubuntu-pool"
demands:
- ImageOverride -equals $(agentName)

variables:
- group: NightlyBlobFuse
- name: root_dir
Expand All @@ -1769,20 +1783,51 @@ stages:

# install blobfuse2
- script: |
sudo apt install fuse3 -y
cd $(Build.ArtifactStagingDirectory)/blobfuse2
ls | grep -i ubuntu-20.04
sudo apt-get install ./`ls | grep -i ubuntu-20.04` -y
blobfuse2 version
displayName: 'Installing blobfuse2'
- script: |
wget https://raw.githubusercontent.com/Azure/azure-storage-fuse/`echo $(Build.SourceBranch) | cut -d "/" -f 1,2 --complement`/releaseVersionUpdate.py
ls -l
displayName: 'Getting Python script'
workingDirectory: $(root_dir)
mkdir -p ~/blob_mnt
chmod 777 ~/blob_mnt
mkdir -p ~/blobfusetemp
chmod 777 ~/blobfusetemp
blobfuse2 mount ~/blob_mnt --tmp-path=~/blobfusetemp --container-name="\$web"
sleep 2
env:
AZURE_STORAGE_ACCOUNT: "blobfuse2"
AZURE_STORAGE_AUTH_TYPE: "msi"
AZURE_STORAGE_IDENTITY_CLIENT_ID: $(BLOBFUSE2_MSI_CIENT_ID)
displayName: 'Mount release container for version update'
- script: |
python3 releaseVersionUpdate.py "$(VERSION_CNT_SAS_URL)" "`blobfuse2 version`"
displayName: 'Updating version number'
workingDirectory: $(root_dir)
cd ~/blob_mnt/release/latest/
echo "Before cleanup"
ls -l
rm -rf *
echo "After cleanup"
ls -l
displayName: 'Delete older version file'
- script: |
cd ~/blob_mnt/release/latest/
touch `blobfuse2 version | cut -d " " -f3`
ls -l
displayName: 'Create new version file'
- script: |
cd ~/blob_mnt/release/latest/
version=`blobfuse2 version | cut -d " " -f3`
echo "Release version: " $version
echo -e "<xml>\n<latest>$version</latest>\n</xml>" > index.xml
echo "Printing index.xml"
cat index.xml
displayName: 'Update the XML file'
- script: |
blobfuse2 unmount all
displayName: 'Unmount Blobfuse2'
14 changes: 9 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ import (
)

type VersionFilesList struct {
XMLName xml.Name `xml:"EnumerationResults"`
Blobs []Blob `xml:"Blobs>Blob"`
Version string `xml:"latest"`
}

type Blob struct {
Expand Down Expand Up @@ -104,18 +103,23 @@ func getRemoteVersion(req string) (string, error) {
return "", err
}

if len(body) > 50 {
log.Err("getRemoteVersion: something suspicious in the contents from remote version")
return "", fmt.Errorf("unable to get latest version")
}

var versionList VersionFilesList
err = xml.Unmarshal(body, &versionList)
if err != nil {
log.Err("getRemoteVersion: error unmarshalling xml response [%s]", err.Error())
return "", err
}

if len(versionList.Blobs) != 1 {
if len(versionList.Version) < 5 || len(versionList.Version) > 20 {
return "", fmt.Errorf("unable to get latest version")
}

versionName := strings.Split(versionList.Blobs[0].Name, "/")[1]
versionName := versionList.Version
return versionName, nil
}

Expand All @@ -126,7 +130,7 @@ func beginDetectNewVersion() chan interface{} {
go func() {
defer close(completed)

latestVersionUrl := common.Blobfuse2ListContainerURL + "?restype=container&comp=list&prefix=latest/"
latestVersionUrl := common.Blobfuse2ListContainerURL + "/latest/index.xml"
remoteVersion, err := getRemoteVersion(latestVersionUrl)
if err != nil {
log.Err("beginDetectNewVersion: error getting latest version [%s]", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func getDummyVersion() string {

func (suite *rootCmdSuite) TestGetRemoteVersionValidContainer() {
defer suite.cleanupTest()
latestVersionUrl := common.Blobfuse2ListContainerURL + "?restype=container&comp=list&prefix=latest/"
latestVersionUrl := common.Blobfuse2ListContainerURL + "/latest/index.xml"
out, err := getRemoteVersion(latestVersionUrl)
suite.assert.NotEmpty(out)
suite.assert.Nil(err)
Expand Down
2 changes: 1 addition & 1 deletion common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import (
"strings"
)

const Blobfuse2ListContainerURL = "https://blobfuse2.blob.core.windows.net/release"
const Blobfuse2ListContainerURL = "https://blobfuse2.z13.web.core.windows.net/release"
const BlobFuse2WarningsURL = "https://aka.ms/blobfuse2warnings"
const BlobFuse2BlockingURL = "https://aka.ms/blobfuse2blockers"

Expand Down
36 changes: 0 additions & 36 deletions releaseVersionUpdate.py

This file was deleted.

0 comments on commit 0ab1a64

Please sign in to comment.