You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by sx chen <cl...@gmail.com> on 2013/10/11 10:15:13 UTC

Why Secondarystroage resourcelimit contains volumes

Hi,all:
    In 4.2,We can limit the secondarystorage usage for a user or a domain.
But when I refer to source code ,I find

    public long calculateSecondaryStorageForAccount(long accountId) {
        long totalVolumesSize =
_volumeDao.secondaryStorageUsedForAccount(accountId);
        long totalSnapshotsSize =
_snapshotDao.secondaryStorageUsedForAccount(accountId);
        long totalTemplatesSize = 0;

        SearchCriteria<SumCount> sc = templateSizeSearch.create();
        sc.setParameters("downloadState", Status.DOWNLOADED);
        sc.setParameters("destroyed", false);
        sc.setJoinParameters("templates", "accountId", accountId);
        List<SumCount> templates = _vmTemplateStoreDao.customSearch(sc,
null);
        if (templates != null) {
            totalTemplatesSize = templates.get(0).sum;
        }

        return totalVolumesSize + totalSnapshotsSize + totalTemplatesSize;
    }

Templates and snapshots are certainly belong to secondarystorage,
The volumes which sql is :
select sum(size) from volumes where account_id=? and path is null and
removed is null and state not in ("ALLOCATED").

So my question is why volumes is counted as secondarystorage?

Re: Why Secondarystroage resourcelimit contains volumes

Posted by Nitin Mehta <Ni...@citrix.com>.
No, once attach volume is called for uploaded volumes they are moved into
primary storage and then on they should be counted for primary storage
only, and not for sec. storage.
If that¹s not happening I would think that¹s a bug. Please do let us know.

On 11/10/13 6:31 PM, "sx chen" <cl...@gmail.com> wrote:

>Thanks,Nitin
>For Upload volume It's OK.
>Then I have another question;
>If I destroy a vm,the root disk will be romoved too,but data disk is still
>on the primary storage,
>and state is not "Allocated",So these volumes will be counted as
>secondarystorage and they
>are actually in the primary storage?
>
>
>2013/10/12 Nitin Mehta <Ni...@citrix.com>
>
>> One of the use case where volume is on secondary storage is for the
>> uploaded volumes.
>> Until they are attached to the vm they reside on secondary storage and
>> hence should be counted for secondary storage usage.
>>
>> On 11/10/13 1:15 AM, "sx chen" <cl...@gmail.com> wrote:
>>
>> >Hi,all:
>> >    In 4.2,We can limit the secondarystorage usage for a user or a
>>domain.
>> >But when I refer to source code ,I find
>> >
>> >    public long calculateSecondaryStorageForAccount(long accountId) {
>> >        long totalVolumesSize =
>> >_volumeDao.secondaryStorageUsedForAccount(accountId);
>> >        long totalSnapshotsSize =
>> >_snapshotDao.secondaryStorageUsedForAccount(accountId);
>> >        long totalTemplatesSize = 0;
>> >
>> >        SearchCriteria<SumCount> sc = templateSizeSearch.create();
>> >        sc.setParameters("downloadState", Status.DOWNLOADED);
>> >        sc.setParameters("destroyed", false);
>> >        sc.setJoinParameters("templates", "accountId", accountId);
>> >        List<SumCount> templates = _vmTemplateStoreDao.customSearch(sc,
>> >null);
>> >        if (templates != null) {
>> >            totalTemplatesSize = templates.get(0).sum;
>> >        }
>> >
>> >        return totalVolumesSize + totalSnapshotsSize +
>>totalTemplatesSize;
>> >    }
>> >
>> >Templates and snapshots are certainly belong to secondarystorage,
>> >The volumes which sql is :
>> >select sum(size) from volumes where account_id=? and path is null and
>> >removed is null and state not in ("ALLOCATED").
>> >
>> >So my question is why volumes is counted as secondarystorage?
>>
>>


Re: Why Secondarystroage resourcelimit contains volumes

Posted by Nitin Mehta <Ni...@citrix.com>.
No, once attach volume is called for uploaded volumes they are moved into
primary storage and then on they should be counted for primary storage
only, and not for sec. storage.
If that¹s not happening I would think that¹s a bug. Please do let us know.

On 11/10/13 6:31 PM, "sx chen" <cl...@gmail.com> wrote:

