id stringlengths 2 7 | text stringlengths 17 51.2k | title stringclasses 1
value |
|---|---|---|
c25600 | Get size of block device into 64 bit int.
// Ref: http://www.microhowto.info/howto/get_the_size_of_a_linux_block_special_device_in_c.html
if _, _, err := unix.Syscall(unix.SYS_IOCTL, file.Fd(), unix.BLKGETSIZE64, uintptr(unsafe.Pointer(&size))); err != 0 {
return 0, err
}
return size, err
} | |
c25601 | },
},
AccessModes: []v1.PersistentVolumeAccessMode{
v1.ReadWriteOnce,
},
StorageClassName: config.StorageClass,
VolumeMode: &config.VolumeMode,
MountOptions: config.MountOptions,
},
}
if config.UseAlphaAPI {
pv.ObjectMeta.Annotations[AlphaStorageNodeAffinityAnnotation] = config.A... | |
c25602 | err != nil {
return err
}
err = ConfigMapDataToVolumeConfig(configMap.Data, provisionerConfig)
return err
} | |
c25603 | configMapData[ProvisionerNodeLabelsForPV] = string(nodeLabels)
}
ver, err := yaml.Marshal(config.UseAlphaAPI)
if err != nil {
return nil, fmt.Errorf("unable to Marshal API version config: %v", err)
}
configMapData[ProvisionerUseAlphaAPI] = string(ver)
return configMapData, nil
} | |
c25604 | config.VolumeMode = DefaultVolumeMode
}
volumeMode := v1.PersistentVolumeMode(config.VolumeMode)
if volumeMode != v1.PersistentVolumeBlock && volumeMode != v1.PersistentVolumeFilesystem {
return fmt.Errorf("unsupported volume mode %s", config.VolumeMode)
}
provisionerConfig.StorageClassConfig[class] = c... | |
c25605 | %s due to: %v", path.Join(configPath, file.Name()), err)
return err
}
data[file.Name()] = string(fileContents)
}
}
}
return ConfigMapDataToVolumeConfig(data, provisionerConfig)
} | |
c25606 |
glog.Fatalf("Error creating InCluster config: %v\n", err)
}
glog.Infof("Creating client using in-cluster config")
}
clientset, err := kubernetes.NewForConfig(config)
if err != nil {
glog.Fatalf("Error creating clientset: %v\n", err)
}
return clientset
} | |
c25607 |
h.Write([]byte(mount.MountDir))
return fmt.Sprintf("mount-%x", h.Sum32())
} | |
c25608 |
}
// report the first error found
if errdir != nil {
return "", fmt.Errorf("Directory check for %q failed: %s", fullPath, errdir)
}
return "", fmt.Errorf("Block device check for %q failed: %s", fullPath, errblk)
} | |
c25609 | = p.deleteDirectory(volume)
if err != nil {
return fmt.Errorf("error deleting volume's backing path: %v", err)
}
err = p.deleteExport(volume)
if err != nil {
return fmt.Errorf("deleted the volume's backing path but error deleting export: %v", err)
}
err = p.deleteQuota(volume)
if err != nil {
return fmt... | |
c25610 |
var identity types.UID
provisioner := &digitaloceanProvisioner{
client: client,
doClient: doClient,
ctx: ctx,
identity: identity,
}
return provisioner
} | |
c25611 | {
return []v1.PersistentVolumeAccessMode{
v1.ReadWriteOnce,
v1.ReadOnlyMany,
}
} | |
c25612 |
}
log.Debug("lun list: ", luns)
if len(luns) >= 255 {
return -1, errors.New("255 luns allocated no more luns available")
}
var sluns sort.IntSlice
sluns = luns[0:]
sort.Sort(sluns)
log.Debug("sorted lun list: ", sluns)
lun := int32(len(sluns))
for i, clun := range sluns {
if i < int(clun) {
lun = i... | |
c25613 | volDestroyArgs{
Pool: pool,
Name: vol,
}
err = client.Call("vol_destroy", args, nil)
return err
} | |
c25614 | err != nil {
log.Warnln(err)
return err
}
args := exportDestroyArgs{
Pool: pool,
Vol: vol,
InitiatorWwn: initiator,
}
err = client.Call("export_destroy", args, nil)
return err
} | |
c25615 | volCreateArgs{
Pool: pool,
Name: name,
Size: size,
}
err = client.Call("vol_create", args, nil)
return err
} | |
c25616 | vol,
InitiatorWwn: initiator,
Lun: lun,
}
err = client.Call("export_create", args, nil)
return err
} | |
c25617 | result1 exportList
err = client.Call("export_list", nil, &result1)
return result1, err
} | |
c25618 | srcs rules
if !hasRules {
v.addRules(pkgPath, nil)
}
if !v.cfg.AddSourcesRules {
return nil, nil
}
pkgSrcsExpr := &bzl.LiteralExpr{Token: `glob(["**"])`}
if pkgPath == "." {
pkgSrcsExpr = &bzl.LiteralExpr{Token: `glob(["**"], exclude=["bazel-*/**", ".git/**"])`}
}
v.addRules(pkgPath, []*bzl.Rule{
ne... | |
c25619 |
Region: os.region,
})
if err != nil {
glog.Warningf("Failed to find network v2 endpoint: %v", err)
return nil, err
}
return network, nil
} | |
c25620 |
Region: os.region,
})
if err != nil {
glog.Warningf("Failed to find compute v2 endpoint: %v", err)
return nil, err
}
return compute, nil
} | |
c25621 |
}
if volumeStatus == VolumeAvailableStatus || volumeStatus == VolumeInUseStatus || volumeStatus == VolumeDeletedStatus {
return false, volume.Status, nil
}
return true, volumeStatus, nil
} | |
c25622 | == volume.AttachedServerID {
glog.V(4).Infof("Disk %s is already attached to instance %s", volumeID, instanceID)
return volume.ID, nil
}
glog.V(2).Infof("Disk %s is attached to a different instance (%s), detaching", volumeID, volume.AttachedServerID)
err = os.DetachDisk(volume.AttachedServerID, volumeID)
... | |
c25623 | nil {
glog.Errorf("Unable to initialize cinder client for region: %s", os.region)
return err
}
err = volumes.deleteVolume(volumeID)
if err != nil {
glog.Errorf("Cannot delete volume %s: %v", volumeID, err)
}
return nil
} | |
c25624 | device path
// see http://developer.openstack.org/api-ref-blockstorage-v1.html
return volume.AttachedDevice, nil
}
errMsg := fmt.Sprintf("Disk %q is attached to a different compute: %q, should be detached before proceeding", volumeID, volume.AttachedServerID)
glog.Error(errMsg)
return "", errors.New(errM... | |
c25625 |
if !ok {
glog.Errorf("Updated object is not a v1.PersistentVolume type")
return
}
p.handlePVUpdate(newPV)
},
DeleteFunc: func(obj interface{}) {
pv, ok := obj.(*v1.PersistentVolume)
if !ok {
glog.Errorf("Added object is not a v1.PersistentVolume type")
return
}
p.handlePVDelete... | |
c25626 | dir.Stat()
if err != nil {
return false, err
}
return stat.IsDir(), nil
} | |
c25627 | := dir.Readdirnames(-1)
if err != nil {
return nil, err
}
return files, nil
} | |
c25628 | _, file := range files {
err = os.RemoveAll(filepath.Join(fullPath, file))
if err != nil {
errList = append(errList, err)
}
}
return utilerrors.NewAggregate(errList)
} | |
c25629 | err := fs.FsInfo(fullPath)
return capacity, err
} | |
c25630 | *FakeVolumeUtil {
return &FakeVolumeUtil{
directoryFiles: dirFiles,
deleteShouldFail: deleteShouldFail,
}
} | |
c25631 | if !found {
return nil, fmt.Errorf("Directory %q not found", fullPath)
}
for _, file := range files {
fileNames = append(fileNames, file.Name)
}
return fileNames, nil
} | |
c25632 | {
if u.deleteShouldFail {
return fmt.Errorf("Fake delete contents failed")
}
return nil
} | |
c25633 | return u.getDirEntryCapacity(fullPath, FakeEntryFile)
} | |
c25634 |
return u.getDirEntryCapacity(fullPath, FakeEntryBlock)
} | |
c25635 | []*FakeDirEntry{}
}
glog.Infof("Adding to directory %q: files %v\n", dir, files)
u.directoryFiles[mountedPath] = append(curFiles, files...)
}
} | |
c25636 | "gce-pd"
}
if spec.Cinder != nil {
return "cinder"
}
if spec.Glusterfs != nil {
return "glusterfs"
}
return ""
} | |
c25637 | "gce-pd"
}
if spec.CinderSnapshot != nil {
return "cinder"
}
if spec.GlusterSnapshotVolume != nil {
return "glusterfs"
}
return ""
} | |
c25638 | nil {
return err
}
tmp2 := VolumeSnapshot(tmp)
*v = tmp2
return nil
} | |
c25639 | }
if tags != nil {
opts.Metadata = tags
}
snapshotID, status, err := snapshots.createSnapshot(opts)
if err != nil {
glog.Errorf("Failed to snapshot volume %s : %v", sourceVolumeID, err)
return "", "", err
}
glog.Infof("Created snapshot %v from volume: %v", snapshotID, sourceVolumeID)
return snapshotID,... | |
c25640 | snapshots.deleteSnapshot(snapshotID)
if err != nil {
glog.Errorf("Cannot delete snapshot %s: %v", snapshotID, err)
}
return nil
} | |
c25641 | if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotNameTag] == nameVal {
uidVal, ok := snapshot.Metadata[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotUIDTag]
if ok {
if tags[ctrlsnap.CloudSnapshotCreatedForVolumeSnapshotUIDTag] == uidVal {
timeVal, ok := snapshot.Metadata[ctrlsnap.Clo... | |
c25642 | err != nil {
return nil, err
}
defaultCfg(&cfg)
return &cfg, nil
} | |
c25643 | "_test.go") {
b, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
if bytes.Contains(b, []byte(openAPIGenTag)) {
includeMe = true
}
}
}
if includeMe {
pkg, err := v.ctx.ImportDir(root, 0)
if err != nil {
return nil, err
}
res = append(res, pkg.ImportPath)
}
return r... | |
c25644 | client,
identity: id,
rbdUtil: &RBDUtil{
timeout: timeout,
},
usePVName: usePVName,
}
} | |
c25645 | {
return []v1.PersistentVolumeAccessMode{
v1.ReadWriteOnce,
v1.ReadOnlyMany,
}
} | |
c25646 | err != nil {
return "", err
}
// TODO: Should we check secret.Type, like `k8s.io/kubernetes/pkg/volume/util.GetSecretForPV` function?
secret := ""
for k, v := range secrets.Data {
if k == secretKeyName {
return string(v), nil
}
secret = string(v)
}
// If not found, the last secret in the map wins as ... | |
c25647 |
if in == nil {
return nil
}
out := new(AWSElasticBlockStoreVolumeSnapshotSource)
in.DeepCopyInto(out)
return out
} | |
c25648 |
if in == nil {
return nil
}
out := new(CinderVolumeSnapshotSource)
in.DeepCopyInto(out)
return out
} | |
c25649 |
if in == nil {
return nil
}
out := new(GCEPersistentDiskSnapshotSource)
in.DeepCopyInto(out)
return out
} | |
c25650 |
if in == nil {
return nil
}
out := new(GlusterVolumeSnapshotSource)
in.DeepCopyInto(out)
return out
} | |
c25651 |
if in == nil {
return nil
}
out := new(HostPathVolumeSnapshotSource)
in.DeepCopyInto(out)
return out
} | |
c25652 |
out := new(VolumeSnapshot)
in.DeepCopyInto(out)
return out
} | |
c25653 |
if in == nil {
return nil
}
out := new(VolumeSnapshotCondition)
in.DeepCopyInto(out)
return out
} | |
c25654 | }
out := new(VolumeSnapshotCopy)
in.DeepCopyInto(out)
return out
} | |
c25655 | }
out := new(VolumeSnapshotData)
in.DeepCopyInto(out)
return out
} | |
c25656 |
if in == nil {
return nil
}
out := new(VolumeSnapshotDataCondition)
in.DeepCopyInto(out)
return out
} | |
c25657 | if in == nil {
return nil
}
out := new(VolumeSnapshotDataCopy)
in.DeepCopyInto(out)
return out
} | |
c25658 | if in == nil {
return nil
}
out := new(VolumeSnapshotDataList)
in.DeepCopyInto(out)
return out
} | |
c25659 |
if in == nil {
return nil
}
out := new(VolumeSnapshotDataListCopy)
in.DeepCopyInto(out)
return out
} | |
c25660 |
if in == nil {
return nil
}
out := new(VolumeSnapshotDataSource)
in.DeepCopyInto(out)
return out
} | |
c25661 | if in == nil {
return nil
}
out := new(VolumeSnapshotDataSpec)
in.DeepCopyInto(out)
return out
} | |
c25662 |
if in == nil {
return nil
}
out := new(VolumeSnapshotDataStatus)
in.DeepCopyInto(out)
return out
} | |
c25663 | }
out := new(VolumeSnapshotList)
in.DeepCopyInto(out)
return out
} | |
c25664 | if in == nil {
return nil
}
out := new(VolumeSnapshotListCopy)
in.DeepCopyInto(out)
return out
} | |
c25665 | }
out := new(VolumeSnapshotSpec)
in.DeepCopyInto(out)
return out
} | |
c25666 |
}
out := new(VolumeSnapshotStatus)
in.DeepCopyInto(out)
return out
} | |
c25667 | loadbalancer == nil {
return nil, false, err
}
status := &v1.LoadBalancerStatus{}
status.Ingress = []v1.LoadBalancerIngress{{IP: loadbalancer.VipAddress}}
return status, true, err
} | |
c25668 |
if vip == nil {
return nil, false, err
}
status := &v1.LoadBalancerStatus{}
status.Ingress = []v1.LoadBalancerIngress{{IP: vip.Address}}
return status, true, err
} | |
c25669 | metav1.GetOptions{})
if err != nil {
glog.Errorf("Error getting maya-apiserver IP Address: %v", err)
}
clusterIP = sc.Spec.ClusterIP
glog.V(2).Infof("Maya Cluster IP: %v", clusterIP)
return clusterIP, err
} | |
c25670 | := http.NewRequest("POST", url, bytes.NewBuffer(yamlValue))
req.Header.Add("Content-Type", "application/yaml")
c := &http.Client{
Timeout: timeout,
}
resp, err := c.Do(req)
if err != nil {
glog.Errorf("Error when connecting maya-apiserver %v", err)
return "Could not connect to maya-apiserver", err
}
def... | |
c25671 | when connecting to maya-apiserver %v", err)
return err
}
defer resp.Body.Close()
code := resp.StatusCode
if code != http.StatusOK {
glog.Errorf("HTTP Status error from maya-apiserver: %v\n", http.StatusText(code))
return err
}
glog.V(2).Info("volume Details Successfully Retrieved")
return json.NewDecoder... | |
c25672 | != nil {
klog.Warningf("couldn't create an AWS session: %v", err)
}
svc := efs.New(sess, &aws.Config{Region: aws.String(awsRegion)})
params := &efs.DescribeFileSystemsInput{
FileSystemId: aws.String(fileSystemID),
}
_, err = svc.DescribeFileSystems(params)
if err != nil {
klog.Warningf("couldn't confirm ... | |
c25673 | metrics.APIServerRequestsDurationSeconds.WithLabelValues(metrics.APIServerRequestCreate).Observe(time.Since(startTime).Seconds())
if err != nil {
metrics.APIServerRequestsFailedTotal.WithLabelValues(metrics.APIServerRequestCreate).Inc()
}
return pv, err
} | |
c25674 | metrics.APIServerRequestsDurationSeconds.WithLabelValues(metrics.APIServerRequestDelete).Observe(time.Since(startTime).Seconds())
if err != nil {
metrics.APIServerRequestsFailedTotal.WithLabelValues(metrics.APIServerRequestDelete).Inc()
}
return err
} | |
c25675 |
deletedPVs: map[string]*v1.PersistentVolume{},
CreatedJobs: map[string]*batch_v1.Job{},
DeletedJobs: map[string]string{},
shouldFail: shouldFail,
cache: cache,
}
} | |
c25676 | fmt.Errorf("API failed")
}
u.createdPVs[pv.Name] = pv
u.cache.AddPV(pv)
return pv, nil
} | |
c25677 | if exists {
u.deletedPVs[pvName] = pv
delete(u.createdPVs, pvName)
u.cache.DeletePV(pvName)
return nil
}
return errors.NewNotFound(v1.Resource("persistentvolumes"), pvName)
} | |
c25678 | {
createdPVs := u.createdPVs
u.createdPVs = map[string]*v1.PersistentVolume{}
return createdPVs
} | |
c25679 | {
deletedPVs := u.deletedPVs
u.deletedPVs = map[string]*v1.PersistentVolume{}
return deletedPVs
} | |
c25680 | error {
u.CreatedJobs[job.Namespace+"/"+job.Name] = job
return nil
} | |
c25681 | u.DeletedJobs[namespace+"/"+jobName] = jobName
return nil
} | |
c25682 | if nodeName == "" {
glog.V(2).Infof("Skipping EC2 instance (no PrivateDNSName): %s",
aws.StringValue(instance.InstanceId))
continue
}
for _, tag := range instance.Tags {
if orEmpty(tag.Key) == "Name" && re.MatchString(orEmpty(tag.Value)) {
matchingInstances = append(matchingInstances, nodeName)
... | |
c25683 | mountDevice, volume := range c.attaching[i.nodeName] {
deviceMappings[mountDevice] = volume
}
// Check to see if this volume is already assigned a device on this machine
for mountDevice, mappingVolumeID := range deviceMappings {
if volumeID == mappingVolumeID {
if assign {
glog.Warningf("Got assignment ... | |
c25684 | err != nil {
return nil, fmt.Errorf("error querying ec2 for volume %q: %v", volumeID, err)
}
if len(volumes) == 0 {
return nil, fmt.Errorf("no volumes found for volume %q", volumeID)
}
if len(volumes) > 1 {
return nil, fmt.Errorf("multiple volumes found for volume %q", volumeID)
}
return volumes[0], nil
} | |
c25685 | glog.Warningf("Ignoring error from describe volume; will retry: %q", err)
return false, nil
}
describeErrorCount = 0
if len(info.Attachments) > 1 {
// Shouldn't happen; log so we know if it is
glog.Warningf("Found multiple attachments for volume %q: %v", d.awsID, info)
}
attachmentStatus := ""
fo... | |
c25686 |
if awsError.Code() == "InvalidVolume.NotFound" {
return false, nil
}
if awsError.Code() == "VolumeInUse" {
return false, volume.NewDeletedVolumeInUseError(err.Error())
}
}
return false, fmt.Errorf("error deleting EBS volume %q: %v", d.awsID, err)
}
return true, nil
} | |
c25687 | {
return nil, err
}
awsInstance = newAWSInstance(c.ec2, instance)
}
return awsInstance, nil
} | |
c25688 | return nil, fmt.Errorf("volume did not have AZ information: %q", *info.VolumeId)
}
labels[apis.LabelZoneFailureDomain] = az
region, err := azToRegion(az)
if err != nil {
return nil, err
}
labels[apis.LabelZoneRegion] = region
return labels, nil
} | |
c25689 |
// If instance no longer exists, safe to assume volume is not attached.
glog.Warningf(
"Node %q does not exist. DisksAreAttached will assume disks %v are not attached to it.",
nodeName,
diskNames)
continue
}
idToDiskName := make(map[awsVolumeID]KubernetesVolumeID)
for _, diskName := range d... | |
c25690 |
if err := c.tagging.createTags(c.ec2, string(awsID), ResourceLifecycleOwned, *snapshotOptions.Tags); err != nil {
_, delerr := c.DeleteSnapshot(*res.SnapshotId)
if delerr != nil {
return "", "", fmt.Errorf("error tagging snapshot %s, could not delete the snapshot: %v", *res.SnapshotId, delerr)
}
retu... | |
c25691 |
request.SnapshotId = aws.String(snapshotID)
_, err := c.ec2.DeleteSnapshot(request)
if err != nil {
return false, err
}
return true, nil
} | |
c25692 | }
if *result[0].State == ec2.SnapshotStateError {
return *result[0].State, false, fmt.Errorf("snapshot state is error: %s", *result[0].StateMessage)
}
if *result[0].State == ec2.SnapshotStatePending {
return *result[0].State, false, nil
}
return *result[0].State, false, fmt.Errorf("unknown state")
} | |
c25693 |
id := *snapshot.SnapshotId
status := *snapshot.State
glog.Infof("found %s, status %s", id, status)
snapshotIDs = append(snapshotIDs, id)
statuses = append(statuses, status)
}
return snapshotIDs, statuses, nil
} | |
c25694 | }
if len(groups) != 1 {
// This should not be possible - ids should be unique
return nil, fmt.Errorf("multiple security groups found with same id %q", securityGroupID)
}
group := groups[0]
return group, nil
} | |
c25695 | if add.Len() == 0 && remove.Len() == 0 {
return false, nil
}
// TODO: There is a limit in VPC of 100 rules per security group, so we
// probably should try grouping or combining to fit under this limit.
// But this is only used on the ELB security group currently, so it
// would require (ports * CIDRS) > 100. ... | |
c25696 | fmt.Errorf("Multiple tagged security groups found for instance %s; ensure only the k8s security group is tagged", instanceID)
}
return tagged[0], nil
}
if len(untagged) > 0 {
// For back-compat, we will allow a single untagged SG
if len(untagged) != 1 {
return nil, fmt.Errorf("Multiple untagged security ... | |
c25697 |
if len(instances) > 1 {
return nil, fmt.Errorf("multiple instances found for instance: %s", instanceID)
}
return instances[instanceID], nil
} | |
c25698 | == nil {
return nil, cloudprovider.ErrInstanceNotFound
}
return instance, err
} | |
c25699 | {
klog.Infof("Creating NewGlusterfsProvisioner.")
return newGlusterfsProvisionerInternal(config, client)
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.