>Thanks,Nitin
>For Upload volume It's OK.
>Then I have another question;
>If I destroy a vm,the root disk will be romoved too,but data disk is still
>on the primary storage,
>and state is not "Allocated",So these volumes will be counted as
>secondarystorage and they
>are actually in the primary storage?
>
>
>2013/10/12 Nitin Mehta <Ni...@citrix.com>
>
>> One of the use case where volume is on secondary storage is for the
>> uploaded volumes.
>> Until they are attached to the vm they reside on secondary storage and
>> hence should be counted for secondary storage usage.
>>
>> On 11/10/13 1:15 AM, "sx chen" <cl...@gmail.com> wrote:
>>
>> >Hi,all:
>> >    In 4.2,We can limit the secondarystorage usage for a user or a
>>domain.
>> >But when I refer to source code ,I find
>> >
>> >    public long calculateSecondaryStorageForAccount(long accountId) {
>> >        long totalVolumesSize =
>> >_volumeDao.secondaryStorageUsedForAccount(accountId);
>> >        long totalSnapshotsSize =
>> >_snapshotDao.secondaryStorageUsedForAccount(accountId);
>> >        long totalTemplatesSize = 0;
>> >
>> >        SearchCriteria<SumCount> sc = templateSizeSearch.create();
>> >        sc.setParameters("downloadState", Status.DOWNLOADED);
>> >        sc.setParameters("destroyed", false);
>> >        sc.setJoinParameters("templates", "accountId", accountId);
>> >        List<SumCount> templates = _vmTemplateStoreDao.customSearch(sc,
>> >null);
>> >        if (templates != null) {
>> >            totalTemplatesSize = templates.get(0).sum;
>> >        }
>> >
>> >        return totalVolumesSize + totalSnapshotsSize +
>>totalTemplatesSize;
>> >    }
>> >
>> >Templates and snapshots are certainly belong to secondarystorage,
>> >The volumes which sql is :
>> >select sum(size) from volumes where account_id=? and path is null and
>> >removed is null and state not in ("ALLOCATED").
>> >
>> >So my question is why volumes is counted as secondarystorage?
>>
>>


Re: Why Secondarystroage resourcelimit contains volumes

Posted by sx chen <cl...@gmail.com>.
Thanks,Nitin
For Upload volume It's OK.
Then I have another question;
If I destroy a vm,the root disk will be romoved too,but data disk is still
on the primary storage,
and state is not "Allocated",So these volumes will be counted as
secondarystorage and they
are actually in the primary storage?


2013/10/12 Nitin Mehta <Ni...@citrix.com>

> One of the use case where volume is on secondary storage is for the
> uploaded volumes.
> Until they are attached to the vm they reside on secondary storage and
> hence should be counted for secondary storage usage.
>
> On 11/10/13 1:15 AM, "sx chen" <cl...@gmail.com> wrote:
>
> >Hi,all:
> >    In 4.2,We can limit the secondarystorage usage for a user or a domain.
> >But when I refer to source code ,I find
> >
> >    public long calculateSecondaryStorageForAccount(long accountId) {
> >        long totalVolumesSize =
> >_volumeDao.secondaryStorageUsedForAccount(accountId);
> >        long totalSnapshotsSize =
> >_snapshotDao.secondaryStorageUsedForAccount(accountId);
> >        long totalTemplatesSize = 0;
> >
> >        SearchCriteria<SumCount> sc = templateSizeSearch.create();
> >        sc.setParameters("downloadState", Status.DOWNLOADED);
> >        sc.setParameters("destroyed", false);
> >        sc.setJoinParameters("templates", "accountId", accountId);
> >        List<SumCount> templates = _vmTemplateStoreDao.customSearch(sc,
> >null);
> >        if (templates != null) {
> >            totalTemplatesSize = templates.get(0).sum;
> >        }
> >
> >        return totalVolumesSize + totalSnapshotsSize + totalTemplatesSize;
> >    }
> >
> >Templates and snapshots are certainly belong to secondarystorage,
> >The volumes which sql is :
> >select sum(size) from volumes where account_id=? and path is null and
> >removed is null and state not in ("ALLOCATED").
> >
> >So my question is why volumes is counted as secondarystorage?
>
>

Re: Why Secondarystroage resourcelimit contains volumes

Posted by sx chen <cl...@gmail.com>.
Thanks,Nitin
For Upload volume It's OK.
Then I have another question;
If I destroy a vm,the root disk will be romoved too,but data disk is still
on the primary storage,
and state is not "Allocated",So these volumes will be counted as
secondarystorage and they
are actually in the primary storage?


2013/10/12 Nitin Mehta <Ni...@citrix.com>

> One of the use case where volume is on secondary storage is for the
> uploaded volumes.
> Until they are attached to the vm they reside on secondary storage and
> hence should be counted for secondary storage usage.
>
> On 11/10/13 1:15 AM, "sx chen" <cl...@gmail.com> wrote:
>
> >Hi,all:
> >    In 4.2,We can limit the secondarystorage usage for a user or a domain.
> >But when I refer to source code ,I find
> >
> >    public long calculateSecondaryStorageForAccount(long accountId) {
> >        long totalVolumesSize =
> >_volumeDao.secondaryStorageUsedForAccount(accountId);
> >        long totalSnapshotsSize =
> >_snapshotDao.secondaryStorageUsedForAccount(accountId);
> >        long totalTemplatesSize = 0;
> >
> >        SearchCriteria<SumCount> sc = templateSizeSearch.create();
> >        sc.setParameters("downloadState", Status.DOWNLOADED);
> >        sc.setParameters("destroyed", false);
> >        sc.setJoinParameters("templates", "accountId", accountId);
> >        List<SumCount> templates = _vmTemplateStoreDao.customSearch(sc,
> >null);
> >        if (templates != null) {
> >            totalTemplatesSize = templates.get(0).sum;
> >        }
> >
> >        return totalVolumesSize + totalSnapshotsSize + totalTemplatesSize;
> >    }
> >
> >Templates and snapshots are certainly belong to secondarystorage,
> >The volumes which sql is :
> >select sum(size) from volumes where account_id=? and path is null and
> >removed is null and state not in ("ALLOCATED").
> >
> >So my question is why volumes is counted as secondarystorage?
>
>

Re: Why Secondarystroage resourcelimit contains volumes

Posted by Nitin Mehta <Ni...@citrix.com>.
One of the use case where volume is on secondary storage is for the
uploaded volumes. 
Until they are attached to the vm they reside on secondary storage and
hence should be counted for secondary storage usage.

On 11/10/13 1:15 AM, "sx chen" <cl...@gmail.com> wrote:

>Hi,all:
>    In 4.2,We can limit the secondarystorage usage for a user or a domain.
>But when I refer to source code ,I find
>
>    public long calculateSecondaryStorageForAccount(long accountId) {
>        long totalVolumesSize =
>_volumeDao.secondaryStorageUsedForAccount(accountId);
>        long totalSnapshotsSize =
>_snapshotDao.secondaryStorageUsedForAccount(accountId);
>        long totalTemplatesSize = 0;
>
>        SearchCriteria<SumCount> sc = templateSizeSearch.create();
>        sc.setParameters("downloadState", Status.DOWNLOADED);
>        sc.setParameters("destroyed", false);
>        sc.setJoinParameters("templates", "accountId", accountId);
>        List<SumCount> templates = _vmTemplateStoreDao.customSearch(sc,
>null);
>        if (templates != null) {
>            totalTemplatesSize = templates.get(0).sum;
>        }
>
>        return totalVolumesSize + totalSnapshotsSize + totalTemplatesSize;
>    }
>
>Templates and snapshots are certainly belong to secondarystorage,
>The volumes which sql is :
>select sum(size) from volumes where account_id=? and path is null and
>removed is null and state not in ("ALLOCATED").
>
>So my question is why volumes is counted as secondarystorage?


Re: Why Secondarystroage resourcelimit contains volumes

Posted by Nitin Mehta <Ni...@citrix.com>.
One of the use case where volume is on secondary storage is for the
uploaded volumes. 
Until they are attached to the vm they reside on secondary storage and
hence should be counted for secondary storage usage.

On 11/10/13 1:15 AM, "sx chen" <cl...@gmail.com> wrote:

>Hi,all:
>    In 4.2,We can limit the secondarystorage usage for a user or a domain.
>But when I refer to source code ,I find
>
>    public long calculateSecondaryStorageForAccount(long accountId) {
>        long totalVolumesSize =
>_volumeDao.secondaryStorageUsedForAccount(accountId);
>        long totalSnapshotsSize =
>_snapshotDao.secondaryStorageUsedForAccount(accountId);
>        long totalTemplatesSize = 0;
>
>        SearchCriteria<SumCount> sc = templateSizeSearch.create();
>        sc.setParameters("downloadState", Status.DOWNLOADED);
>        sc.setParameters("destroyed", false);
>        sc.setJoinParameters("templates", "accountId", accountId);
>        List<SumCount> templates = _vmTemplateStoreDao.customSearch(sc,
>null);
>        if (templates != null) {
>            totalTemplatesSize = templates.get(0).sum;
>        }
>
>        return totalVolumesSize + totalSnapshotsSize + totalTemplatesSize;
>    }
>
>Templates and snapshots are certainly belong to secondarystorage,
>The volumes which sql is :
>select sum(size) from volumes where account_id=? and path is null and
>removed is null and state not in ("ALLOCATED").
>
>So my question is why volumes is counted as secondarystorage?